summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--routers/repo/setting.go4
-rw-r--r--templates/repo/settings/options.tmpl4
2 files changed, 6 insertions, 2 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index c24cee3b21..0101b2362b 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -95,8 +95,8 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
}
visibilityChanged := repo.IsPrivate != form.Private
- // when ForcePrivate enabled, you could change public repo to private, but could not change private to public
- if visibilityChanged && setting.Repository.ForcePrivate && !form.Private {
+ // when ForcePrivate enabled, you could change public repo to private, but only admin users can change private to public
+ if visibilityChanged && setting.Repository.ForcePrivate && !form.Private && !ctx.User.IsAdmin {
ctx.ServerError("Force Private enabled", errors.New("cannot change private repository to public"))
return
}
diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl
index 94fbcbe651..7e25206c9d 100644
--- a/templates/repo/settings/options.tmpl
+++ b/templates/repo/settings/options.tmpl
@@ -19,7 +19,11 @@
<div class="inline field">
<label>{{.i18n.Tr "repo.visibility"}}</label>
<div class="ui checkbox">
+ {{if .IsAdmin}}
+ <input name="private" type="checkbox" {{if .Repository.IsPrivate}}checked{{end}}>
+ {{else}}
<input name="private" type="checkbox" {{if .Repository.IsPrivate}}checked{{end}}{{if and $.ForcePrivate .Repository.IsPrivate}} readonly{{end}}>
+ {{end}}
<label>{{.i18n.Tr "repo.visibility_helper" | Safe}} {{if .Repository.NumForks}}<span class="text red">{{.i18n.Tr "repo.visibility_fork_helper"}}</span>{{end}}</label>
</div>
</div>