1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-10-29 08:17:31 -04:00

#965 Remember visibility preference

This commit is contained in:
Unknwon 2015-08-28 18:45:25 +08:00
parent 11ce720f9f
commit c75cd33f2f

View File

@ -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