Marking a resercation as processed
This commit is contained in:
		@ -16,6 +16,8 @@ import (
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/go-chi/chi/v5"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Repo the repository used by the handlers
 | 
			
		||||
@ -616,3 +618,15 @@ func (m *Repository) AdminPostShowReservation(w http.ResponseWriter, r *http.Req
 | 
			
		||||
func (m *Repository) AdminReservationsCalendar(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	render.Template(w, r, "admin-reservations-calendar.page.tmpl", &models.TemplateData{})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AdminProcessReservation marks a reservation as processed
 | 
			
		||||
func (m *Repository) AdminProcessReservation(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	id, _ := strconv.Atoi(chi.URLParam(r, "id"))
 | 
			
		||||
	src := chi.URLParam(r, "src")
 | 
			
		||||
 | 
			
		||||
	_ = m.DB.UpdateProcessedForReservation(id, 1)
 | 
			
		||||
 | 
			
		||||
	m.App.Session.Put(r.Context(), "flash", "Reservation marked as processed")
 | 
			
		||||
 | 
			
		||||
	http.Redirect(w, r, fmt.Sprintf("/admin/reservations-%s", src), http.StatusSeeOther)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user