diff options
author | Rémy Boulanouar <rboulanouar@gmail.com> | 2017-09-14 13:46:14 +0200 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-09-14 14:46:14 +0300 |
commit | e5d80b7090d7c1088854e8a0f8223bdf8a769d12 (patch) | |
tree | 0ce2f8ded817b346d6637dd06cf78080dab17bf1 /routers | |
parent | 1739e84ac02c0384c04576a00abab9348293f9c7 (diff) | |
download | gitea-e5d80b7090d7c1088854e8a0f8223bdf8a769d12.tar.gz gitea-e5d80b7090d7c1088854e8a0f8223bdf8a769d12.zip |
Implementation of all repositories of a user from user->settings (#1740)
* Implementation of all repositories of a user from user->settings
* Update message when no repository found
* Update according to comments
* Change UI to have a better look
* improved user repositories UI
Diffstat (limited to 'routers')
-rw-r--r-- | routers/routes/routes.go | 1 | ||||
-rw-r--r-- | routers/user/setting.go | 35 |
2 files changed, 36 insertions, 0 deletions
diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 067bf6a7f6..a0684c8478 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -237,6 +237,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Route("/delete", "GET,POST", user.SettingsDelete) m.Combo("/account_link").Get(user.SettingsAccountLinks).Post(user.SettingsDeleteAccountLink) m.Get("/organization", user.SettingsOrganization) + m.Get("/repos", user.SettingsRepos) m.Group("/two_factor", func() { m.Get("", user.SettingsTwoFactor) m.Post("/regenerate_scratch", user.SettingsTwoFactorRegenerateScratch) diff --git a/routers/user/setting.go b/routers/user/setting.go index 2c951eaf5f..b71b29ba21 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -39,6 +39,7 @@ const ( tplSettingsTwofaEnroll base.TplName = "user/settings/twofa_enroll" tplSettingsAccountLink base.TplName = "user/settings/account_link" tplSettingsOrganization base.TplName = "user/settings/organization" + tplSettingsRepositories base.TplName = "user/settings/repos" tplSettingsDelete base.TplName = "user/settings/delete" tplSecurity base.TplName = "user/security" ) @@ -785,3 +786,37 @@ func SettingsOrganization(ctx *context.Context) { ctx.Data["Orgs"] = orgs ctx.HTML(200, tplSettingsOrganization) } + +// SettingsRepos display a list of all repositories of the user +func SettingsRepos(ctx *context.Context) { + ctx.Data["Title"] = ctx.Tr("settings") + ctx.Data["PageIsSettingsRepos"] = true + ctxUser := ctx.User + + var err error + if err = ctxUser.GetRepositories(1, setting.UI.User.RepoPagingNum); err != nil { + ctx.Handle(500, "GetRepositories", err) + return + } + repos := ctxUser.Repos + + for i := range repos { + if repos[i].IsFork { + err := repos[i].GetBaseRepo() + if err != nil { + ctx.Handle(500, "GetBaseRepo", err) + return + } + err = repos[i].BaseRepo.GetOwner() + if err != nil { + ctx.Handle(500, "GetOwner", err) + return + } + } + } + + ctx.Data["Owner"] = ctxUser + ctx.Data["Repos"] = repos + + ctx.HTML(200, tplSettingsRepositories) +} |