aboutsummaryrefslogtreecommitdiff
path: root/modules/grils
diff options
context:
space:
mode:
authorrtz12 <koenig@fagott.pw>2015-12-28 18:56:47 (UTC)
committerrtz12 <koenig@fagott.pw>2015-12-28 18:56:47 (UTC)
commiteb03000339859fc3b5869cb8906f1e4f1022a52e (patch)
treeb238d003268dfb9c93dfa80635ad8263cb67b2b8 /modules/grils
parent23f73a60a4cf4621dd5951bfe6601a8c154cad07 (diff)
parent647c105dadfa58af6cfa80d3f359d43cfa5d5cf2 (diff)
Merge branch 'master' of projekte.fagott.pw:grilist
Diffstat (limited to 'modules/grils')
-rw-r--r--modules/grils/gril.go1
-rw-r--r--modules/grils/grils.go24
2 files changed, 25 insertions, 0 deletions
diff --git a/modules/grils/gril.go b/modules/grils/gril.go
index 9fd3be5..edf25a9 100644
--- a/modules/grils/gril.go
+++ b/modules/grils/gril.go
@@ -23,4 +23,5 @@ type Gril struct {
23 Tags []string 23 Tags []string
24 ForeignIDs map[DataSource]int 24 ForeignIDs map[DataSource]int
25 UpdatedAt time.Time 25 UpdatedAt time.Time
26 Lists []int
26} 27}
diff --git a/modules/grils/grils.go b/modules/grils/grils.go
index e2eb543..a38f41f 100644
--- a/modules/grils/grils.go
+++ b/modules/grils/grils.go
@@ -74,6 +74,26 @@ func (m *GrilsModule) getGrils(whereClause string, params ...interface{}) ([]*Gr
74 return grils, nil 74 return grils, nil
75} 75}
76 76
77func (m *GrilsModule) GetListsOfGril(gril *Gril) error {
78 rows, err := m.g.DB.Query(`SELECT list_id FROM grilist.lists_grils WHERE gril_id = $1`, gril.ID)
79 if err != nil {
80 return err
81 }
82
83 defer rows.Close()
84 for rows.Next() {
85 var listID int
86 if err := rows.Scan(&listID); err != nil {
87 log.Println(err)
88 continue
89 }
90
91 gril.Lists = append(gril.Lists, listID)
92 }
93
94 return nil
95}
96
77func (m *GrilsModule) ProvideDashboardData(user *charakterin.User) []grilist.DashboardCategory { 97func (m *GrilsModule) ProvideDashboardData(user *charakterin.User) []grilist.DashboardCategory {
78 var categories []grilist.DashboardCategory 98 var categories []grilist.DashboardCategory
79 99
@@ -137,6 +157,10 @@ func (m *GrilsModule) viewGril(w http.ResponseWriter, r *http.Request, p httprou
137 return 157 return
138 } 158 }
139 159
160 if err := m.GetListsOfGril(gril); err != nil {
161 log.Println(err)
162 }
163
140 data := m.g.Renderer.DefaultData() 164 data := m.g.Renderer.DefaultData()
141 data["user"] = user 165 data["user"] = user
142 data["gril"] = gril 166 data["gril"] = gril