-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from AkshatGupta15/main
Intialised mailing system for every action on pvfs
- Loading branch information
Showing
5 changed files
with
108 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,8 +88,8 @@ func sendVerificationLinkForPvfHandler(mail_channel chan mail.Mail) gin.HandlerF | |
"https://placement.iitk.ac.in/verify?token=" + token + "&rcid=" + util.ParseString(rid) + "\n\n" + | ||
"Your prompt response is appreciated to ensure timely processing of " + pvf.Name + "'s placement applications.\n\n" + | ||
"Please note:\n" + | ||
"The PVF verifies the student's involvement and contributions to the project/internship. " + | ||
"Only projects/internships conducted with IIT Kanpur faculty or external organizations require verification. " + | ||
"The PVF verifies the student's involvement and contributions to the project/internship. \n" + | ||
"Only projects/internships conducted with IIT Kanpur faculty or external organizations require verification. \n" + | ||
"If you have any questions regarding the PVF process, please don't hesitate to contact the Students' Placement Office at [email protected].\n\n" + | ||
"Thank you for your time and support." | ||
|
||
|
@@ -183,39 +183,54 @@ func deletePVFHandler(ctx *gin.Context) { | |
ctx.JSON(http.StatusOK, gin.H{"status": "deleted PVF"}) | ||
} | ||
|
||
func putPVFHandlerForAdmin(ctx *gin.Context) { | ||
var jp PVF | ||
func putPVFHandlerForAdmin(mail_channel chan mail.Mail) gin.HandlerFunc { | ||
return func(ctx *gin.Context) { | ||
var pvf PVF | ||
|
||
rid, err := util.ParseUint(ctx.Param("rid")) | ||
if err != nil { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
} | ||
// rid, err := util.ParseUint(ctx.Param("rid")) | ||
// if err != nil { | ||
// ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
// return | ||
// } | ||
|
||
err = ctx.ShouldBindJSON(&jp) | ||
if err != nil { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
} | ||
err := ctx.ShouldBindJSON(&pvf) | ||
if err != nil { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
} | ||
|
||
if jp.ID == 0 { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "id is required"}) | ||
return | ||
} | ||
if pvf.ID == 0 { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "id is required"}) | ||
return | ||
} | ||
|
||
var oldJp PVF | ||
err = fetchPvfForAdmin(ctx, rid, jp.ID, &oldJp) | ||
if err != nil { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
} | ||
var oldPvf PVF | ||
|
||
err = updatePVF(ctx, &jp) | ||
if err != nil { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
// err = fetchPvfForAdmin(ctx, rid, oldPvf.ID, &oldPvf) | ||
err = fetchPVF(ctx, pvf.ID, &oldPvf) | ||
if err != nil { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
} | ||
|
||
err = updatePVF(ctx, &pvf) | ||
if err != nil { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
} | ||
message := "Dear " + oldPvf.Name + ",\n\n" + | ||
|
||
"Action has been taken on your Project Verification Form. Kindly check the status on the RAS Portal." + | ||
"\n\n" + | ||
"Regards,\n" + | ||
"Students' Placement Team, IIT kanpur" | ||
// logrus.Infof("EmaIL : %s OR %s", pvf.IITKEmail, oldPvf.IITKEmail) | ||
mail_channel <- mail.GenerateMail(oldPvf.IITKEmail, | ||
"Project Verification Update for "+oldPvf.Name+"'s Internship/Project", | ||
message, | ||
) | ||
ctx.JSON(http.StatusOK, gin.H{"status": "Updated PVF with id " + util.ParseString(pvf.ID)}) | ||
} | ||
ctx.JSON(http.StatusOK, gin.H{"status": "Updated PVF with id " + util.ParseString(jp.ID)}) | ||
} | ||
|
||
func getAllStudentPvfHandler(ctx *gin.Context) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import ( | |
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/spo-iitk/ras-backend/mail" | ||
"github.com/spo-iitk/ras-backend/middleware" | ||
"github.com/spo-iitk/ras-backend/util" | ||
) | ||
|
@@ -33,38 +34,68 @@ func getPvfForVerificationHandler(ctx *gin.Context) { | |
ctx.JSON(http.StatusOK, jps) | ||
} | ||
|
||
func putPVFHandler(ctx *gin.Context) { | ||
var jp PVF | ||
func putPVFHandler(mail_channel chan mail.Mail) gin.HandlerFunc { | ||
return func(ctx *gin.Context) { | ||
var pvf PVF | ||
|
||
err := ctx.ShouldBindJSON(&jp) | ||
if err != nil { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
} | ||
pid := middleware.GetPVFID(ctx) | ||
err := ctx.ShouldBindJSON(&pvf) | ||
if err != nil { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
} | ||
pid := middleware.GetPVFID(ctx) | ||
|
||
jp.ID = pid | ||
pvf.ID = pid | ||
|
||
if jp.ID == 0 { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "id is required"}) | ||
return | ||
} | ||
if pvf.ID == 0 { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "id is required"}) | ||
return | ||
} | ||
|
||
var oldJp PVF | ||
err = fetchPVF(ctx, jp.ID, &oldJp) | ||
if err != nil { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
} | ||
var oldJp PVF | ||
err = fetchPVF(ctx, pvf.ID, &oldJp) | ||
if err != nil { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
} | ||
|
||
// jp.ActionTakenBy = middleware.GetUserID(ctx) | ||
// jp.ActionTakenBy = middleware.GetUserID(ctx) | ||
|
||
// publishNotice := oldJp.Deadline == 0 && jp.Deadline != 0 | ||
// publishNotice := oldJp.Deadline == 0 && jp.Deadline != 0 | ||
|
||
err = updatePVF(ctx, &pvf) | ||
if err != nil { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
} | ||
var action string | ||
if pvf.IsVerified.Bool { | ||
action = "APPROVED" | ||
} else { | ||
action = "DENIED" | ||
} | ||
messageMentor := "Dear " + oldJp.MentorName + ",\n\n" + | ||
"The action " + action + " on the Project Verification Form of the " + oldJp.Name + " has been taken.\n\n" + | ||
"If you have not done this action please reach out to [email protected]\n\n" + | ||
"Regards,\n" + | ||
"Students' Placement Team, IIT kanpur" | ||
|
||
mail_channel <- mail.GenerateMail(oldJp.MentorEmail, | ||
"Project Verification Update for "+oldJp.Name+"'s Internship/Project", | ||
messageMentor, | ||
) | ||
messageStudent := "Dear " + oldJp.Name + ",\n\n" + | ||
|
||
"Action has been taken on your Project Verification Form. Kindly check the status on the RAS Portal." + | ||
"\n\n" + | ||
"Regards,\n" + | ||
"Students' Placement Team, IIT kanpur" | ||
|
||
mail_channel <- mail.GenerateMail(oldJp.IITKEmail, | ||
"Project Verification Update for "+oldJp.Name+"'s Internship/Project", | ||
messageStudent, | ||
) | ||
ctx.JSON(http.StatusOK, gin.H{"status": "Updated PVF with id " + util.ParseString(pvf.ID)}) | ||
|
||
err = updatePVF(ctx, &jp) | ||
if err != nil { | ||
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
return | ||
} | ||
ctx.JSON(http.StatusOK, gin.H{"status": "Updated PVF with id " + util.ParseString(jp.ID)}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters