Remove extra OwnUserPage field

Move logic into template, rather than add another field to the page.

Ref T695
This commit is contained in:
Matt Baer 2019-11-11 16:06:03 +09:00
parent 6e09fcb9e2
commit 6d4ec0b17d
2 changed files with 3 additions and 5 deletions

View file

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

View file

@ -61,7 +61,7 @@ button[type="submit"].danger {
<tr>
<th>Password</th>
<td>
{{if not .OwnUserPage}}
{{if ne .Username .User.Username}}
<form id="reset-form" action="/admin/user/{{.User.Username}}/passphrase" method="post" autocomplete="false">
<input type="hidden" name="user" value="{{.User.ID}}"/>
<button