From c75cd33f2fc792622885edf9429d41a44d08c6c5 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 28 Aug 2015 18:45:25 +0800 Subject: [PATCH] #965 Remember visibility preference --- routers/repo/repo.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/routers/repo/repo.go b/routers/repo/repo.go index f0e1ce939a2..8cb2db3a5e7 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