|
|
|
@ -17,13 +17,14 @@ import ( |
|
|
|
|
|
|
|
root "marmic/servicetrade-toolbox" |
|
|
|
"marmic/servicetrade-toolbox/internal/api" |
|
|
|
"marmic/servicetrade-toolbox/internal/middleware" |
|
|
|
|
|
|
|
"github.com/gorilla/mux" |
|
|
|
) |
|
|
|
|
|
|
|
// DocumentRemoveHandler handles the document removal page
|
|
|
|
func DocumentRemoveHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
session, ok := r.Context().Value("session").(*api.Session) |
|
|
|
session, ok := r.Context().Value(middleware.SessionKey).(*api.Session) |
|
|
|
if !ok { |
|
|
|
http.Error(w, "Unauthorized", http.StatusUnauthorized) |
|
|
|
return |
|
|
|
@ -73,7 +74,7 @@ func DocumentRemoveHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
// ProcessRemoveCSVHandler processes a CSV file containing job IDs for document removal
|
|
|
|
func ProcessRemoveCSVHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
// We don't use the session in the body but check it for auth
|
|
|
|
_, ok := r.Context().Value("session").(*api.Session) |
|
|
|
_, ok := r.Context().Value(middleware.SessionKey).(*api.Session) |
|
|
|
if !ok { |
|
|
|
http.Error(w, "Unauthorized", http.StatusUnauthorized) |
|
|
|
return |
|
|
|
@ -165,7 +166,7 @@ func ProcessRemoveCSVHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
// This handler is for Step 2
|
|
|
|
func JobSelectionHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
// We don't use the session directly but check it for auth
|
|
|
|
_, ok := r.Context().Value("session").(*api.Session) |
|
|
|
_, ok := r.Context().Value(middleware.SessionKey).(*api.Session) |
|
|
|
if !ok { |
|
|
|
http.Error(w, "Unauthorized", http.StatusUnauthorized) |
|
|
|
return |
|
|
|
@ -210,7 +211,7 @@ func JobSelectionHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
// GetJobAttachmentsHandler retrieves attachments for a specific job
|
|
|
|
func GetJobAttachmentsHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
session, ok := r.Context().Value("session").(*api.Session) |
|
|
|
session, ok := r.Context().Value(middleware.SessionKey).(*api.Session) |
|
|
|
if !ok { |
|
|
|
vars := mux.Vars(r) |
|
|
|
jobID := vars["jobID"] |
|
|
|
@ -248,7 +249,7 @@ func GetJobAttachmentsHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
// RemoveJobAttachmentsHandler handles the removal of attachments from a job
|
|
|
|
func RemoveJobAttachmentsHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
session, ok := r.Context().Value("session").(*api.Session) |
|
|
|
session, ok := r.Context().Value(middleware.SessionKey).(*api.Session) |
|
|
|
if !ok { |
|
|
|
vars := mux.Vars(r) |
|
|
|
jobID := vars["jobID"] |
|
|
|
@ -379,7 +380,7 @@ func RemoveJobAttachmentsHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
// JobListHandler renders the job list for document removal
|
|
|
|
func JobListHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
session, ok := r.Context().Value("session").(*api.Session) |
|
|
|
session, ok := r.Context().Value(middleware.SessionKey).(*api.Session) |
|
|
|
if !ok { |
|
|
|
renderErrorTemplate(w, "job_list", "You must be logged in to use this feature") |
|
|
|
return |
|
|
|
@ -439,7 +440,7 @@ func BulkRemoveDocumentsHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
session, ok := r.Context().Value("session").(*api.Session) |
|
|
|
session, ok := r.Context().Value(middleware.SessionKey).(*api.Session) |
|
|
|
if !ok { |
|
|
|
http.Error(w, "Unauthorized", http.StatusUnauthorized) |
|
|
|
return |
|
|
|
|