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" .}}