forked from OrgGo/Tasks
formatting small things
This commit is contained in:
parent
eb42e38fae
commit
534cb71064
10
db/tasks.go
10
db/tasks.go
|
@ -2,13 +2,12 @@ package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"log"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3" //we want to use sqlite natively
|
_ "github.com/mattn/go-sqlite3" //we want to use sqlite natively
|
||||||
md "github.com/shurcooL/github_flavored_markdown"
|
md "github.com/shurcooL/github_flavored_markdown"
|
||||||
"github.com/thewhitetulip/Tasks/types"
|
"github.com/thewhitetulip/Tasks/types"
|
||||||
|
"log"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var database Database
|
var database Database
|
||||||
|
@ -162,6 +161,7 @@ func UpdateTask(id int, title string, content string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//taskQuery encapsulates running multiple queries which don't do much things
|
||||||
func taskQuery(sql string, args ...interface{}) error {
|
func taskQuery(sql string, args ...interface{}) error {
|
||||||
SQL := database.prepare(sql)
|
SQL := database.prepare(sql)
|
||||||
tx := database.begin()
|
tx := database.begin()
|
||||||
|
@ -170,7 +170,7 @@ func taskQuery(sql string, args ...interface{}) error {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
} else {
|
} else {
|
||||||
log.Println(tx.Commit())
|
tx.Commit()
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
package views
|
package views
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"log"
|
|
||||||
"strconv"
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
"fmt"
|
|
||||||
"text/template"
|
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
|
"fmt"
|
||||||
"github.com/thewhitetulip/Tasks/db"
|
"github.com/thewhitetulip/Tasks/db"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"text/template"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UploadedFileHandler is used to handle the uploaded file related requests
|
// UploadedFileHandler is used to handle the uploaded file related requests
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
//TrashTaskFunc is used to populate the trash tasks
|
//TrashTaskFunc is used to populate the trash tasks
|
||||||
func TrashTaskFunc(w http.ResponseWriter, r *http.Request) {
|
func TrashTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == "GET" {
|
if r.Method == "GET" {
|
||||||
|
@ -50,7 +49,6 @@ func RestoreTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//EditTaskFunc is used to edit tasks, handles "/edit/" URL
|
//EditTaskFunc is used to edit tasks, handles "/edit/" URL
|
||||||
func EditTaskFunc(w http.ResponseWriter, r *http.Request) {
|
func EditTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == "GET" {
|
if r.Method == "GET" {
|
||||||
|
@ -67,7 +65,6 @@ func EditTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//DeleteTaskFunc is used to delete a task, trash = move to recycle bin, delete = permanent delete
|
//DeleteTaskFunc is used to delete a task, trash = move to recycle bin, delete = permanent delete
|
||||||
func DeleteTaskFunc(w http.ResponseWriter, r *http.Request) {
|
func DeleteTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == "GET" {
|
if r.Method == "GET" {
|
||||||
|
@ -95,7 +92,6 @@ func DeleteTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//RestoreFromCompleteFunc restores the task from complete to pending
|
//RestoreFromCompleteFunc restores the task from complete to pending
|
||||||
func RestoreFromCompleteFunc(w http.ResponseWriter, r *http.Request) {
|
func RestoreFromCompleteFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == "GET" {
|
if r.Method == "GET" {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
//PopulateTemplates is used to parse all templates present in
|
//PopulateTemplates is used to parse all templates present in
|
||||||
//the templates folder
|
//the templates folder
|
||||||
func PopulateTemplates() {
|
func PopulateTemplates() {
|
||||||
|
@ -81,7 +80,6 @@ func SearchTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//UpdateTaskFunc is used to update a task, handes "/update/" URL
|
//UpdateTaskFunc is used to update a task, handes "/update/" URL
|
||||||
func UpdateTaskFunc(w http.ResponseWriter, r *http.Request) {
|
func UpdateTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == "POST" {
|
if r.Method == "POST" {
|
||||||
|
@ -104,4 +102,4 @@ func UpdateTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||||
message = "Method not allowed"
|
message = "Method not allowed"
|
||||||
http.Redirect(w, r, "/", http.StatusFound)
|
http.Redirect(w, r, "/", http.StatusFound)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue