Skip to content

Commit

Permalink
fixed 0 value + unverify button
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishnansh5 committed Jul 16, 2023
1 parent 312621e commit 97551af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion student/admin.update.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ func verifyStudentHandler(ctx *gin.Context) {
logrus.Infof("A student with id %d is unverified", verifyStudentRequest.ID)
ctx.JSON(http.StatusOK, gin.H{"status": "Successfully unverified"})
}
}
}
5 changes: 2 additions & 3 deletions student/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,15 @@ func getLimitedStudents(ctx *gin.Context, students *[]Student, lastFetchedId uin
}

func updateStudentByID(ctx *gin.Context, student *Student) (bool, error) {
tx := db.WithContext(ctx).Where("id = ?", student.ID).Updates(student)
tx := db.WithContext(ctx).Where("id = ?", student.ID).Select("*").Omit("id", "created_at", "updated_at", "deleted_at", "iitk_email", "roll_no", "is_verified", "is_editable", "program_department_id", "secondary_program_department_id").Updates(Student{Name: student.Name, Specialization: student.Specialization, Preference: student.Preference, Gender: student.Gender, Disablity: student.Disablity, DOB: student.DOB, ExpectedGraduationYear: student.ExpectedGraduationYear, PersonalEmail: "", Phone: student.Phone, AlternatePhone: student.AlternatePhone, WhatsappNumber: student.WhatsappNumber, CurrentCPI: student.CurrentCPI, UGCPI: student.UGCPI, TenthBoard: student.TenthBoard, TenthYear: student.TenthYear, TenthMarks: student.TenthMarks, TwelfthBoard: student.TwelfthBoard, TwelfthYear: student.TwelfthYear, TwelfthMarks: student.TwelfthMarks, EntranceExam: student.EntranceExam, EntranceExamRank: student.EntranceExamRank, Category: student.Category, CategoryRank: student.CategoryRank, CurrentAddress: student.CurrentAddress, PermanentAddress: student.PermanentAddress, FriendName: student.FriendName, FriendPhone: student.FriendPhone, IsVerified: student.IsVerified, IsEditable: student.IsEditable})
return tx.RowsAffected > 0, tx.Error
}

func verifyStudent(ctx *gin.Context, student *Student) (bool, error) {
tx := db.WithContext(ctx).Model(&student).
Clauses(clause.Returning{}).
Where("id = ?", student.ID).
Update("is_verified", student.IsVerified).
Update("is_editable", !student.IsVerified)
Updates(map[string]interface{}{"is_verified": student.IsVerified, "is_editable": !student.IsVerified})
return tx.RowsAffected > 0, tx.Error
}

Expand Down

0 comments on commit 97551af

Please sign in to comment.