Exemplo n.º 1
0
func (this *ProblemController) Delete(w http.ResponseWriter, r *http.Request) {
	class.Logger.Debug("Admin Problem Delete")
	if r.Method != "POST" {
		this.Err400(w, r, "Error", "Error Method to Delete problem")
		return
	}

	this.Init(w, r)

	if this.Privilege != config.PrivilegeAD {
		this.Err400(w, r, "Warning", "Error Privilege to Delete problem")
		return
	}

	args := this.ParseURL(r.URL.String())
	pid, err := strconv.Atoi(args["pid"])
	if err != nil {
		http.Error(w, "args error", 400)
		return
	}

	problemModel := model.ProblemModel{}
	problemModel.Delete(pid)

	w.WriteHeader(200)
}
Exemplo n.º 2
0
//@URL: /admin/problems/(\d+)/ @method: DELETE
func (pc *AdminProblem) Delete(Pid string) {
	restweb.Logger.Debug("Admin Problem Delete")

	if pc.Privilege != config.PrivilegeAD {
		pc.Err400("Warning", "Error Privilege to Delete problem")
		return
	}

	pid, err := strconv.Atoi(Pid)
	if err != nil {
		pc.Error("args error", 400)
		return
	}

	problemModel := model.ProblemModel{}
	problemModel.Delete(pid)

	os.RemoveAll(config.Datapath + Pid) //delete test data
	pc.W.WriteHeader(200)
}