Browse Source

Remove unused associations

Andrea Fazzi 6 years ago
parent
commit
202dc926e0
1 changed files with 0 additions and 40 deletions
  1. 0 40
      api/classes.go

+ 0 - 40
api/classes.go

@@ -136,26 +136,6 @@ func classesAddHandler() http.Handler {
 				panic(err)
 			}
 
-			if class.CoordinatorID != 0 {
-				var coordinator orm.Teacher
-				if err := orm.DB().First(&coordinator, class.CoordinatorID).Error; err != nil {
-					panic(err)
-				}
-				if err := orm.DB().Model(&class).Association("Teachers").Append(coordinator).Error; err != nil {
-					panic(err)
-				}
-			}
-
-			if class.MinuterID != 0 {
-				var minuter orm.Teacher
-				if err := orm.DB().First(&minuter, class.MinuterID).Error; err != nil {
-					panic(err)
-				}
-				if err := orm.DB().Model(&class).Association("Teachers").Append(minuter).Error; err != nil {
-					panic(err)
-				}
-			}
-
 			http.Redirect(w, r, fmt.Sprintf("/classes/%d", class.ID), http.StatusSeeOther)
 		}
 
@@ -244,26 +224,6 @@ func classesUpdateHandler() http.Handler {
 				panic(err)
 			}
 
-			if class.CoordinatorID != 0 {
-				var coordinator orm.Teacher
-				if err := orm.DB().First(&coordinator, class.CoordinatorID).Error; err != nil {
-					panic(err)
-				}
-				if err := orm.DB().Model(&class).Association("Teachers").Append(coordinator).Error; err != nil {
-					panic(err)
-				}
-			}
-
-			if class.MinuterID != 0 {
-				var minuter orm.Teacher
-				if err := orm.DB().First(&minuter, class.MinuterID).Error; err != nil {
-					panic(err)
-				}
-				if err := orm.DB().Model(&class).Association("Teachers").Append(minuter).Error; err != nil {
-					panic(err)
-				}
-			}
-
 			http.Redirect(w, r, fmt.Sprintf("/classes/%d", class.ID), http.StatusSeeOther)
 		}