From f73f862bcf48165b9486341569906d707247288f Mon Sep 17 00:00:00 2001 From: Florian Hoss Date: Wed, 6 Apr 2022 20:59:10 +0200 Subject: [PATCH] task can be added --- Lab01/app/database/database.go | 11 ++++++++++ Lab01/app/database/types.go | 1 + Lab01/app/templates/tasks.tmpl | 40 ++++++++++++++++++++++++---------- Lab01/app/webpage/webpage.go | 27 +++++++++++++++++++---- 4 files changed, 64 insertions(+), 15 deletions(-) diff --git a/Lab01/app/database/database.go b/Lab01/app/database/database.go index 6eb5fa1..a9eb9ed 100644 --- a/Lab01/app/database/database.go +++ b/Lab01/app/database/database.go @@ -34,6 +34,17 @@ func (db *Database) GetAllTasks() []Task { return tasks } +func (db *Database) CreateTask(username string, description string) Task { + task := Task{ + ID: 0, + Username: username, + Description: description, + Done: false, + } + db.ORM.Create(&task) + return task +} + func (db *Database) CreateUser(username string, password string) error { user := User{Username: username, Password: password} result := db.ORM.Create(&user) diff --git a/Lab01/app/database/types.go b/Lab01/app/database/types.go index 081dbda..515266e 100644 --- a/Lab01/app/database/types.go +++ b/Lab01/app/database/types.go @@ -17,6 +17,7 @@ type User struct { type Task struct { ID int `gorm:"primaryKey"` + Username string Description string Done bool } diff --git a/Lab01/app/templates/tasks.tmpl b/Lab01/app/templates/tasks.tmpl index 66c249c..89eb3df 100644 --- a/Lab01/app/templates/tasks.tmpl +++ b/Lab01/app/templates/tasks.tmpl @@ -30,9 +30,37 @@ {{template "scripts" .}} +{{template "formScripts" .}}