From 6d4ec0b17db8f27673f91a7c2fa20229a93527f3 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 11 Nov 2019 16:06:03 +0900 Subject: [PATCH] Remove extra OwnUserPage field Move logic into template, rather than add another field to the page. Ref T695 --- admin.go | 6 ++---- templates/user/admin/view-user.tmpl | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/admin.go b/admin.go index 5b3acab..c5f5646 100644 --- a/admin.go +++ b/admin.go @@ -169,9 +169,8 @@ func handleViewAdminUser(app *App, u *User, w http.ResponseWriter, r *http.Reque p := struct { *UserPage - Config config.AppCfg - Message string - OwnUserPage bool + Config config.AppCfg + Message string User *User Colls []inspectedCollection @@ -196,7 +195,6 @@ func handleViewAdminUser(app *App, u *User, w http.ResponseWriter, r *http.Reque if err != nil { return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not get user: %v", err)} } - p.OwnUserPage = u.ID == p.User.ID p.UserPage = NewUserPage(app, r, u, p.User.Username, nil) p.TotalPosts = app.db.GetUserPostsCount(p.User.ID) lp, err := app.db.GetUserLastPostTime(p.User.ID) diff --git a/templates/user/admin/view-user.tmpl b/templates/user/admin/view-user.tmpl index 91fdaf1..ac1f8bd 100644 --- a/templates/user/admin/view-user.tmpl +++ b/templates/user/admin/view-user.tmpl @@ -61,7 +61,7 @@ button[type="submit"].danger { Password - {{if not .OwnUserPage}} + {{if ne .Username .User.Username}}