From b46c72a602cc9b3780c6f01f4275703e6b3e5b2e Mon Sep 17 00:00:00 2001 From: jan Date: Tue, 29 Dec 2015 19:52:53 +0100 Subject: =?UTF-8?q?wip:=20richtige=20liste=20f=C3=BCr=20grils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit diff --git a/modules/lists/lists.go b/modules/lists/lists.go index dcc7046..94d4030 100644 --- a/modules/lists/lists.go +++ b/modules/lists/lists.go @@ -34,8 +34,9 @@ type List struct { // ListGril ist ein geranktes Gril type ListGril struct { - Gril *grils.Gril - Order int + Gril *grils.Gril + Order int + ImagePath string } // Name gibt den Namen des Moduls zurück @@ -91,7 +92,7 @@ func (m *Module) getListGrils(list *List) error { func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, error) { var lists []*List - rows, err := m.g.DB.Query(fmt.Sprintf(`SELECT id, name, description, fork_of, updated_at FROM grilist.lists WHERE %s`, whereClause), params...) + 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...) if err != nil { return nil, err } @@ -99,8 +100,8 @@ func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, e defer rows.Close() for rows.Next() { list := &List{} - - if err := rows.Scan(&list.ID, &list.Name, &list.Description, &list.ForkOf, &list.UpdatedAt); err != nil { + var ownerID int + if err := rows.Scan(&list.ID, &list.Name, &list.Description, &list.ForkOf, &list.UpdatedAt, &ownerID); err != nil { log.Println("error scanning row in getLists:", err) continue } @@ -110,6 +111,14 @@ func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, e continue } + // Owner kriegn + owner, err := m.g.Charakterin.GetUserByID(ownerID) + if err != nil { + log.Println("error retreiving owner of list", err) + continue + } + list.Owner = owner + lists = append(lists, list) } diff --git a/views/list.html b/views/list.html index fb5f7a3..8fc7694 100644 --- a/views/list.html +++ b/views/list.html @@ -1,22 +1,59 @@ {{ define "list" }} {{ $list := .list }} - - {{ template "materialize" }} - grilist - - - - - {{ template "navbar" . }} -
-

{{ $list.Name }}von xyz


- -
- + + {{ template "materialize" }} + grilist + + + + + + {{ template "navbar" . }} +
+

{{ $list.Name }}von {{ $list.Owner.GetName }}


+ +
+ {{ end }} \ No newline at end of file diff --git a/views/navbar.html b/views/navbar.html index 70911e4..8905a1d 100644 --- a/views/navbar.html +++ b/views/navbar.html @@ -4,7 +4,7 @@