summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--controller/recipe.go4
-rw-r--r--model/recipe.go5
2 files changed, 4 insertions, 5 deletions
diff --git a/controller/recipe.go b/controller/recipe.go
index 818a077..6acb062 100644
--- a/controller/recipe.go
+++ b/controller/recipe.go
@@ -13,6 +13,8 @@ import (
func RecipeCreate(w http.ResponseWriter, r *http.Request) {
recipe := model.Recipe{}
recipe.Title = "recipe without title"
+ recipe.Touch()
+ recipe.Created = recipe.LastChanged
err := recipe.Create()
if err != nil {
@@ -42,6 +44,8 @@ func RecipeUpdate(w http.ResponseWriter, r *http.Request) {
return
}
+ recipe.Touch()
+
err = recipe.Update()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
diff --git a/model/recipe.go b/model/recipe.go
index b9830e6..db3af70 100644
--- a/model/recipe.go
+++ b/model/recipe.go
@@ -29,9 +29,6 @@ func (r *Recipe) Touch() {
}
func (r *Recipe) Create() error {
- r.Touch()
- r.Created = r.LastChanged
-
query := `INSERT INTO recipes
(title, portions, url, notes, created, last_changed)
VALUES
@@ -88,8 +85,6 @@ WHERE id = ?`
}
func (r *Recipe) Update() error {
- r.Touch()
-
query := `UPDATE
recipes
SET