Fix error occurring when attaching a file to a Task
Extend the SQL storing the information to a file by username and creation date.
This commit is contained in:
parent
3c5e5460e8
commit
4f9b712053
|
@ -11,8 +11,8 @@ import (
|
||||||
|
|
||||||
// AddFile is used to add the md5 of a file name which is uploaded to our application
|
// AddFile is used to add the md5 of a file name which is uploaded to our application
|
||||||
// this will enable us to randomize the URL without worrying about the file names
|
// this will enable us to randomize the URL without worrying about the file names
|
||||||
func AddFile(fileName, token string) error {
|
func AddFile(fileName, token, username string) error {
|
||||||
err := taskQuery("insert into files values(?,?)", fileName, token)
|
err := taskQuery("insert into files values(?,?,?,datetime())", fileName, token, username)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,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 {
|
||||||
|
username := sessions.GetCurrentUserName(r)
|
||||||
if handler != nil {
|
if handler != nil {
|
||||||
// this will be executed whenever a file is uploaded
|
// 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
|
||||||
|
@ -95,13 +96,12 @@ func AddTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
content = content + filelink
|
content = content + filelink
|
||||||
|
|
||||||
fileTruth := db.AddFile(handler.Filename, token)
|
fileTruth := db.AddFile(handler.Filename, token, username)
|
||||||
if fileTruth != nil {
|
if fileTruth != nil {
|
||||||
message = "Error adding filename in db"
|
message = "Error adding filename in db"
|
||||||
log.Println("error adding task to db")
|
log.Println("error adding task to db")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
username := sessions.GetCurrentUserName(r)
|
|
||||||
taskTruth := db.AddTask(title, content, category, taskPriority, username)
|
taskTruth := db.AddTask(title, content, category, taskPriority, username)
|
||||||
|
|
||||||
if taskTruth != nil {
|
if taskTruth != nil {
|
||||||
|
|
Loading…
Reference in New Issue