From a0ba2622ced6ba8fdd24d4118068123d5458ec47 Mon Sep 17 00:00:00 2001 From: yequari Date: Sat, 27 Dec 2025 11:24:47 -0700 Subject: [PATCH] user & group modification in admin panel --- cmd/web/handlers_admin.go | 31 +++- cmd/web/routes.go | 2 + internal/forms/forms.go | 2 +- internal/models/user.go | 10 ++ ui/views/admin.templ | 166 +++++++++++--------- ui/views/admin_templ.go | 319 +++++++++++++++++++++++--------------- 6 files changed, 330 insertions(+), 200 deletions(-) diff --git a/cmd/web/handlers_admin.go b/cmd/web/handlers_admin.go index d2c36bd..4adc7ec 100644 --- a/cmd/web/handlers_admin.go +++ b/cmd/web/handlers_admin.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "net/http" + "time" "git.32bit.cafe/32bitcafe/guestbook/internal/forms" "git.32bit.cafe/32bitcafe/guestbook/internal/models" @@ -52,7 +53,8 @@ func (app *application) getAdminPanelUserMgmtDetail(w http.ResponseWriter, r *ht } return } - views.AdminPanelUserMgmtDetail(u).Render(r.Context(), w) + commonData := app.newCommonData(r) + views.AdminPanelUserMgmtDetail(commonData.CSRFToken, u).Render(r.Context(), w) } func (app *application) getAdminPanelUserMgmtForm(w http.ResponseWriter, r *http.Request) { @@ -108,7 +110,8 @@ func (app *application) putAdminPanelUserMgmtForm(w http.ResponseWriter, r *http app.serverError(w, r, err) return } - views.AdminPanelUserMgmtDetail(updatedUser).Render(r.Context(), w) + commonData := app.newCommonData(r) + views.AdminPanelUserMgmtDetail(commonData.CSRFToken, updatedUser).Render(r.Context(), w) } @@ -128,6 +131,30 @@ func (app *application) putAdminPanelBanUser(w http.ResponseWriter, r *http.Requ app.serverError(w, r, err) return } + u.Banned = time.Now() + commonData := app.newCommonData(r) + views.AdminPanelUserMgmtDetail(commonData.CSRFToken, u).Render(r.Context(), w) +} + +func (app *application) putAdminPanelUnbanUser(w http.ResponseWriter, r *http.Request) { + slug := r.PathValue("id") + u, err := app.users.Get(slugToShortId(slug)) + if err != nil { + if errors.Is(err, models.ErrNoRecord) { + http.NotFound(w, r) + } else { + app.serverError(w, r, err) + } + return + } + err = app.users.UnbanUser(u.ID) + if err != nil { + app.serverError(w, r, err) + return + } + u.Banned = time.Time{} + commonData := app.newCommonData(r) + views.AdminPanelUserMgmtDetail(commonData.CSRFToken, u).Render(r.Context(), w) } func (app *application) getAdminPanelWebsites(w http.ResponseWriter, r *http.Request) { diff --git a/cmd/web/routes.go b/cmd/web/routes.go index d0d61bb..1f843cf 100644 --- a/cmd/web/routes.go +++ b/cmd/web/routes.go @@ -65,6 +65,8 @@ func (app *application) routes() http.Handler { mux.Handle("GET /admin/users/{id}/edit", adminOnly.ThenFunc(app.getAdminPanelUserMgmtForm)) mux.Handle("GET /admin/users/{id}/detail", adminOnly.ThenFunc(app.getAdminPanelUserMgmtDetail)) mux.Handle("PUT /admin/users/{id}/edit", adminOnly.ThenFunc(app.putAdminPanelUserMgmtForm)) + mux.Handle("PUT /admin/users/{id}/ban", adminOnly.ThenFunc(app.putAdminPanelBanUser)) + mux.Handle("PUT /admin/users/{id}/unban", adminOnly.ThenFunc(app.putAdminPanelUnbanUser)) return standard.Then(mux) } diff --git a/internal/forms/forms.go b/internal/forms/forms.go index 25ba116..85fddad 100644 --- a/internal/forms/forms.go +++ b/internal/forms/forms.go @@ -28,7 +28,7 @@ type CommentCreateForm struct { } type WebsiteCreateForm struct { - Name string `schema:"ws_name""` + Name string `schema:"ws_name"` SiteUrl string `schema:"ws_url"` AuthorName string `schema:"ws_author"` validator.Validator `schema:"-"` diff --git a/internal/models/user.go b/internal/models/user.go index 7719a17..1e70241 100644 --- a/internal/models/user.go +++ b/internal/models/user.go @@ -68,6 +68,7 @@ type UserModelInterface interface { GetNumberOfUsers() int AddUserToGroup(userId int64, groupId UserGroupId) error BanUser(userId int64) error + UnbanUser(userId int64) error UpdateUser(u User) error UpdatePassword(userId int64, password string) error Delete(userId int64) error @@ -487,6 +488,15 @@ func (m *UserModel) BanUser(userId int64) error { return nil } +func (m *UserModel) UnbanUser(userId int64) error { + stmt := `UPDATE users SET Banned=NULL WHERE Id=?` + _, err := m.DB.Exec(stmt, userId) + if err != nil { + return err + } + return nil +} + func (m *UserModel) UpdateUser(u User) error { stmt := `UPDATE users SET Email=?, Username=? WHERE Id=?` _, err := m.DB.Exec(stmt, u.Email, u.Username, u.ID) diff --git a/ui/views/admin.templ b/ui/views/admin.templ index 3e04beb..f8ab1c3 100644 --- a/ui/views/admin.templ +++ b/ui/views/admin.templ @@ -2,9 +2,10 @@ package views import ( "fmt" - "git.32bit.cafe/32bitcafe/guestbook/internal/models" - "time" "git.32bit.cafe/32bitcafe/guestbook/internal/forms" + "git.32bit.cafe/32bitcafe/guestbook/internal/models" + "slices" + "time" ) templ adminBase(title string, data CommonData) { @@ -38,6 +39,7 @@ templ adminSidebar() {

Administration

@@ -68,14 +70,14 @@ templ AdminPanelUsersView(title string, data CommonData, users []models.User) { Username Joined Email - for _, u := range users { - + for _, u := range users { + {{ url := fmt.Sprintf("/admin/users/%s", shortIdToSlug(u.ShortId)) }} { u.Username } { u.Created.Format(time.RFC3339) } { u.Email } - - } + + }
@@ -83,84 +85,98 @@ templ AdminPanelUsersView(title string, data CommonData, users []models.User) { } } -templ AdminPanelUserMgmtDetail(user models.User) { -
-
-

User Info

-
-
Username
-

{ user.Username }

-
-
-
Email
-

{ user.Email }

-
-
-
Joined
-

{ user.Created.Format(time.RFC3339) }

-
-
-
-

Groups

-
    - for _, g := range user.Groups { -
  • { fmt.Sprintf("%s", getGroupName(g)) }
  • - } -
-
-
-

Actions

- {{ getFormUrl := fmt.Sprintf("/admin/users/%s/edit", shortIdToSlug(user.ShortId)) }} - - - -
-
+templ AdminPanelUserMgmtDetail(csrfToken string, user models.User) { +
+
+ +
+

User Info

+
+
Username
+

{ user.Username }

+
+
+
Email
+

{ user.Email }

+
+
+
Joined
+

{ user.Created.Format(time.RFC3339) }

+
+
+
+

Groups

+
    + for _, g := range user.Groups { +
  • { fmt.Sprintf("%s", getGroupName(g)) }
  • + } +
+
+
+

Actions

+ {{ getFormUrl := fmt.Sprintf("/admin/users/%s/edit", shortIdToSlug(user.ShortId)) }} + {{ putBanUrl := fmt.Sprintf("/admin/users/%s/ban", shortIdToSlug(user.ShortId)) }} + {{ putUnbanUrl := fmt.Sprintf("/admin/users/%s/unban", shortIdToSlug(user.ShortId)) }} + {{ deleteUrl := fmt.Sprintf("/admin/users/%s", shortIdToSlug(user.ShortId)) }} + + if user.ID != 1 { + if user.Banned.IsZero() { + + } else { + + } + + } +
+
+
} templ AdminPanelUserMgmtView(title string, data CommonData, user models.User) { @adminBase(title, data) {
@adminSidebar() - @AdminPanelUserMgmtDetail(user) + @AdminPanelUserMgmtDetail(data.CSRFToken, user)
} } templ AdminPanelUserMgmtEditForm(csrfToken string, form forms.AdminUserMgmtForm, user models.User, groups []models.UserGroupId) { -
-
- -
-

User Info

-
-
Username
- -
-
-
Email
- -
-
-
Joined
-

{ user.Created.Format(time.RFC3339) }

-
-
-
-

Groups

-
    - for _, g := range groups { -
  • { fmt.Sprintf("%s", getGroupName(g)) }
  • - } -
-
-
-

Actions

- {{ putFormUrl := fmt.Sprintf("/admin/users/%s/edit", shortIdToSlug(user.ShortId)) }} - {{ getDetailUrl := fmt.Sprintf("/admin/users/%s/detail", shortIdToSlug(user.ShortId)) }} - - -
-
-
+
+
+ +
+

User Info

+
+
Username
+ +
+
+
Email
+ +
+
+
Joined
+

{ user.Created.Format(time.RFC3339) }

+
+
+
+
+

Groups

+ {{ isAdmin := slices.Contains(user.Groups, models.AdminGroup) }} + + + + +
+
+
+

Actions

+ {{ putFormUrl := fmt.Sprintf("/admin/users/%s/edit", shortIdToSlug(user.ShortId)) }} + {{ getDetailUrl := fmt.Sprintf("/admin/users/%s/detail", shortIdToSlug(user.ShortId)) }} + + +
+
+
} diff --git a/ui/views/admin_templ.go b/ui/views/admin_templ.go index 47762e1..d2884b2 100644 --- a/ui/views/admin_templ.go +++ b/ui/views/admin_templ.go @@ -12,6 +12,7 @@ import ( "fmt" "git.32bit.cafe/32bitcafe/guestbook/internal/forms" "git.32bit.cafe/32bitcafe/guestbook/internal/models" + "slices" "time" ) @@ -43,7 +44,7 @@ func adminBase(title string, data CommonData) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 14, Col: 17} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 15, Col: 17} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -56,7 +57,7 @@ func adminBase(title string, data CommonData) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(`{"includeIndicatorStyles":false}`) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 17, Col: 72} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 18, Col: 72} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -107,7 +108,7 @@ func adminSidebar() templ.Component { templ_7745c5c3_Var4 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -163,7 +164,7 @@ func AdminPanelLandingView(title string, data CommonData) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 54, Col: 15} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 56, Col: 15} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -250,7 +251,7 @@ func AdminPanelUsersView(title string, data CommonData, users []models.User) tem var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(u.Username) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 74, Col: 51} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 76, Col: 51} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -263,7 +264,7 @@ func AdminPanelUsersView(title string, data CommonData, users []models.User) tem var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(u.Created.Format(time.RFC3339)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 75, Col: 44} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 77, Col: 44} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -276,7 +277,7 @@ func AdminPanelUsersView(title string, data CommonData, users []models.User) tem var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(u.Email) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 76, Col: 21} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 78, Col: 21} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -301,7 +302,7 @@ func AdminPanelUsersView(title string, data CommonData, users []models.User) tem }) } -func AdminPanelUserMgmtDetail(user models.User) templ.Component { +func AdminPanelUserMgmtDetail(csrfToken string, user models.User) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -322,87 +323,163 @@ func AdminPanelUserMgmtDetail(user models.User) templ.Component { templ_7745c5c3_Var14 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "

User Info

Username

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "

Email

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "\">

User Info

Username

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var16 string - templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(user.Email) + templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(user.Username) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 96, Col: 31} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 96, Col: 23} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "

