From 4931e759e09a70895ee5493f3326cf802fb832d1 Mon Sep 17 00:00:00 2001 From: ayush00git Date: Wed, 24 Jun 2026 19:57:23 +0530 Subject: [PATCH] fix: deprecate stage field from posts --- handlers/admin_status.go | 6 +++--- models/post.go | 10 ---------- routes/admin.go | 8 ++++---- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/handlers/admin_status.go b/handlers/admin_status.go index f853003..b33abd2 100644 --- a/handlers/admin_status.go +++ b/handlers/admin_status.go @@ -37,7 +37,7 @@ const ( ResolvedAll PostStatus = "resolved_all" // defaults to closed post ) -// AdminFacultyPostStatus sets the stage of the faculty posts +// AdminFacultyPostStatus sets the status of the faculty posts // Sends email to the corresponding post using goroutines func (h *AdminHandler) AdminFacultyPostStatus(c *gin.Context) { adminEmail, exists := c.Get(middleware.EmailKey) @@ -343,7 +343,7 @@ func (h *AdminHandler) AdminFacultyPostStatus(c *gin.Context) { } -// AdminWardenPostStatus sets the stage of the warden posts +// AdminWardenPostStatus sets the status of the warden posts // Sends email to the corresponding post using goroutines func (h *AdminHandler) AdminWardenPostStatus(c *gin.Context) { adminEmail, exists := c.Get(middleware.EmailKey) @@ -649,7 +649,7 @@ func (h *AdminHandler) AdminWardenPostStatus(c *gin.Context) { } -// AdminCentreheadPostStatus sets the stage of the centrehead posts +// AdminCentreheadPostStatus sets the status of the centrehead posts // Sends email to the corresponding post using goroutines func (h *AdminHandler) AdminCentreheadPostStatus(c *gin.Context) { adminEmail, exists := c.Get(middleware.EmailKey) diff --git a/models/post.go b/models/post.go index 102d38e..2461027 100644 --- a/models/post.go +++ b/models/post.go @@ -33,13 +33,6 @@ const ( StatusResolved PostStatus = "resolved_all" // defaults to closed post ) -type PostStage string -const ( - StageXEN PostStage = "XEN" - StageAE PostStage = "AE" - StageJE PostStage = "JE" -) - type FacultyPost struct { ID uint `gorm:"primaryKey;autoIncrement" json:"id"` FacultyID uint `gorm:"not null" json:"faculty_id"` @@ -49,7 +42,6 @@ type FacultyPost struct { Title string `gorm:"type:varchar(50);not null" json:"title" binding:"required"` Description string `gorm:"type:text;not null" json:"description" binding:"required"` Status string `gorm:"type:varchar(20);not null;default:'pending_xen'" json:"status"` - Stage PostStage `gorm:"type:varchar(20);not null;default:'XEN'" json:"stage"` AssignedJE_ID *uint `json:"assigned_je_id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` @@ -66,7 +58,6 @@ type WardenPost struct { Title string `gorm:"not null" json:"title" binding:"required"` Description string `gorm:"type:text;not null" json:"description" binding:"required"` Status string `gorm:"type:varchar(20);not null;default:'pending_xen'" json:"status"` - Stage PostStage `gorm:"type:varchar(20);not null;default:'XEN'" json:"stage"` AssignedJE_ID *uint `json:"assigned_je_id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` @@ -82,7 +73,6 @@ type CentreheadPost struct { Title string `gorm:"not null" json:"title" binding:"required"` Description string `gorm:"type:text;not null" json:"description" binding:"required"` Status string `gorm:"type:varchar(20);not null;default:'pending_xen'" json:"status"` - Stage PostStage `gorm:"type:varchar(20);not null;default:'XEN'" json:"stage"` AssignedJE_ID *uint `json:"assigned_je_id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` diff --git a/routes/admin.go b/routes/admin.go index 257e890..7cdaef1 100644 --- a/routes/admin.go +++ b/routes/admin.go @@ -16,11 +16,11 @@ func AdminRoutes (e *gin.Engine, h *handlers.AdminHandler) { e.DELETE("/api/admin/comment/:type/:id/:comment_id", middleware.IsAuthenticated(), h.AdminDeleteComment) // keep separate apis for updating status - stage := e.Group("/api/admin") + status := e.Group("/api/admin") { - stage.PATCH("/faculty_posts/status/:post_id", middleware.IsAuthenticated(), h.AdminFacultyPostStatus) - stage.PATCH("/warden_posts/status/:post_id", middleware.IsAuthenticated(), h.AdminWardenPostStatus) - stage.PATCH("/centrehead_posts/status/:post_id", middleware.IsAuthenticated(), h.AdminCentreheadPostStatus) + status.PATCH("/faculty_posts/status/:post_id", middleware.IsAuthenticated(), h.AdminFacultyPostStatus) + status.PATCH("/warden_posts/status/:post_id", middleware.IsAuthenticated(), h.AdminWardenPostStatus) + status.PATCH("/centrehead_posts/status/:post_id", middleware.IsAuthenticated(), h.AdminCentreheadPostStatus) } // get the posts according to the status