Edit Task bug fixed
This commit is contained in:
parent
4f4fd46782
commit
57d096f8b9
|
@ -35,13 +35,15 @@ func AddTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == "POST" { // Will work only for POST requests, will redirect to home
|
if r.Method == "POST" { // Will work only for POST requests, will redirect to home
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
file, handler, err := r.FormFile("uploadfile")
|
file, handler, err := r.FormFile("uploadfile")
|
||||||
if err != nil {
|
if err != nil && handler != nil {
|
||||||
|
//Case executed when file is uploaded and yet an error occurs
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
message = "Error uploading file"
|
message = "Error uploading file"
|
||||||
http.Redirect(w, r, "/", http.StatusInternalServerError)
|
http.Redirect(w, r, "/", http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
taskPriority, priorityErr := strconv.Atoi(r.FormValue("priority"))
|
taskPriority, priorityErr := strconv.Atoi(r.FormValue("priority"))
|
||||||
|
|
||||||
if priorityErr != nil {
|
if priorityErr != nil {
|
||||||
log.Print(priorityErr)
|
log.Print(priorityErr)
|
||||||
message = "Bad task priority"
|
message = "Bad task priority"
|
||||||
|
@ -66,6 +68,7 @@ func AddTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
cookie, _ := r.Cookie("csrftoken")
|
cookie, _ := r.Cookie("csrftoken")
|
||||||
if formToken == cookie.Value {
|
if formToken == cookie.Value {
|
||||||
if handler != nil {
|
if handler != nil {
|
||||||
|
// this will be executed whenever a file is uploaded
|
||||||
r.ParseMultipartForm(32 << 20) //defined maximum size of file
|
r.ParseMultipartForm(32 << 20) //defined maximum size of file
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
randomFileName := md5.New()
|
randomFileName := md5.New()
|
||||||
|
@ -99,8 +102,8 @@ func AddTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
} else {
|
} else {
|
||||||
message = "Task added"
|
message = "Task added"
|
||||||
log.Println("added task to db")
|
log.Println("added task to db")
|
||||||
}
|
|
||||||
http.Redirect(w, r, "/", http.StatusFound)
|
http.Redirect(w, r, "/", http.StatusFound)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Println("CSRF mismatch")
|
log.Println("CSRF mismatch")
|
||||||
message = "Server Error"
|
message = "Server Error"
|
||||||
|
|
Loading…
Reference in New Issue