From 00767a0522606cd504d81d35fa1d9e9c1e34610c Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 6 Sep 2015 11:25:08 -0400 Subject: [PATCH] finish new org settings page --- routers/org/setting.go | 14 ++++- templates/base/delete_modal_actions.tmpl | 10 ++++ templates/org/settings/delete.tmpl | 71 +++++++++++++----------- templates/org/settings/nav.tmpl | 12 ---- templates/user/settings/delete.tmpl | 15 +---- 5 files changed, 63 insertions(+), 59 deletions(-) create mode 100644 templates/base/delete_modal_actions.tmpl delete mode 100644 templates/org/settings/nav.tmpl diff --git a/routers/org/setting.go b/routers/org/setting.go index c36bafee8c..c6d2db3d97 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -70,7 +70,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) { } log.Trace("Organization setting updated: %s", org.Name) ctx.Flash.Success(ctx.Tr("org.settings.update_setting_success")) - ctx.Redirect(setting.AppSubUrl + "/org/" + org.Name + "/settings") + ctx.Redirect(org.HomeLink() + "/settings") } func SettingsDelete(ctx *middleware.Context) { @@ -79,11 +79,19 @@ func SettingsDelete(ctx *middleware.Context) { org := ctx.Org.Organization if ctx.Req.Method == "POST" { - // FIXME: validate password. + if _, err := models.UserSignIn(ctx.User.Name, ctx.Query("password")); err != nil { + if models.IsErrUserNotExist(err) { + ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_DELETE, nil) + } else { + ctx.Handle(500, "UserSignIn", err) + } + return + } + if err := models.DeleteOrganization(org); err != nil { if models.IsErrUserOwnRepos(err) { ctx.Flash.Error(ctx.Tr("form.org_still_own_repo")) - ctx.Redirect(setting.AppSubUrl + "/org/" + org.LowerName + "/settings/delete") + ctx.Redirect(org.HomeLink() + "/settings/delete") } else { ctx.Handle(500, "DeleteOrganization", err) } diff --git a/templates/base/delete_modal_actions.tmpl b/templates/base/delete_modal_actions.tmpl new file mode 100644 index 0000000000..6e9e256cb9 --- /dev/null +++ b/templates/base/delete_modal_actions.tmpl @@ -0,0 +1,10 @@ +
+
+ + {{.i18n.Tr "modal.no"}} +
+
+ + {{.i18n.Tr "modal.yes"}} +
+
\ No newline at end of file diff --git a/templates/org/settings/delete.tmpl b/templates/org/settings/delete.tmpl index a929fabfe2..707d6f88b2 100644 --- a/templates/org/settings/delete.tmpl +++ b/templates/org/settings/delete.tmpl @@ -1,36 +1,43 @@ -{{template "ng/base/head" .}} -{{template "ng/base/header" .}} -{{template "org/base/header" .}} -
-
- {{template "org/settings/nav" .}} -
-
- {{template "ng/base/alert" .}} -
-
-

{{.i18n.Tr "org.settings.delete_account"}}

-
- {{.i18n.Tr "org.settings.delete_prompt" | Str2html}} -
- {{.CsrfTokenHtml}} -

- - -

-
-
-

{{.i18n.Tr "org.settings.delete_org_title"}}

-

{{.i18n.Tr "org.settings.delete_org_desc"}}

-
- - -
-
-
-
+{{template "base/head" .}} +
+ {{template "org/header" .}} +
+
+ {{template "org/settings/navbar" .}} +
+ {{template "base/alert" .}} +

+ {{.i18n.Tr "org.settings.delete_account"}} +

+
+
+

{{.i18n.Tr "org.settings.delete_prompt" | Str2html}}

+
+
+ {{.CsrfTokenHtml}} + +
+ +
+
+ {{.i18n.Tr "org.settings.confirm_delete_account"}} +
+
+
+
-{{template "ng/base/footer" .}} \ No newline at end of file + + +{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/org/settings/nav.tmpl b/templates/org/settings/nav.tmpl deleted file mode 100644 index 28af4d29a5..0000000000 --- a/templates/org/settings/nav.tmpl +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/templates/user/settings/delete.tmpl b/templates/user/settings/delete.tmpl index d9a0837b5e..6b490ad291 100644 --- a/templates/user/settings/delete.tmpl +++ b/templates/user/settings/delete.tmpl @@ -1,5 +1,5 @@ {{template "base/head" .}} -
+
{{template "user/settings/navbar" .}} @@ -10,7 +10,7 @@
-

{{.i18n.Tr "settings.delete_prompt" | Str2html}}

+

{{.i18n.Tr "settings.delete_prompt" | Str2html}}

{{.CsrfTokenHtml}} @@ -37,15 +37,6 @@

{{.i18n.Tr "settings.delete_account_desc"}}

-
-
- - {{.i18n.Tr "modal.no"}} -
-
- - {{.i18n.Tr "modal.yes"}} -
-
+ {{template "base/delete_modal_actions" .}}
{{template "base/footer" .}} \ No newline at end of file