diff --git a/EduSync.exe b/EduSync.exe
index 88f3197..0620a12 100644
Binary files a/EduSync.exe and b/EduSync.exe differ
diff --git a/adminHandler.go b/adminHandler.go
index 1570608..3137e80 100644
--- a/adminHandler.go
+++ b/adminHandler.go
@@ -166,6 +166,30 @@ func AdminHandler(router *mux.Router) {
}
}).Methods("POST")
+ // Handle student deletion
+ router.HandleFunc("/admin/student/delete/{googleID}", func(res http.ResponseWriter, req *http.Request) {
+ vars := mux.Vars(req)
+ googleID := vars["googleID"]
+
+ if req.Method == http.MethodDelete {
+ student, err := readStudent(googleID, req)
+ if err != nil {
+ http.Error(res, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ if err := deleteStudent(student, req); err != nil {
+ http.Error(res, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ res.WriteHeader(http.StatusNoContent) // Respond with No Content status
+ return
+ }
+
+ http.Error(res, "Method Not Allowed", http.StatusMethodNotAllowed)
+ }).Methods("DELETE")
+
// Serve the search parent page
router.HandleFunc("/admin/search_parent", func(res http.ResponseWriter, req *http.Request) {
t, err := template.ParseFiles("templates/admin/search_parent.html")
@@ -266,6 +290,30 @@ func AdminHandler(router *mux.Router) {
}
}).Methods("POST")
+ // Handle parent deletion
+ router.HandleFunc("/admin/parent/delete/{googleID}", func(res http.ResponseWriter, req *http.Request) {
+ vars := mux.Vars(req)
+ googleID := vars["googleID"]
+
+ if req.Method == http.MethodDelete {
+ parent, err := readParent(googleID, req)
+ if err != nil {
+ http.Error(res, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ if err := deleteParent(parent, req); err != nil {
+ http.Error(res, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ res.WriteHeader(http.StatusNoContent) // Respond with No Content status
+ return
+ }
+
+ http.Error(res, "Method Not Allowed", http.StatusMethodNotAllowed)
+ }).Methods("DELETE")
+
// Serve the search instructor page
router.HandleFunc("/admin/search_instructor", func(res http.ResponseWriter, req *http.Request) {
t, err := template.ParseFiles("templates/admin/search_instructor.html")
@@ -377,6 +425,30 @@ func AdminHandler(router *mux.Router) {
t.Execute(res, nil)
}).Methods("GET")
+ // Handle instructor deletion
+ router.HandleFunc("/admin/instructor/delete/{googleID}", func(res http.ResponseWriter, req *http.Request) {
+ vars := mux.Vars(req)
+ googleID := vars["googleID"]
+
+ if req.Method == http.MethodDelete {
+ instructor, err := readInstructor(googleID, req)
+ if err != nil {
+ http.Error(res, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ if err := deleteInstructor(instructor, req); err != nil {
+ http.Error(res, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ res.WriteHeader(http.StatusNoContent) // Respond with No Content status
+ return
+ }
+
+ http.Error(res, "Method Not Allowed", http.StatusMethodNotAllowed)
+ }).Methods("DELETE")
+
// Serve the create announcement page
router.HandleFunc("/admin/create_announcement", func(res http.ResponseWriter, req *http.Request) {
t, err := template.ParseFiles("templates/admin/create_announcement.html")
@@ -473,6 +545,23 @@ func AdminHandler(router *mux.Router) {
// Request Body: JSON object with announcement details
// Response: HTTP Status Created (201)
+ // Handle announcement deletion
+ router.HandleFunc("/admin/announcement/delete/{announcementID}", func(res http.ResponseWriter, req *http.Request) {
+ vars := mux.Vars(req)
+ announcementID := vars["announcementID"]
+
+ switch req.Method {
+ case http.MethodDelete:
+ if err := deleteAnnouncement(announcementID, req); err != nil {
+ http.Error(res, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ res.WriteHeader(http.StatusNoContent)
+ default:
+ http.Error(res, "Method Not Allowed", http.StatusMethodNotAllowed)
+ }
+ }).Methods("DELETE")
+
// Serve the search class page
router.HandleFunc("/admin/search_class", func(res http.ResponseWriter, req *http.Request) {
t, err := template.ParseFiles("templates/admin/search_class.html")
@@ -589,6 +678,27 @@ func AdminHandler(router *mux.Router) {
}
}).Methods("POST")
+ // Handle class deletion
+ router.HandleFunc("/admin/class/delete/{classID}", func(res http.ResponseWriter, req *http.Request) {
+ vars := mux.Vars(req)
+ classID := vars["classID"]
+
+ switch req.Method {
+ case http.MethodDelete:
+ // Create a Class struct with the classID
+ class := Class{ClassID: classID}
+
+ // Call deleteClass function to delete the class
+ if err := deleteClass(class, req); err != nil {
+ http.Error(res, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ res.WriteHeader(http.StatusNoContent)
+ default:
+ http.Error(res, "Method Not Allowed", http.StatusMethodNotAllowed)
+ }
+ }).Methods("DELETE")
+
router.HandleFunc("/admin/api/profile", func(res http.ResponseWriter, req *http.Request) {
currentUser, err := GetCurrentUser(req)
if err != nil {
diff --git a/database.go b/database.go
index 9ce2862..3c8fc1c 100644
--- a/database.go
+++ b/database.go
@@ -6,7 +6,6 @@ import (
"fmt"
"log"
"net/http"
-
"os"
"strings"
@@ -18,10 +17,10 @@ import (
var firebaseClient *db.Client
func SessionCookie() (string, error) {
- // sessionCookieStore := goDotEnvVariable("SESSION_COOKIE_STORE")
- // if sessionCookieStore == "" {
- // return sessionCookieStore, fmt.Errorf("SESSION_COOKIE_STORE is not set in the environment variables")
- // }
+ // sessionCookieStore := goDotEnvVariable("SESSION_COOKIE_STORE")
+ // if sessionCookieStore == "" {
+ // return sessionCookieStore, fmt.Errorf("SESSION_COOKIE_STORE is not set in the environment variables")
+ // }
sessionCookieStore, found := os.LookupEnv("COOKIESTORE")
if !found {
diff --git a/templates/admin/search_announcement.html b/templates/admin/search_announcement.html
index 05630f7..a31da4d 100644
--- a/templates/admin/search_announcement.html
+++ b/templates/admin/search_announcement.html
@@ -9,12 +9,6 @@