func CreateTeachers(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	redirected, _ := ensureLoggedIn(w, r)
	if redirected {
		return
	}

	r.ParseMultipartForm(16384)
	file, _, err := r.FormFile("teacherjson")
	if err != nil {
		log.Printf("error recieving teacher file from upload: %v\n", err)
		return
	}
	defer file.Close()

	bytes, err := ioutil.ReadAll(file)
	if err != nil {
		log.Printf("error reading teacher file: %v\n", err)
		return
	}

	type tmpTeacher struct {
		model.Teacher
		Compellation string
	}
	teachers := []tmpTeacher{}
	err = json.Unmarshal(bytes, &teachers)
	if err != nil {
		log.Printf("error unmarshaling teacher data: %v\n", err)
		return
	}
	for _, teacher := range teachers {
		if teacher.Compellation == "Herr" {
			teacher.Sex = "m"
		} else {
			teacher.Sex = "w"
		}
		teacher.Create()

		unknown := model.UnknownTeacher{Short: teacher.Short}
		unknown.Delete()
	}

	http.Redirect(w, r, "/teachers", http.StatusSeeOther)
}
// CreateTeachers creates multiple teachers from json upload and serves the list
// of all teachers.
CreateTeachers creates multiple teachers from json upload and serves the list
of all teachers.
// CreateTeachers creates multiple teachers from json upload and serves the list // of all teachers .
func CreateTeachers(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	redirected, _ := ensureLoggedIn(w, r)
	if redirected {
		return
	}
	r.ParseMultipartForm(16384)
	file, _, err := r.FormFile("teacherjson")
	if err != nil {
		log.Printf("error recieving teacher file from upload: %v\n", err)
		return
	}
	defer file.Close()
	bytes, err := ioutil.ReadAll(file)
	if err != nil {
		log.Printf("error reading teacher file: %v\n", err)
		return
	}
	type tmpTeacher struct {
		model.Teacher
		Compellation string
	}
	teachers := []tmpTeacher{}
	err = json.Unmarshal(bytes, &teachers)
	if err != nil {
		log.Printf("error unmarshaling teacher data: %v\n", err)
		return
	}
	for _, teacher := range teachers {
		if teacher.Compellation == "Herr" {
			teacher.Sex = "m"
		} else {
			teacher.Sex = "w"
		}
		teacher.Create()
		unknown := model.UnknownTeacher{Short: teacher.Short}
		unknown.Delete()
	}
	http.Redirect(w, r, "/teachers", http.StatusSeeOther)
}
func CreateTeachers ( w http . ResponseWriter , r * http . Request , _ httprouter . Params ) { redirected , _ := ensureLoggedIn ( w , r ) if redirected { return } r . ParseMultipartForm ( 16384 ) file , _ , err := r . FormFile ( " " ) if err != nil { log . Printf ( " \n " , err ) return } defer file . Close ( ) bytes , err := ioutil . ReadAll ( file ) if err != nil { log . Printf ( " \n " , err ) return } type tmpTeacher struct { model . Teacher Compellation string } teachers := [ ] tmpTeacher { } err = json . Unmarshal ( bytes , & teachers ) if err != nil { log . Printf ( " \n " , err ) return } for _ , teacher := range teachers { if teacher . Compellation == " " { teacher . Sex = " " } else { teacher . Sex = " " } teacher . Create ( ) unknown := model . UnknownTeacher { Short : teacher . Short } unknown . Delete ( ) } http . Redirect ( w , r , " " , http . StatusSeeOther ) }
CreateTeachers creates multiple teachers from json upload and serves the list
of all teachers.
CreateTeachers creates multiple teachers from json upload and serves the list of all teachers .