Established Participants and Tickets model. Migrated concepts.
This commit is contained in:
parent
0df93e1886
commit
cd8e1e3b3b
22 changed files with 1345 additions and 191 deletions
|
|
@ -7,17 +7,20 @@ import (
|
|||
)
|
||||
|
||||
// handleKioskGet returns the volunteer's profile, current shift assignments, and
|
||||
// available open shifts in their department. Authenticated by volunteer token only —
|
||||
// available open shifts in their department. Authenticated by ticket code only —
|
||||
// no JWT required.
|
||||
func (app *App) handleKioskGet(w http.ResponseWriter, r *http.Request) {
|
||||
token := r.PathValue("token")
|
||||
a, err := app.getAttendeeByToken(token)
|
||||
if err != nil || a == nil {
|
||||
t, err := app.getTicketByCode(token)
|
||||
if err != nil || t == nil {
|
||||
writeError(w, "not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
v, _ := app.getVolunteerByAttendeeID(a.ID)
|
||||
var v *Volunteer
|
||||
if t.ParticipantID != nil {
|
||||
v, _ = app.getVolunteerByParticipantID(*t.ParticipantID)
|
||||
}
|
||||
if v == nil {
|
||||
writeError(w, "no volunteer record linked to this token", http.StatusNotFound)
|
||||
return
|
||||
|
|
@ -53,12 +56,15 @@ func (app *App) handleKioskClaim(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
a, err := app.getAttendeeByToken(token)
|
||||
if err != nil || a == nil {
|
||||
t, err := app.getTicketByCode(token)
|
||||
if err != nil || t == nil {
|
||||
writeError(w, "not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
v, _ := app.getVolunteerByAttendeeID(a.ID)
|
||||
var v *Volunteer
|
||||
if t.ParticipantID != nil {
|
||||
v, _ = app.getVolunteerByParticipantID(*t.ParticipantID)
|
||||
}
|
||||
if v == nil {
|
||||
writeError(w, "no volunteer linked to this token", http.StatusNotFound)
|
||||
return
|
||||
|
|
@ -110,12 +116,15 @@ func (app *App) handleKioskUnclaim(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
a, err := app.getAttendeeByToken(token)
|
||||
if err != nil || a == nil {
|
||||
t, err := app.getTicketByCode(token)
|
||||
if err != nil || t == nil {
|
||||
writeError(w, "not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
v, _ := app.getVolunteerByAttendeeID(a.ID)
|
||||
var v *Volunteer
|
||||
if t.ParticipantID != nil {
|
||||
v, _ = app.getVolunteerByParticipantID(*t.ParticipantID)
|
||||
}
|
||||
if v == nil {
|
||||
writeError(w, "no volunteer linked to this token", http.StatusNotFound)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue