From a365e42dcfb8a9383be42da9cbf123f856804091 Mon Sep 17 00:00:00 2001 From: Azareal Date: Tue, 2 Oct 2018 17:20:55 +1000 Subject: [PATCH] Added a missing panel_ prefix for a template and added a couple more error phrases. --- langs/english.json | 5 ++++- routes/panel/common.go | 1 + routes/panel/groups.go | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/langs/english.json b/langs/english.json index 08c75705..164afe87 100644 --- a/langs/english.json +++ b/langs/english.json @@ -96,7 +96,10 @@ "register_password_mismatch":"The two passwords don't match.", "register_username_unavailable":"This username isn't available. Try another.", "register_username_too_long_prefix":"The username is too long, max: ", - "register_email_fail":"We were unable to send the email for you to confirm that this email address belongs to you. You may not have access to some functionality until you do so. Please ask an administrator for assistance." + "register_email_fail":"We were unable to send the email for you to confirm that this email address belongs to you. You may not have access to some functionality until you do so. Please ask an administrator for assistance.", + + "panel_groups_cannot_edit_admin":"You need the EditGroupAdmin permission to edit an admin group.", + "panel_groups_cannot_edit_supermod":"You need the EditGroupSuperMod permission to edit a super-mod group." }, "PageTitles": { diff --git a/routes/panel/common.go b/routes/panel/common.go index 24dcfd21..8590bcc1 100644 --- a/routes/panel/common.go +++ b/routes/panel/common.go @@ -24,6 +24,7 @@ func renderTemplate(tmplName string, w http.ResponseWriter, r *http.Request, use if common.RunPreRenderHook("pre_render_"+tmplName, w, r, &user, pi) { return nil } + // TODO: Prepend this with panel_? err := common.Templates.ExecuteTemplate(w, tmplName+".html", pi) if err != nil { return common.InternalError(err, w, r) diff --git a/routes/panel/groups.go b/routes/panel/groups.go index 108ad2b2..ba93e3fa 100644 --- a/routes/panel/groups.go +++ b/routes/panel/groups.go @@ -86,10 +86,10 @@ func GroupsEdit(w http.ResponseWriter, r *http.Request, user common.User, sgid s } if group.IsAdmin && !user.Perms.EditGroupAdmin { - return common.LocalError("You need the EditGroupAdmin permission to edit an admin group.", w, r, user) + return common.LocalError(common.GetErrorPhrase("panel_groups_cannot_edit_admin"), w, r, user) } if group.IsMod && !user.Perms.EditGroupSuperMod { - return common.LocalError("You need the EditGroupSuperMod permission to edit a super-mod group.", w, r, user) + return common.LocalError(common.GetErrorPhrase("panel_groups_cannot_edit_supermod"), w, r, user) } var rank string @@ -108,7 +108,7 @@ func GroupsEdit(w http.ResponseWriter, r *http.Request, user common.User, sgid s disableRank := !user.Perms.EditGroupGlobalPerms || (group.ID == 6) pi := common.PanelEditGroupPage{basePage, group.ID, group.Name, group.Tag, rank, disableRank} - return renderTemplate("group_edit", w, r, user, pi) + return renderTemplate("panel_group_edit", w, r, user, pi) } //routePanelGroupsEditPerms @@ -135,10 +135,10 @@ func GroupsEditPerms(w http.ResponseWriter, r *http.Request, user common.User, s } if group.IsAdmin && !user.Perms.EditGroupAdmin { - return common.LocalError("You need the EditGroupAdmin permission to edit an admin group.", w, r, user) + return common.LocalError(common.GetErrorPhrase("panel_groups_cannot_edit_admin"), w, r, user) } if group.IsMod && !user.Perms.EditGroupSuperMod { - return common.LocalError("You need the EditGroupSuperMod permission to edit a super-mod group.", w, r, user) + return common.LocalError(common.GetErrorPhrase("panel_groups_cannot_edit_supermod"), w, r, user) } // TODO: Load the phrases in bulk for efficiency? @@ -188,7 +188,7 @@ func GroupsEditPerms(w http.ResponseWriter, r *http.Request, user common.User, s addGlobalPerm("UploadFiles", group.Perms.UploadFiles) pi := common.PanelEditGroupPermsPage{basePage, group.ID, group.Name, localPerms, globalPerms} - return renderTemplate("group_edit_perms", w, r, user, pi) + return renderTemplate("panel_group_edit_perms", w, r, user, pi) } //routePanelGroupsEditSubmit @@ -215,10 +215,10 @@ func GroupsEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, } if group.IsAdmin && !user.Perms.EditGroupAdmin { - return common.LocalError("You need the EditGroupAdmin permission to edit an admin group.", w, r, user) + return common.LocalError(common.GetErrorPhrase("panel_groups_cannot_edit_admin"), w, r, user) } if group.IsMod && !user.Perms.EditGroupSuperMod { - return common.LocalError("You need the EditGroupSuperMod permission to edit a super-mod group.", w, r, user) + return common.LocalError(common.GetErrorPhrase("panel_groups_cannot_edit_supermod"), w, r, user) } gname := r.FormValue("group-name") @@ -305,10 +305,10 @@ func GroupsEditPermsSubmit(w http.ResponseWriter, r *http.Request, user common.U } if group.IsAdmin && !user.Perms.EditGroupAdmin { - return common.LocalError("You need the EditGroupAdmin permission to edit an admin group.", w, r, user) + return common.LocalError(common.GetErrorPhrase("panel_groups_cannot_edit_admin"), w, r, user) } if group.IsMod && !user.Perms.EditGroupSuperMod { - return common.LocalError("You need the EditGroupSuperMod permission to edit a super-mod group.", w, r, user) + return common.LocalError(common.GetErrorPhrase("panel_groups_cannot_edit_supermod"), w, r, user) } var pmap = make(map[string]bool)