aboutsummaryrefslogtreecommitdiff
path: root/modules/lists
diff options
context:
space:
mode:
authorrtz12 <koenig@fagott.pw>2015-12-29 19:51:43 (UTC)
committerrtz12 <koenig@fagott.pw>2015-12-29 19:51:43 (UTC)
commit989ab00b731d659aa17d6a626efb899f8e400936 (patch)
tree8f31f5987a0ee6232b730dfad3fdd4d75f9ce153 /modules/lists
parentc2498d562d3e30e4795056058fc3d8a5cec4ec11 (diff)
parent1354a3a30c1639c1441e79356df12601151630a6 (diff)
Merge branch 'master' of projekte.fagott.pw:grilist
Diffstat (limited to 'modules/lists')
-rw-r--r--modules/lists/lists.go25
1 files changed, 14 insertions, 11 deletions
diff --git a/modules/lists/lists.go b/modules/lists/lists.go
index 47501c2..4c4288f 100644
--- a/modules/lists/lists.go
+++ b/modules/lists/lists.go
@@ -52,7 +52,7 @@ func (m *Module) Init(g *grilist.Grilist) {
52 log.Fatal("lists: grils module not found") 52 log.Fatal("lists: grils module not found")
53 } 53 }
54 54
55 grilsModule, ok := gm.Interface().(*grils.GrilsModule) 55 grilsModule, ok := gm.(*grils.GrilsModule)
56 if !ok { 56 if !ok {
57 log.Fatal("lists: error with grils module") 57 log.Fatal("lists: error with grils module")
58 } 58 }
@@ -60,11 +60,6 @@ func (m *Module) Init(g *grilist.Grilist) {
60 m.g.Router.GET("/list/:id", m.viewList) 60 m.g.Router.GET("/list/:id", m.viewList)
61} 61}
62 62
63// Interface gibt das Modul zurück
64func (m *Module) Interface() interface{} {
65 return m
66}
67
68func (m *Module) getListGrils(list *List) error { 63func (m *Module) getListGrils(list *List) error {
69 rows, err := m.g.DB.Query(`SELECT gril_id, "order" FROM grilist.lists_grils WHERE list_id = $1`, list.ID) 64 rows, err := m.g.DB.Query(`SELECT gril_id, "order" FROM grilist.lists_grils WHERE list_id = $1`, list.ID)
70 if err != nil { 65 if err != nil {
@@ -96,7 +91,7 @@ func (m *Module) getListGrils(list *List) error {
96func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, error) { 91func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, error) {
97 var lists []*List 92 var lists []*List
98 93
99 rows, err := m.g.DB.Query(fmt.Sprintf(`SELECT id, name, description, fork_of, updated_at FROM grilist.lists WHERE %s`, whereClause), params...) 94 rows, err := m.g.DB.Query(fmt.Sprintf(`SELECT id, name, description, fork_of, updated_at, user_id FROM grilist.lists WHERE %s`, whereClause), params...)
100 if err != nil { 95 if err != nil {
101 return nil, err 96 return nil, err
102 } 97 }
@@ -104,8 +99,8 @@ func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, e
104 defer rows.Close() 99 defer rows.Close()
105 for rows.Next() { 100 for rows.Next() {
106 list := &List{} 101 list := &List{}
107 102 var ownerID int
108 if err := rows.Scan(&list.ID, &list.Name, &list.Description, &list.ForkOf, &list.UpdatedAt); err != nil { 103 if err := rows.Scan(&list.ID, &list.Name, &list.Description, &list.ForkOf, &list.UpdatedAt, &ownerID); err != nil {
109 log.Println("error scanning row in getLists:", err) 104 log.Println("error scanning row in getLists:", err)
110 continue 105 continue
111 } 106 }
@@ -115,6 +110,14 @@ func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, e
115 continue 110 continue
116 } 111 }
117 112
113 // Owner kriegn
114 owner, err := m.g.Charakterin.GetUserByID(ownerID)
115 if err != nil {
116 log.Println("error retreiving owner of list", err)
117 continue
118 }
119 list.Owner = owner
120
118 lists = append(lists, list) 121 lists = append(lists, list)
119 } 122 }
120 123
@@ -161,8 +164,8 @@ func listsToCards(lists []*List) []frontend.Card {
161 Link: fmt.Sprintf("/list/%d", list.ID), 164 Link: fmt.Sprintf("/list/%d", list.ID),
162 }, 165 },
163 frontend.Action{ 166 frontend.Action{
164 Name: fmt.Sprintf(`<span class="chip">%d gril%s</span>`, len(list.Grils), s), 167 Name: fmt.Sprintf(`<span class="chip">%d gril%s</span>`, len(list.Grils), s),
165 Link: "#", 168 Link: "#",
166 Disabled: true, 169 Disabled: true,
167 }, 170 },
168 }, 171 },