Skip to content

Commit

Permalink
send choices for Gender and Category. Also send Academics Verificatio…
Browse files Browse the repository at this point in the history
…n info
  • Loading branch information
shalearkane committed May 25, 2024
1 parent bb4c993 commit c91aa42
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions constants/datatypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ const (
TYPE_DATE = "date"
TYPE_PRIMITIVE_DATETIME = "primitive.DateTime"
TYPE_SOCIAL = "social"
TYPE_CHOICES = "choices"
)
29 changes: 20 additions & 9 deletions controller/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var PointerToNilString *string = nil
var PointerToNilInteger *int = nil
var PointerToNilFloat64 *float64 = nil
var PointerToNilReservationCategory *studentModel.ReservationCategory = nil
var GenderChoices = []constantModel.Gender{constantModel.MALE, constantModel.FEMALE, constantModel.OTHER_GENDER}
var ReservationCategoryChoices = []string{"GEN", "OBC", "OBC-NCL", "SC", "ST"}

func AssignReservationCategory(category *interfaces.GenericField[string], isEWS *interfaces.GenericField[bool], isPWD *interfaces.GenericField[bool], rc **studentModel.ReservationCategory, forward bool) {
if forward {
Expand All @@ -32,7 +34,8 @@ func AssignReservationCategory(category *interfaces.GenericField[string], isEWS
isPWD.Value = (**rc).IsPWD
}

category.DataType = constants.TYPE_STRING
category.DataType = constants.TYPE_CHOICES
category.DataChoices = &ReservationCategoryChoices
isEWS.DataType = constants.TYPE_BOOL
isPWD.DataType = constants.TYPE_BOOL

Expand Down Expand Up @@ -62,6 +65,8 @@ func AssignSocialProfile(field *interfaces.GenericField[interfaces.TYPE_SOCIAL],
field.Value = (**social).URL + "|" + (**social).Username
}

field.IsVerified = &(*social).Verification.IsVerified

return
}

Expand Down Expand Up @@ -188,12 +193,18 @@ func MapProfilePersonal(profile *interfaces.ProfilePersonal, student *studentMod
AssignNotNilValue(&profile.FatherOccupation, &student.ParentsDetails.FatherOccupation, forward)
AssignNotNilValue(&profile.MotherOccupation, &student.ParentsDetails.MotherOccupation, forward)

// required
profile.FirstName.IsRequired = true
profile.DOB.IsRequired = true
profile.PermanentAddress.IsRequired = true
profile.PersonalEmail.IsRequired = true
profile.Mobile.IsRequired = true
if forward {
// set required field
profile.FirstName.IsRequired = true
profile.DOB.IsRequired = true
profile.PermanentAddress.IsRequired = true
profile.PersonalEmail.IsRequired = true
profile.Mobile.IsRequired = true

// set choices
profile.Gender.DataType = constants.TYPE_CHOICES
profile.Gender.DataChoices = &GenderChoices
}
}

func MapProfileCurrentAcademics(profile *interfaces.ProfileCurrentAcademics, academics *studentModel.Academics, forward bool) {
Expand Down Expand Up @@ -262,8 +273,8 @@ func MapRanks(profile *interfaces.ProfilePastAcademics, rank *studentModel.Acade
}

// 'forward' defines the mapping direction
// if true, then maps model to profile
// if false, then maps profile to model
// if true, then maps model (backend) to profile (frontend)
// if false, then maps profile (frontend) to model (backend)
func MapStudentToStudentProfile(profile *interfaces.StudentProfile, student *studentModel.Student, forward bool) {
// Profile
MapProfilePersonal(&profile.Profile.PersonalProfile, student, forward)
Expand Down
2 changes: 1 addition & 1 deletion handler/student.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (h *Handler) HandlerGetStudentProfile(ctx *gin.Context) {
studentProfile := interfaces.StudentProfile{}
controller.MapStudentToStudentProfile(&studentProfile, &studentPopulated.Student, true)

ctx.JSON(200, gin.H{"profile": studentProfile})
ctx.JSON(200, gin.H{"profile": studentProfile, "isAcademicsVerified": studentPopulated.Academics.Verification.IsVerified})
}

func (h *Handler) HandlerUpdateStudentProfile(ctx *gin.Context) {
Expand Down

0 comments on commit c91aa42

Please sign in to comment.