Skip to content

Commit

Permalink
website: fix staff page data input
Browse files Browse the repository at this point in the history
  • Loading branch information
Wessie committed Feb 7, 2024
1 parent 9ea3d6c commit 2737bab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
13 changes: 6 additions & 7 deletions templates/default/staff.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
{{end}}

{{define "staff-rows"}}
{{$ctx := .}}
{{range $role := $ctx.Roles}}
{{range $role := .Roles}}
<div class="column block">
{{template "staff-row-title" $role}}
<div class="columns is-multiline has-background-white-ter px-4 py-3 content-border-top">
{{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}}
</div>
Expand All @@ -39,11 +38,11 @@
<div class="card has-background-white-bis p-4 m-2">
<div class="card-image">
<figure class="image is-square ml-0 mr-0">
<img src="/api/dj-image/{{.DjImage}}"/>
<img src="/api/dj-image/{{.Image}}"/>
</figure>
</div>
<div class="card-content has-text-centered pt-4 pb-0">
<div class="title is-4 word-break-ellipsis">{{.DjName}}</div>
<div class="title is-4 word-break-ellipsis">{{.Name}}</div>
</div>
</div>
</div>
Expand Down
28 changes: 23 additions & 5 deletions website/public/staff.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,44 @@ 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 {
return "staff"
}

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
Expand Down

0 comments on commit 2737bab

Please sign in to comment.