This commit is contained in:
Suraj 2016-01-28 20:49:59 +05:30
commit c585103642
2 changed files with 23 additions and 1 deletions

View File

@ -19,7 +19,7 @@
<input type="hidden" name="CSRFToken" value={{.CSRFToken}}> <input type="hidden" name="CSRFToken" value={{.CSRFToken}}>
</div> </div>
<div class="form-group"> <div class="form-group">
<textarea class="form-control" name="content" id="add-note-content" placeholder="Content" rows="10" style="border:none;border-bottom:1px solid gray; box-shadow:none;"></textarea> <textarea class="form-control" name="content" id="add-note-content" placeholder="Content" rows="10" style="border:none;border-bottom:1px solid gray; box-shadow:none;"></textarea>
File: <input type="file" name="uploadfile" /> <br> File: <input type="file" name="uploadfile" /> <br>
Priority: <select name="priority"> Priority: <select name="priority">
@ -52,7 +52,11 @@
<li role="presentation"> <li role="presentation">
<span class="glyphicon glyphicon-time"></span> {{.Created}}</li> <span class="glyphicon glyphicon-time"></span> {{.Created}}</li>
<li role="presentation"> <li role="presentation">
<<<<<<< HEAD
<a role="menuitem" tabindex="-1" href="/mask/{{.Id}}"> <a role="menuitem" tabindex="-1" href="/mask/{{.Id}}">
=======
<a role="menuitem" tabindex="-1" href="/mask/{{.Id}}">
>>>>>>> 474ffbc0ea29e8ccacc707893a07534a4afed961
<span class="glyphicon glyphicon-lock"></span></a></li> <span class="glyphicon glyphicon-lock"></span></a></li>
<li role="presentation"> <li role="presentation">
<a role="menuitem" tabindex="-1" href="/trash/{{.Id}}"> <a role="menuitem" tabindex="-1" href="/trash/{{.Id}}">

View File

@ -12,6 +12,7 @@ import (
"strings" "strings"
"text/template" "text/template"
"time" "time"
) )
var homeTemplate *template.Template var homeTemplate *template.Template
@ -113,6 +114,7 @@ func AddTaskFunc(w http.ResponseWriter, r *http.Request) {
file, handler, err := r.FormFile("uploadfile") file, handler, err := r.FormFile("uploadfile")
if err != nil { if err != nil {
log.Println(err) log.Println(err)
<<<<<<< HEAD
} }
taskPriority, priorityErr := strconv.Atoi(r.FormValue("priority")) taskPriority, priorityErr := strconv.Atoi(r.FormValue("priority"))
@ -129,6 +131,14 @@ func AddTaskFunc(w http.ResponseWriter, r *http.Request) {
content := template.HTMLEscapeString(r.Form.Get("content")) content := template.HTMLEscapeString(r.Form.Get("content"))
formToken := template.HTMLEscapeString(r.Form.Get("CSRFToken")) formToken := template.HTMLEscapeString(r.Form.Get("CSRFToken"))
=======
return
}
title := template.HTMLEscapeString(r.Form.Get("title"))
content := template.HTMLEscapeString(r.Form.Get("content"))
formToken := template.HTMLEscapeString(r.Form.Get("CSRFToken"))
>>>>>>> 474ffbc0ea29e8ccacc707893a07534a4afed961
cookie, _ := r.Cookie("csrftoken") cookie, _ := r.Cookie("csrftoken")
if formToken == cookie.Value { if formToken == cookie.Value {
if handler != nil { if handler != nil {
@ -141,11 +151,19 @@ func AddTaskFunc(w http.ResponseWriter, r *http.Request) {
} }
defer f.Close() defer f.Close()
io.Copy(f, file) io.Copy(f, file)
<<<<<<< HEAD
filelink := "<br> <a href=/files/" + handler.Filename + ">" + handler.Filename + "</a>" filelink := "<br> <a href=/files/" + handler.Filename + ">" + handler.Filename + "</a>"
content = content + filelink content = content + filelink
} }
truth := db.AddTask(title, content, taskPriority) truth := db.AddTask(title, content, taskPriority)
=======
filelink := "<br> <a href=./files/"+handler.Filename+">"+ handler.Filename+"</a>"
content = content + filelink
}
truth := db.AddTask(title, content)
>>>>>>> 474ffbc0ea29e8ccacc707893a07534a4afed961
if truth != nil { if truth != nil {
message = "Error adding task" message = "Error adding task"
log.Println("error adding task to db") log.Println("error adding task to db")