bug fixes for go 1.19 update

This commit is contained in:
SowinskiBraeden committed 2023-01-07 15:10:55 -08:00
1 parent c3aaec9798
commit 0d29e1f382
7 files changed
+114 -102

No files matched your search

+39 -27
View File
@@ -231,18 +231,20 @@ func Enroll(c *fiber.Ctx) error {
})
}
student.PersonalData.FirstName = data["firstname"].(string)
student.PersonalData.MiddleName = data["middlename"].(string)
student.PersonalData.LastName = data["lastname"].(string)
student.PersonalData.Age = data["age"].(float64)
student.Personal.FirstName = data["firstname"].(string)
if middle, ok := data["middlename"]; ok {
student.Personal.MiddleName = middle.(string)
}
student.Personal.LastName = data["lastname"].(string)
student.Personal.Age = data["age"].(float64)
student.SchoolData.GradeLevel = data["gradelevel"].(float64)
student.PersonalData.DOB = data["dob"].(string)
student.PersonalData.Email = data["email"].(string)
student.PersonalData.Province = data["province"].(string)
student.PersonalData.City = data["city"].(string)
student.PersonalData.Address = data["address"].(string)
student.PersonalData.Postal = data["postal"].(string)
student.PersonalData.Contacts = []string{}
student.Personal.DOB = data["dob"].(string)
student.Personal.Email = data["email"].(string)
student.Personal.Province = data["province"].(string)
student.Personal.City = data["city"].(string)
student.Personal.Address = data["address"].(string)
student.Personal.Postal = data["postal"].(string)
student.Personal.Contacts = []string{}
student.SchoolData.YOG = ((12 - int(student.SchoolData.GradeLevel)) + time.Now().Year()) + 1
var photo models.Photo
@@ -287,10 +289,10 @@ func Enroll(c *fiber.Ctx) error {
// Send student personal email student ID
subject := "Account Registered"
receiver := student.PersonalData.Email
receiver := student.Personal.Email
r := NewRequest([]string{receiver}, subject)
if sent := r.Send("./templates/accountRegisreded.html", map[string]string{"username": student.PersonalData.FirstName, "id": sid, "userType": "student"}); !sent {
if sent := r.Send("./templates/accountRegisreded.html", map[string]string{"username": student.Personal.FirstName, "id": sid, "userType": "student"}); !sent {
cancel()
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
"success": false,
@@ -396,14 +398,24 @@ func RegisterTeacher(c *fiber.Ctx) error {
})
}
teacher.PersonalData.FirstName = data["firstname"].(string)
teacher.PersonalData.MiddleName = data["middlename"].(string)
teacher.PersonalData.LastName = data["lastname"].(string)
teacher.PersonalData.Email = data["email"].(string)
teacher.PersonalData.Province = data["province"].(string)
teacher.PersonalData.City = data["city"].(string)
teacher.PersonalData.Postal = data["postal"].(string)
teacher.PersonalData.DOB = data["dob"].(string)
teacher.Personal.FirstName = data["firstname"].(string)
if middle, ok := data["middlename"]; ok {
teacher.Personal.MiddleName = middle.(string)
}
teacher.Personal.LastName = data["lastname"].(string)
teacher.Personal.Email = data["email"].(string)
if province, ok := data["province"]; ok {
teacher.Personal.Province = province.(string)
}
if city, ok := data["city"]; ok {
teacher.Personal.City = city.(string)
}
if postal, ok := data["postal"]; ok {
teacher.Personal.Postal = postal.(string)
}
if dob, ok := data["dob"]; ok {
teacher.Personal.DOB = dob.(string)
}
var photo models.Photo
photo.Name = uuid.New().String()
@@ -447,10 +459,10 @@ func RegisterTeacher(c *fiber.Ctx) error {
// Send teacher personal email student ID
subject := "Account Registered"
receiver := teacher.PersonalData.Email
receiver := teacher.Personal.Email
r := NewRequest([]string{receiver}, subject)
if sent := r.Send("./templates/accountRegisreded.html", map[string]string{"username": teacher.PersonalData.FirstName, "id": tid, "userType": "teacher"}); !sent {
if sent := r.Send("./templates/accountRegisreded.html", map[string]string{"username": teacher.Personal.FirstName, "id": tid, "userType": "teacher"}); !sent {
cancel()
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
"success": false,
@@ -672,10 +684,10 @@ func StudentLogin(c *fiber.Ctx) error {
if !student.AccountData.Alerted {
// Send student email warning of disabled account
subject := "Account Disabled"
receiver := student.PersonalData.Email
receiver := student.Personal.Email
r := NewRequest([]string{receiver}, subject)
if sent := r.Send("./templates/accountDisabled.html", map[string]string{"username": student.PersonalData.FirstName}); !sent {
if sent := r.Send("./templates/accountDisabled.html", map[string]string{"username": student.Personal.FirstName}); !sent {
cancel()
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
"success": false,
@@ -981,8 +993,8 @@ func Student(c *fiber.Ctx) error {
var contacts []models.Contact
var contact models.Contact
for i := range student.PersonalData.Contacts {
findErr := ContactCollection.FindOne(context.TODO(), bson.M{"_id": student.PersonalData.Contacts[i]}).Decode(&contact)
for i := range student.Personal.Contacts {
findErr := ContactCollection.FindOne(context.TODO(), bson.M{"_id": student.Personal.Contacts[i]}).Decode(&contact)
if findErr != nil {
responseData["error"] = "Error! There was an error finding some contacts"
}
+29 -29
View File
@@ -63,18 +63,18 @@ func UpdateStudentName(c *fiber.Ctx) error {
if updateMiddle {
update = bson.M{
"$set": bson.M{
"personaldata.firstname": data["firstname"],
"personaldata.middlename": data["middlename"],
"personaldata.lastname": data["lastname"],
"updated_at": update_time,
"Personal.firstname": data["firstname"],
"Personal.middlename": data["middlename"],
"Personal.lastname": data["lastname"],
"updated_at": update_time,
},
}
} else {
update = bson.M{
"$set": bson.M{
"personaldata.firstname": data["firstname"],
"personaldata.lastname": data["lastname"],
"updated_at": update_time,
"Personal.firstname": data["firstname"],
"Personal.lastname": data["lastname"],
"updated_at": update_time,
},
}
}
@@ -162,15 +162,15 @@ func UpdateStudentGradeLevel(c *fiber.Ctx) error {
}
/*
Far later on this function is going to be completely automated.
Instead of an admin sending a request to update the homeroom of
a student or teacher, the system will take the room number of
the teacher's or student's Block 2 class from their schedule.
Far later on this function is going to be completely automated.
Instead of an admin sending a request to update the homeroom of
a student or teacher, the system will take the room number of
the teacher's or student's Block 2 class from their schedule.
Though this function would remain for students only, for example
a student requests a course change, if its their block 2 the
admin would have to alter their homeroom to be the new class
number.
Though this function would remain for students only, for example
a student requests a course change, if its their block 2 the
admin would have to alter their homeroom to be the new class
number.
*/
func UpdateStudentHomeroom(c *fiber.Ctx) error {
var data map[string]string
@@ -332,10 +332,10 @@ func UpdateStudentPassword(c *fiber.Ctx) error {
// Alert email the password has changed
subject := "Password Changed"
receiver := student.PersonalData.Email
receiver := student.Personal.Email
r := NewRequest([]string{receiver}, subject)
if sent := r.Send("./templates/selfPasswordChanged.html", map[string]string{"username": student.PersonalData.FirstName}); !sent {
if sent := r.Send("./templates/selfPasswordChanged.html", map[string]string{"username": student.Personal.FirstName}); !sent {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
"success": false,
"message": "failed to send email to student",
@@ -381,7 +381,7 @@ func ResetStudentPassword(c *fiber.Ctx) error {
})
}
if student.PersonalData.Email != data["email"] {
if student.Personal.Email != data["email"] {
cancel()
return c.Status(fiber.StatusOK).JSON(fiber.Map{
"success": false,
@@ -416,10 +416,10 @@ func ResetStudentPassword(c *fiber.Ctx) error {
// Send student personal email temp password
subject := "Password Changed"
receiver := student.PersonalData.Email
receiver := student.Personal.Email
r := NewRequest([]string{receiver}, subject)
if sent := r.Send("./templates/passwordChanged.html", map[string]string{"username": student.PersonalData.FirstName, "password": tempPass}); !sent {
if sent := r.Send("./templates/passwordChanged.html", map[string]string{"username": student.Personal.FirstName, "password": tempPass}); !sent {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
"success": false,
"message": "Could not send password to students email",
@@ -538,11 +538,11 @@ func UpdateStudentAddress(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"personaldata.address": data["address"],
"personaldata.city": data["city"],
"personaldata.province": data["province"],
"personaldata.postal": data["postal"],
"updated_at": update_time,
"Personal.address": data["address"],
"Personal.city": data["city"],
"Personal.province": data["province"],
"Personal.postal": data["postal"],
"updated_at": update_time,
},
}
@@ -687,7 +687,7 @@ func RemoveStudentContact(c *fiber.Ctx) error {
"updated_at": update_time,
},
"$pull": bson.M{
"personaldata.contacts": contact.ID,
"Personal.contacts": contact.ID,
},
}
@@ -761,7 +761,7 @@ func AddStudentContact(c *fiber.Ctx) error {
"updated_at": update_time,
},
"$push": bson.M{
"personaldata.contacts": contact.ID,
"Personal.contacts": contact.ID,
},
}
@@ -951,8 +951,8 @@ func UpdateStudentEmail(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"personaldata.email": data["email"],
"updated_at": update_time,
"Personal.email": data["email"],
"updated_at": update_time,
},
}
+24 -24
View File
@@ -17,15 +17,15 @@ import (
)
/*
Far later on this function is going to be completely automated.
Instead of an admin sending a request to update the homeroom of
a student or teacher, the system will take the room number of
the teacher's or student's Block 2 class from their schedule.
Far later on this function is going to be completely automated.
Instead of an admin sending a request to update the homeroom of
a student or teacher, the system will take the room number of
the teacher's or student's Block 2 class from their schedule.
Though this function would remain for students only, for example
a student requests a course change, if its their block 2 the
admin would have to alter their homeroom to be the new class
number.
Though this function would remain for students only, for example
a student requests a course change, if its their block 2 the
admin would have to alter their homeroom to be the new class
number.
*/
func UpdateTeacherHomeroom(c *fiber.Ctx) error {
var data map[string]string
@@ -186,10 +186,10 @@ func UpdateTeacherPassword(c *fiber.Ctx) error {
defer cancel()
subject := "Password Changed"
receiver := teacher.PersonalData.Email
receiver := teacher.Personal.Email
r := NewRequest([]string{receiver}, subject)
if sent := r.Send("./templates/selfPasswordChanged.html", map[string]string{"username": teacher.PersonalData.FirstName}); !sent {
if sent := r.Send("./templates/selfPasswordChanged.html", map[string]string{"username": teacher.Personal.FirstName}); !sent {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
"success": false,
"message": "Could not send password to teachers email",
@@ -234,7 +234,7 @@ func ResetTeacherPassword(c *fiber.Ctx) error {
})
}
if teacher.PersonalData.Email != data["email"] {
if teacher.Personal.Email != data["email"] {
cancel()
return c.Status(fiber.StatusOK).JSON(fiber.Map{
"success": false,
@@ -269,10 +269,10 @@ func ResetTeacherPassword(c *fiber.Ctx) error {
// Send teacher personal email temp password
subject := "Password Changed"
receiver := teacher.PersonalData.Email
receiver := teacher.Personal.Email
r := NewRequest([]string{receiver}, subject)
if sent := r.Send("./templates/passwordChanged.html", map[string]string{"username": teacher.PersonalData.FirstName, "password": tempPass}); !sent {
if sent := r.Send("./templates/passwordChanged.html", map[string]string{"username": teacher.Personal.FirstName, "password": tempPass}); !sent {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
"success": false,
"message": "Could not send password to teachers email",
@@ -320,11 +320,11 @@ func UpdateTeacherAddress(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"personaldata.address": data["address"],
"personaldata.city": data["city"],
"personaldata.province": data["province"],
"personaldata.postal": data["postal"],
"updated_at": update_time,
"Personal.address": data["address"],
"Personal.city": data["city"],
"Personal.province": data["province"],
"Personal.postal": data["postal"],
"updated_at": update_time,
},
}
@@ -514,8 +514,8 @@ func UpdateTeacherEmail(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"personaldata.email": data["email"],
"updated_at": update_time,
"Personal.email": data["email"],
"updated_at": update_time,
},
}
@@ -592,10 +592,10 @@ func UpdateTeacherName(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"personaldata.firstname": data["firstname"],
"personaldata.middlename": middlename,
"personaldata.lastname": data["lastname"],
"updated_at": update_time,
"Personal.firstname": data["firstname"],
"Personal.middlename": middlename,
"Personal.lastname": data["lastname"],
"updated_at": update_time,
},
}