Switched to path routing. Added data management.
This commit is contained in:
parent
8dc5d3ed01
commit
4bba0ed3a0
14 changed files with 256 additions and 46 deletions
|
|
@ -79,6 +79,61 @@ func (app *App) handleUpdateSettings(w http.ResponseWriter, r *http.Request) {
|
|||
app.handleGetSettings(w, r)
|
||||
}
|
||||
|
||||
func (app *App) handleResetAttendees(w http.ResponseWriter, r *http.Request) {
|
||||
result, err := app.db.Exec(`DELETE FROM attendees`)
|
||||
if err != nil {
|
||||
writeError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
n, _ := result.RowsAffected()
|
||||
|
||||
writeJSON(w, map[string]any{"deleted": n})
|
||||
}
|
||||
|
||||
func (app *App) handleResetVolunteers(w http.ResponseWriter, r *http.Request) {
|
||||
result, err := app.db.Exec(`DELETE FROM volunteers`)
|
||||
if err != nil {
|
||||
writeError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
n, _ := result.RowsAffected()
|
||||
|
||||
writeJSON(w, map[string]any{"deleted": n})
|
||||
}
|
||||
|
||||
func (app *App) handleResetShifts(w http.ResponseWriter, r *http.Request) {
|
||||
result, err := app.db.Exec(`DELETE FROM shifts`)
|
||||
if err != nil {
|
||||
writeError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
n, _ := result.RowsAffected()
|
||||
|
||||
writeJSON(w, map[string]any{"deleted": n})
|
||||
}
|
||||
|
||||
func (app *App) handleResetDepartments(w http.ResponseWriter, r *http.Request) {
|
||||
result, err := app.db.Exec(`DELETE FROM departments`)
|
||||
if err != nil {
|
||||
writeError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
n, _ := result.RowsAffected()
|
||||
|
||||
writeJSON(w, map[string]any{"deleted": n})
|
||||
}
|
||||
|
||||
func (app *App) handleResetVolunteerShifts(w http.ResponseWriter, r *http.Request) {
|
||||
result, err := app.db.Exec(`DELETE FROM volunteer_shifts`)
|
||||
if err != nil {
|
||||
writeError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
n, _ := result.RowsAffected()
|
||||
|
||||
writeJSON(w, map[string]any{"deleted": n})
|
||||
}
|
||||
|
||||
func (app *App) handleTestEmail(w http.ResponseWriter, r *http.Request) {
|
||||
var body struct {
|
||||
To string `json:"to"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue