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 @@ -301,6 +301,8 @@ DEFAULT_KEEP_EMAIL_PRIVATE = false
301
301
; Default value for AllowCreateOrganization
302
302
; New user will have rights set to create organizations depending on this setting
303
303
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
304
+ ; Enable Timetracking
305
+ ENABLE_TIMETRACKING = true
304
306
; Default value for EnableTimetracking
305
307
; Repositories will use timetracking by default depending on this setting
306
308
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 @@ -1151,6 +1151,7 @@ var Service struct {
1151
1151
EnableCaptcha bool
1152
1152
DefaultKeepEmailPrivate bool
1153
1153
DefaultAllowCreateOrganization bool
1154
+ EnableTimetracking bool
1154
1155
DefaultEnableTimetracking bool
1155
1156
DefaultAllowOnlyContributorsToTrackTime bool
1156
1157
NoReplyAddress string
@@ -1174,7 +1175,10 @@ func newService() {
1174
1175
Service .EnableCaptcha = sec .Key ("ENABLE_CAPTCHA" ).MustBool ()
1175
1176
Service .DefaultKeepEmailPrivate = sec .Key ("DEFAULT_KEEP_EMAIL_PRIVATE" ).MustBool ()
1176
1177
Service .DefaultAllowCreateOrganization = sec .Key ("DEFAULT_ALLOW_CREATE_ORGANIZATION" ).MustBool (true )
1177
- Service .DefaultEnableTimetracking = sec .Key ("DEFAULT_ENABLE_TIMETRACKING" ).MustBool (true )
1178
+ Service .EnableTimetracking = sec .Key ("ENABLE_TIMETRACKING" ).MustBool (true )
1179
+ if Service .EnableTimetracking {
1180
+ Service .DefaultEnableTimetracking = sec .Key ("DEFAULT_ENABLE_TIMETRACKING" ).MustBool (true )
1181
+ }
1178
1182
Service .DefaultAllowOnlyContributorsToTrackTime = sec .Key ("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME" ).MustBool (true )
1179
1183
Service .NoReplyAddress = sec .Key ("NO_REPLY_ADDRESS" ).MustString ("noreply.example.org" )
1180
1184
Original file line number Diff line number Diff line change @@ -1435,6 +1435,7 @@ config.active_code_lives = Active Code Lives
1435
1435
config.reset_password_code_lives = Reset Password Code Expiry Time
1436
1436
config.default_keep_email_private = Default Value for Keep Email Private
1437
1437
config.default_allow_create_organization = Default permission to create organizations
1438
+ config.enable_timetracking = Enable time tracking
1438
1439
config.default_enable_timetracking = Enable time tracking by default
1439
1440
config.default_allow_only_contributors_to_track_time = Allow only contributors to track time by default
1440
1441
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