Joined

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "

Email

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var17 string - templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(user.Created.Format(time.RFC3339)) + templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(user.Email) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 100, Col: 54} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 100, Col: 20} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "

Groups

    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "

Joined

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var18 string + templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(user.Created.Format(time.RFC3339)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 104, Col: 43} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "

Groups

    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, g := range user.Groups { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "
  • ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "
  • ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var18 string - templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s", getGroupName(g))) + var templ_7745c5c3_Var19 string + templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s", getGroupName(g))) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 107, Col: 60} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 111, Col: 46} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "
  • ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "

Actions

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "

Actions

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } getFormUrl := fmt.Sprintf("/admin/users/%s/edit", shortIdToSlug(user.ShortId)) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "\" hx-target=\"#user-info\">Edit ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if user.ID != 1 { + if user.Banned.IsZero() { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -426,12 +503,12 @@ func AdminPanelUserMgmtView(title string, data CommonData, user models.User) tem }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var20 := templ.GetChildren(ctx) - if templ_7745c5c3_Var20 == nil { - templ_7745c5c3_Var20 = templ.NopComponent + templ_7745c5c3_Var24 := templ.GetChildren(ctx) + if templ_7745c5c3_Var24 == nil { + templ_7745c5c3_Var24 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var21 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var25 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -443,7 +520,7 @@ func AdminPanelUserMgmtView(title string, data CommonData, user models.User) tem }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -451,17 +528,17 @@ func AdminPanelUserMgmtView(title string, data CommonData, user models.User) tem if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = AdminPanelUserMgmtDetail(user).Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = AdminPanelUserMgmtDetail(data.CSRFToken, user).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = adminBase(title, data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var21), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = adminBase(title, data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var25), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -485,119 +562,117 @@ func AdminPanelUserMgmtEditForm(csrfToken string, form forms.AdminUserMgmtForm, }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var22 := templ.GetChildren(ctx) - if templ_7745c5c3_Var22 == nil { - templ_7745c5c3_Var22 = templ.NopComponent + templ_7745c5c3_Var26 := templ.GetChildren(ctx) + if templ_7745c5c3_Var26 == nil { + templ_7745c5c3_Var26 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "

User Info

Username
Email
Joined

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var26 string - templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(user.Created.Format(time.RFC3339)) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 146, Col: 54} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "

Groups

    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - for _, g := range groups { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "
  • ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var27 string - templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s", getGroupName(g))) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 153, Col: 60} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "
  • ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "

Actions

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - putFormUrl := fmt.Sprintf("/admin/users/%s/edit", shortIdToSlug(user.ShortId)) - getDetailUrl := fmt.Sprintf("/admin/users/%s/detail", shortIdToSlug(user.ShortId)) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "
Email
Cancel
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "\" required>
Joined

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var30 string + templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(user.Created.Format(time.RFC3339)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 160, Col: 43} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "

Groups

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + isAdmin := slices.Contains(user.Groups, models.AdminGroup) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "

Actions

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + putFormUrl := fmt.Sprintf("/admin/users/%s/edit", shortIdToSlug(user.ShortId)) + getDetailUrl := fmt.Sprintf("/admin/users/%s/detail", shortIdToSlug(user.ShortId)) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }