Skip to content

Commit

Permalink
fix: controller not updating to false
Browse files Browse the repository at this point in the history
  • Loading branch information
Bikram-ghuku committed Nov 29, 2024
1 parent 2d38fc2 commit ab34ad6
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions controllers/project_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,30 @@ func UpdateProject(w http.ResponseWriter, r *http.Request) {
}
}

updatedProj := &models.Project{
Name: reqFields.Name,
Description: reqFields.Description,
Tags: strings.Join(reqFields.Tags, ","),
RepoLink: reqFields.RepoLink,
CommChannel: reqFields.CommChannel,
ReadmeLink: reqFields.ReadmeLink,
SecondaryMentor: secondaryMentor,
}

if login_details.UserType == OAUTH_TYPE_ORGANISER {
updatedProj.ProjectStatus = reqFields.ProjectStatus
updatedProj.StatusRemark = reqFields.StatusRemark
}

tx = db.
Table("projects").
Where("id = ?", reqFields.Id).
Updates(updatedProj)
updateDet := map[string]interface{}{"status_remark": reqFields.StatusRemark, "project_status": reqFields.ProjectStatus}
tx = db.
Table("projects").
Where("id = ?", reqFields.Id).
Updates(updateDet)

} else {
updatedProj := &models.Project{
Name: reqFields.Name,
Description: reqFields.Description,
Tags: strings.Join(reqFields.Tags, ","),
RepoLink: reqFields.RepoLink,
CommChannel: reqFields.CommChannel,
ReadmeLink: reqFields.ReadmeLink,
SecondaryMentor: secondaryMentor,
}

tx = db.
Table("projects").
Where("id = ?", reqFields.Id).
Updates(updatedProj)
}

if tx.Error != nil {
utils.LogErrAndRespond(r, w, tx.Error, "Error updating the project.", http.StatusInternalServerError)
Expand Down

0 comments on commit ab34ad6

Please sign in to comment.