File tree 6 files changed +38
-16
lines changed
6 files changed +38
-16
lines changed Original file line number Diff line number Diff line change @@ -299,6 +299,8 @@ DEFAULT_KEEP_EMAIL_PRIVATE = false
299
299
; Default value for AllowCreateOrganization
300
300
; New user will have rights set to create organizations depending on this setting
301
301
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
302
+ ; Enable Timetracking
303
+ ENABLE_TIMETRACKING = true
302
304
; Default value for EnableTimetracking
303
305
; Repositories will use timetracking by default depending on this setting
304
306
DEFAULT_ENABLE_TIMETRACKING = true
Original file line number Diff line number Diff line change @@ -13,8 +13,18 @@ import "code.gitea.io/gitea/modules/setting"
13
13
// |____| |__|__|_| /\___ >____| |__| (____ /\___ >__|_ \\___ >__|
14
14
// \/ \/ \/ \/ \/ \/
15
15
16
+ // CanEnableTimetracker returns true when the server admin enabled time tracking
17
+ // This overrules IsTimetrackerEnabled
18
+ func (repo * Repository ) CanEnableTimetracker () bool {
19
+ return setting .Service .EnableTimetracking
20
+ }
21
+
16
22
// IsTimetrackerEnabled returns whether or not the timetracker is enabled. It returns the default value from config if an error occurs.
17
23
func (repo * Repository ) IsTimetrackerEnabled () bool {
24
+ if ! setting .Service .EnableTimetracking {
25
+ return false
26
+ }
27
+
18
28
var u * RepoUnit
19
29
var err error
20
30
if u , err = repo .GetUnit (UnitTypeIssues ); err != nil {
Original file line number Diff line number Diff line change @@ -1149,6 +1149,7 @@ var Service struct {
1149
1149
EnableCaptcha bool
1150
1150
DefaultKeepEmailPrivate bool
1151
1151
DefaultAllowCreateOrganization bool
1152
+ EnableTimetracking bool
1152
1153
DefaultEnableTimetracking bool
1153
1154
DefaultAllowOnlyContributorsToTrackTime bool
1154
1155
NoReplyAddress string
@@ -1172,7 +1173,10 @@ func newService() {
1172
1173
Service .EnableCaptcha = sec .Key ("ENABLE_CAPTCHA" ).MustBool ()
1173
1174
Service .DefaultKeepEmailPrivate = sec .Key ("DEFAULT_KEEP_EMAIL_PRIVATE" ).MustBool ()
1174
1175
Service .DefaultAllowCreateOrganization = sec .Key ("DEFAULT_ALLOW_CREATE_ORGANIZATION" ).MustBool (true )
1175
- Service .DefaultEnableTimetracking = sec .Key ("DEFAULT_ENABLE_TIMETRACKING" ).MustBool (true )
1176
+ Service .EnableTimetracking = sec .Key ("ENABLE_TIMETRACKING" ).MustBool (true )
1177
+ if Service .EnableTimetracking {
1178
+ Service .DefaultEnableTimetracking = sec .Key ("DEFAULT_ENABLE_TIMETRACKING" ).MustBool (true )
1179
+ }
1176
1180
Service .DefaultAllowOnlyContributorsToTrackTime = sec .Key ("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME" ).MustBool (true )
1177
1181
Service .NoReplyAddress = sec .Key ("NO_REPLY_ADDRESS" ).MustString ("noreply.example.org" )
1178
1182
Original file line number Diff line number Diff line change @@ -1429,6 +1429,7 @@ config.active_code_lives = Active Code Lives
1429
1429
config.reset_password_code_lives = Reset Password Code Expiry Time
1430
1430
config.default_keep_email_private = Default Value for Keep Email Private
1431
1431
config.default_allow_create_organization = Default permission to create organizations
1432
+ config.enable_timetracking = Enable time tracking
1432
1433
config.default_enable_timetracking = Enable time tracking by default
1433
1434
config.default_allow_only_contributors_to_track_time = Allow only contributors to track time by default
1434
1435
config.no_reply_address = No-reply Address
Original file line number Diff line number Diff line change 132
132
<dd><i class="fa fa{{if .Service.DefaultKeepEmailPrivate}}-check{{end}}-square-o"></i></dd>
133
133
<dt>{{.i18n.Tr "admin.config.default_allow_create_organization"}}</dt>
134
134
<dd><i class="fa fa{{if .Service.DefaultAllowCreateOrganization}}-check{{end}}-square-o"></i></dd>
135
- <dt>{{.i18n.Tr "admin.config.default_enable_timetracking"}}</dt>
136
- <dd><i class="fa fa{{if .Service.DefaultEnableTimetracking}}-check{{end}}-square-o"></i></dd>
137
- <dt>{{.i18n.Tr "admin.config.default_allow_only_contributors_to_track_time"}}</dt>
138
- <dd><i class="fa fa{{if .Service.DefaultAllowOnlyContributorsToTrackTime}}-check{{end}}-square-o"></i></dd>
135
+ <dt>{{.i18n.Tr "admin.config.enable_timetracking"}}</dt>
136
+ <dd><i class="fa fa{{if .Service.EnableTimetracking}}-check{{end}}-square-o"></i></dd>
137
+ {{if .Service.EnableTimetracking}}
138
+ <dt>{{.i18n.Tr "admin.config.default_enable_timetracking"}}</dt>
139
+ <dd><i class="fa fa{{if .Service.DefaultEnableTimetracking}}-check{{end}}-square-o"></i></dd>
140
+ <dt>{{.i18n.Tr "admin.config.default_allow_only_contributors_to_track_time"}}</dt>
141
+ <dd><i class="fa fa{{if .Service.DefaultAllowOnlyContributorsToTrackTime}}-check{{end}}-square-o"></i></dd>
142
+ {{end}}
139
143
<dt>{{.i18n.Tr "admin.config.no_reply_address"}}</dt>
140
144
<dd>{{if .Service.NoReplyAddress}}{{.Service.NoReplyAddress}}{{else}}-{{end}}</dd>
141
145
<div class="ui divider"></div>
Original file line number Diff line number Diff line change 139
139
</div>
140
140
</div>
141
141
<div class="field {{if (.Repository.UnitEnabled $.UnitTypeExternalTracker)}}disabled{{end}}" id="internal_issue_box">
142
- <div class="field">
143
- <div class="ui checkbox">
144
- <input name="enable_timetracker" class="enable-system" data-target="#only_contributors" type="checkbox" {{if .Repository.IsTimetrackerEnabled}}checked{{end}}>
145
- <label>{{.i18n.Tr "repo.settings.enable_timetracker"}}</label>
142
+ {{if .Repository.CanEnableTimetracker}}
143
+ <div class="field">
144
+ <div class="ui checkbox">
145
+ <input name="enable_timetracker" class="enable-system" data-target="#only_contributors" type="checkbox" {{if .Repository.IsTimetrackerEnabled}}checked{{end}}>
146
+ <label>{{.i18n.Tr "repo.settings.enable_timetracker"}}</label>
147
+ </div>
146
148
</div>
147
- </div>
148
- <div class="field {{if not .Repository.IsTimetrackerEnabled}}disabled{{end}}" id="only_contributors">
149
- <div class="ui checkbox">
150
-
151
- <input name="allow_only_contributors_to_track_time" type="checkbox" {{if .Repository.AllowOnlyContributorsToTrackTime}}checked{{end}}>
152
- <label>{{.i18n.Tr "repo.settings.allow_only_contributors_to_track_time"}}</label>
149
+ <div class="field {{if not .Repository.IsTimetrackerEnabled}}disabled{{end}}" id="only_contributors">
150
+ <div class="ui checkbox">
151
+ <input name="allow_only_contributors_to_track_time" type="checkbox" {{if .Repository.AllowOnlyContributorsToTrackTime}}checked{{end}}>
152
+ <label>{{.i18n.Tr "repo.settings.allow_only_contributors_to_track_time"}}</label>
153
+ </div>
153
154
</div>
154
- </div>
155
+ {{end}}
155
156
</div>
156
157
<div class="field">
157
158
<div class="ui radio checkbox">
You can’t perform that action at this time.
0 commit comments