aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjan <jan@ruken.pw>2016-10-10 11:12:59 (UTC)
committerjan <jan@ruken.pw>2016-10-10 11:12:59 (UTC)
commit892495f99912166623b69dc9c91ed1b45e4809fb (patch)
treedcb6f4ba734fee34fcbdc637ac329ec235410d9d
parent5b069f567cc45475a7d2562150de6550d03634f5 (diff)
nur den unterschied bei einer liste updaten
-rw-r--r--modules/lists/lists.go30
1 files changed, 23 insertions, 7 deletions
diff --git a/modules/lists/lists.go b/modules/lists/lists.go
index 2f37fb8..9e78ac7 100644
--- a/modules/lists/lists.go
+++ b/modules/lists/lists.go
@@ -387,16 +387,32 @@ func (m *Module) updateListSettings(w http.ResponseWriter, r *http.Request, p ht
387 return 387 return
388 } 388 }
389 389
390 list.Name = name 390 if list.Name != name && list.Description != description {
391 list.Description = description 391 _, err = m.g.DB.Query(`UPDATE grilist.lists SET name = $2, description = $3 WHERE id = $1`, id, name, description)
392 if err != nil {
393 log.Println("could not update list:", err)
394 renderWithError("interner fehler", false, false)
395 return
396 }
397 } else if list.Name != name || list.Description != description {
398 field := "name"
399 value := name
400 if list.Description != description {
401 field = "description"
402 value = description
403 }
392 404
393 _, err = m.g.DB.Query(`UPDATE grilist.lists SET name = $2, description = $3 WHERE id = $1`, id, name, description) 405 _, err = m.g.DB.Query(fmt.Sprintf(`UPDATE grilist.lists SET %s = $2 WHERE id = $1`, field), id, value)
394 if err != nil { 406 if err != nil {
395 log.Println("could not update list:", err) 407 log.Println("could not update list:", err)
396 renderWithError("interner fehler", false, false) 408 renderWithError("interner fehler", false, false)
397 return 409 return
410 }
398 } 411 }
399 412
413 list.Name = name
414 list.Description = description
415
400 m.viewListSettings(w, r, p) 416 m.viewListSettings(w, r, p)
401} 417}
402 418