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

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

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

	type tmpSubject struct {
		model.Subject
		ConcurrentlyTaught bool
	}
	subjects := []tmpSubject{}
	err = json.Unmarshal(bytes, &subjects)
	if err != nil {
		log.Printf("error unmarshaling subject data: %v\n", err)
		return
	}
	for _, subject := range subjects {
		if subject.ConcurrentlyTaught {
			subject.SplitClass = true
		}
		subject.Create()

		unknown := model.UnknownSubject{Short: subject.Short}
		unknown.Delete()
	}

	http.Redirect(w, r, "/subjects", http.StatusSeeOther)
}
// CreateSubjects creates multiple subjects from json upload and serves the list
// of all subjects.
CreateSubjects creates multiple subjects from json upload and serves the list
of all subjects.
// CreateSubjects creates multiple subjects from json upload and serves the list // of all subjects .
func CreateSubjects(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	redirected, _ := ensureLoggedIn(w, r)
	if redirected {
		return
	}
	r.ParseMultipartForm(16384)
	file, _, err := r.FormFile("subjectjson")
	if err != nil {
		log.Printf("error recieving subject file from upload: %v\n", err)
		return
	}
	defer file.Close()
	bytes, err := ioutil.ReadAll(file)
	if err != nil {
		log.Printf("error reading subject file: %v\n", err)
		return
	}
	type tmpSubject struct {
		model.Subject
		ConcurrentlyTaught bool
	}
	subjects := []tmpSubject{}
	err = json.Unmarshal(bytes, &subjects)
	if err != nil {
		log.Printf("error unmarshaling subject data: %v\n", err)
		return
	}
	for _, subject := range subjects {
		if subject.ConcurrentlyTaught {
			subject.SplitClass = true
		}
		subject.Create()
		unknown := model.UnknownSubject{Short: subject.Short}
		unknown.Delete()
	}
	http.Redirect(w, r, "/subjects", http.StatusSeeOther)
}
func CreateSubjects ( 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 tmpSubject struct { model . Subject ConcurrentlyTaught bool } subjects := [ ] tmpSubject { } err = json . Unmarshal ( bytes , & subjects ) if err != nil { log . Printf ( " \n " , err ) return } for _ , subject := range subjects { if subject . ConcurrentlyTaught { subject . SplitClass = true } subject . Create ( ) unknown := model . UnknownSubject { Short : subject . Short } unknown . Delete ( ) } http . Redirect ( w , r , " " , http . StatusSeeOther ) }
CreateSubjects creates multiple subjects from json upload and serves the list
of all subjects.
CreateSubjects creates multiple subjects from json upload and serves the list of all subjects .