summaryrefslogtreecommitdiffstats
path: root/routers/repo/repo.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-08-28 18:45:25 +0800
committerUnknwon <u@gogs.io>2015-08-28 18:45:25 +0800
commitc75cd33f2fc792622885edf9429d41a44d08c6c5 (patch)
tree96411c2e397c2cbcdd25e6b1bacff19f650492ba /routers/repo/repo.go
parent11ce720f9f3e8cb32207d9ca08a7d56024680cd3 (diff)
downloadgitea-c75cd33f2fc792622885edf9429d41a44d08c6c5.tar.gz
gitea-c75cd33f2fc792622885edf9429d41a44d08c6c5.zip
#965 Remember visibility preference
Diffstat (limited to 'routers/repo/repo.go')
-rw-r--r--routers/repo/repo.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index f0e1ce939a..8cb2db3a5e 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -65,6 +65,7 @@ func Create(ctx *middleware.Context) {
ctx.Data["Licenses"] = models.Licenses
ctx.Data["Readmes"] = models.Readmes
ctx.Data["readme"] = "Default"
+ ctx.Data["private"] = ctx.User.LastRepoVisibility
ctxUser := checkContextUser(ctx, ctx.QueryInt64("org"))
if ctx.Written() {
@@ -119,6 +120,10 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
AutoInit: form.AutoInit,
})
if err == nil {
+ // Remember visibility preference.
+ ctx.User.LastRepoVisibility = repo.IsPrivate
+ models.UpdateUser(ctx.User)
+
log.Trace("Repository created: %s/%s", ctxUser.Name, repo.Name)
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name)
return
@@ -135,6 +140,7 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
func Migrate(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("new_migrate")
+ ctx.Data["private"] = ctx.User.LastRepoVisibility
ctxUser := checkContextUser(ctx, ctx.QueryInt64("org"))
if ctx.Written() {
@@ -184,6 +190,10 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
repo, err := models.MigrateRepository(ctxUser, form.RepoName, form.Description, form.Private, form.Mirror, remoteAddr)
if err == nil {
+ // Remember visibility preference.
+ ctx.User.LastRepoVisibility = repo.IsPrivate
+ models.UpdateUser(ctx.User)
+
log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName)
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + form.RepoName)
return