diff --git a/templates/default/staff.tmpl b/templates/default/staff.tmpl index ca192213..496de53e 100644 --- a/templates/default/staff.tmpl +++ b/templates/default/staff.tmpl @@ -9,14 +9,13 @@ {{end}} {{define "staff-rows"}} -{{$ctx := .}} - {{range $role := $ctx.Roles}} + {{range $role := .Roles}}
{{template "staff-row-title" $role}}
- {{range $user := $ctx.Users}} - {{if and (eq $user.Visible 1) (eq $user.Role $role)}} - {{template "djcard" $user}} + {{range $user := $.Users}} + {{if and $user.DJ.Visible (eq $user.DJ.Role $role)}} + {{template "djcard" $user.DJ}} {{end}} {{end}}
@@ -39,11 +38,11 @@
- +
-
{{.DjName}}
+
{{.Name}}
diff --git a/website/public/staff.go b/website/public/staff.go index 766aa5f7..52130d8a 100644 --- a/website/public/staff.go +++ b/website/public/staff.go @@ -2,16 +2,30 @@ package public import ( "net/http" + + radio "github.com/R-a-dio/valkyrie" ) type StaffInput struct { SharedInput + + Users []radio.User } -func NewStaffInput(r *http.Request) StaffInput { - return StaffInput{ - SharedInput: NewSharedInput(r), +func (si StaffInput) Roles() []string { + return []string{"staff", "dev", "djs"} +} + +func NewStaffInput(us radio.UserStorageService, r *http.Request) (*StaffInput, error) { + users, err := us.User(r.Context()).All() + if err != nil { + return nil, err } + + return &StaffInput{ + SharedInput: NewSharedInput(r), + Users: users, + }, nil } func (StaffInput) TemplateBundle() string { @@ -19,9 +33,13 @@ func (StaffInput) TemplateBundle() string { } func (s State) GetStaff(w http.ResponseWriter, r *http.Request) { - input := NewStaffInput(r) + input, err := NewStaffInput(s.Storage, r) + if err != nil { + s.errorHandler(w, r, err) + return + } - err := s.Templates.Execute(w, r, input) + err = s.Templates.Execute(w, r, input) if err != nil { s.errorHandler(w, r, err) return