aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkeiser <keiserwiliem@googlemail.com>2016-11-04 17:07:11 (UTC)
committerkeiser <keiserwiliem@googlemail.com>2016-11-04 17:07:11 (UTC)
commitb37847a030c792697902466274080ed095600008 (patch)
tree6ffec2835103815db922e510f5b0bbd6a3f4704f
parent7aaf955a8455c6cedd74d7a8e3cda6de8318a0c2 (diff)
Drucker ist ein fauler versager
-rw-r--r--modules/lists/lists.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/lists/lists.go b/modules/lists/lists.go
index 753a7be..ad3bd0e 100644
--- a/modules/lists/lists.go
+++ b/modules/lists/lists.go
@@ -663,6 +663,7 @@ func (m *Module) updateGrilOrder(w http.ResponseWriter, r *http.Request, p httpr
663 663
664func (m *Module) removeGrilFromList(w http.ResponseWriter, r *http.Request, p httprouter.Params) { 664func (m *Module) removeGrilFromList(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
665 el := m.g.EventLogger(r) 665 el := m.g.EventLogger(r)
666 var oldOrder int
666 667
667 user, err := m.g.Charakterin.GetUserFromRequest(r) 668 user, err := m.g.Charakterin.GetUserFromRequest(r)
668 if err != nil { 669 if err != nil {
@@ -694,7 +695,7 @@ func (m *Module) removeGrilFromList(w http.ResponseWriter, r *http.Request, p ht
694 return 695 return
695 } 696 }
696 697
697 res, err := m.g.DB.Exec(`DELETE FROM grilist.lists_grils WHERE list_id=$1 AND gril_id=$2`, listID, grilID) 698 res, err := m.g.DB.QueryRow(`DELETE FROM grilist.lists_grils WHERE list_id=$1 AND gril_id=$2`, listID, grilID).scan(&oldOrder)
698 if err != nil { 699 if err != nil {
699 log.Println("error removing gril:", err) 700 log.Println("error removing gril:", err)
700 http.Error(w, "could not remove gril", 500) 701 http.Error(w, "could not remove gril", 500)
@@ -706,6 +707,13 @@ func (m *Module) removeGrilFromList(w http.ResponseWriter, r *http.Request, p ht
706 http.Error(w, "gril not in list / other error", 500) 707 http.Error(w, "gril not in list / other error", 500)
707 return 708 return
708 } 709 }
710
711 res, err := m.g.DB.Exec(`UPDATE grilist.lists_gril SET "order" = "order" - 1 WHERE list_id = $1 AND "order" > $2`, listID, oldOrder)
712 if err != nil {
713 log.Println("error removing gril:", err)
714 http.Error(w, "could not remove gril", 500)
715 return
716 }
709 717
710 list.Grils = list.Grils[:0] 718 list.Grils = list.Grils[:0]
711 719