diff options
author | jan <jan@ruken.pw> | 2015-12-28 11:23:30 (UTC) |
---|---|---|
committer | jan <jan@ruken.pw> | 2015-12-28 11:23:30 (UTC) |
commit | 647c105dadfa58af6cfa80d3f359d43cfa5d5cf2 (patch) | |
tree | 895a68bcfc5f66da7bcfcdea5fe686f742e8cc21 /modules/grils | |
parent | 0891a94767cafc13307482cd0c4f76db3bcc3b5e (diff) |
anzeige im gril view, in wie vielen listen das gril vorkommt
Diffstat (limited to 'modules/grils')
-rw-r--r-- | modules/grils/gril.go | 1 | ||||
-rw-r--r-- | modules/grils/grils.go | 24 |
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 | ||
77 | func (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 | |||
77 | func (m *GrilsModule) ProvideDashboardData(user *charakterin.User) []grilist.DashboardCategory { | 97 | func (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 |