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

	short := html.EscapeString(params.ByName("short"))
	teacher := model.Teacher{Short: short}
	if !teacher.Exists() {
		http.NotFound(w, r)
		return
	}

	// Parse and validate teacher data.
	r.ParseForm()
	nshort := html.EscapeString(r.Form.Get("short"))
	name := html.EscapeString(r.Form.Get("name"))
	sex := html.EscapeString(r.Form.Get("sex"))

	valid, message := validateTeacherData(short, name, sex)
	if !valid {
		http.Error(w, message, http.StatusNotAcceptable)
		return
	}

	// Update teacher and send the new URL back to the client.
	// It might have changed with an update of short.
	updTeacher := model.Teacher{Short: nshort, Name: name, Sex: sex}
	updTeacher.UpdateShort(short)
	w.Write([]byte(fmt.Sprintf("/teacher/%s", nshort)))
}
// UpdateTeacher updates a teacher with the uploaded information.
UpdateTeacher updates a teacher with the uploaded information.
// UpdateTeacher updates a teacher with the uploaded information .
func UpdateTeacher(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
	redirected, _ := ensureLoggedIn(w, r)
	if redirected {
		return
	}
	short := html.EscapeString(params.ByName("short"))
	teacher := model.Teacher{Short: short}
	if !teacher.Exists() {
		http.NotFound(w, r)
		return
	}
	r.ParseForm()
	nshort := html.EscapeString(r.Form.Get("short"))
	name := html.EscapeString(r.Form.Get("name"))
	sex := html.EscapeString(r.Form.Get("sex"))
	valid, message := validateTeacherData(short, name, sex)
	if !valid {
		http.Error(w, message, http.StatusNotAcceptable)
		return
	}
	updTeacher := model.Teacher{Short: nshort, Name: name, Sex: sex}
	updTeacher.UpdateShort(short)
	w.Write([]byte(fmt.Sprintf("/teacher/%s", nshort)))
}
func UpdateTeacher ( w http . ResponseWriter , r * http . Request , params httprouter . Params ) { redirected , _ := ensureLoggedIn ( w , r ) if redirected { return } short := html . EscapeString ( params . ByName ( " " ) ) teacher := model . Teacher { Short : short } if ! teacher . Exists ( ) { http . NotFound ( w , r ) return } r . ParseForm ( ) nshort := html . EscapeString ( r . Form . Get ( " " ) ) name := html . EscapeString ( r . Form . Get ( " " ) ) sex := html . EscapeString ( r . Form . Get ( " " ) ) valid , message := validateTeacherData ( short , name , sex ) if ! valid { http . Error ( w , message , http . StatusNotAcceptable ) return } updTeacher := model . Teacher { Short : nshort , Name : name , Sex : sex } updTeacher . UpdateShort ( short ) w . Write ( [ ] byte ( fmt . Sprintf ( " " , nshort ) ) ) }
UpdateTeacher updates a teacher with the uploaded information.
UpdateTeacher updates a teacher with the uploaded information .
// Parse and validate teacher data. // Update teacher and send the new URL back to the client. // It might have changed with an update of short.