diff options
-rw-r--r-- | modules/lists/lists.go | 36 | ||||
-rw-r--r-- | views/pages/list_settings.html | 49 |
2 files changed, 85 insertions, 0 deletions
diff --git a/modules/lists/lists.go b/modules/lists/lists.go index a219bcc..73a3fe7 100644 --- a/modules/lists/lists.go +++ b/modules/lists/lists.go | |||
@@ -75,6 +75,7 @@ func (m *Module) Init(g *grilist.Grilist) { | |||
75 | m.g.Router.POST("/list/:id/order", m.updateGrilOrder) | 75 | m.g.Router.POST("/list/:id/order", m.updateGrilOrder) |
76 | m.g.Router.POST("/list/:id", m.addGrilToList) | 76 | m.g.Router.POST("/list/:id", m.addGrilToList) |
77 | m.g.Router.DELETE("/list/:id/order", m.removeGrilFromList) | 77 | m.g.Router.DELETE("/list/:id/order", m.removeGrilFromList) |
78 | m.g.Router.GET("/list/:id/settings", m.viewListSettings) | ||
78 | m.g.Router.GET("/new/list", m.displayCreateList) | 79 | m.g.Router.GET("/new/list", m.displayCreateList) |
79 | m.g.Router.POST("/new/list", m.createList) | 80 | m.g.Router.POST("/new/list", m.createList) |
80 | 81 | ||
@@ -285,6 +286,41 @@ func (m *Module) viewList(w http.ResponseWriter, r *http.Request, p httprouter.P | |||
285 | m.g.Renderer.RenderPage("list", w, data) | 286 | m.g.Renderer.RenderPage("list", w, data) |
286 | } | 287 | } |
287 | 288 | ||
289 | func (m *Module) viewListSettings(w http.ResponseWriter, r *http.Request, p httprouter.Params) { | ||
290 | user, err := m.g.Charakterin.GetUserFromRequest(r) | ||
291 | if err != nil { | ||
292 | log.Println("invalid viewListSettings user") | ||
293 | http.Redirect(w, r, fmt.Sprintf("/list/%s", p.ByName("id")), 403) | ||
294 | return | ||
295 | } | ||
296 | |||
297 | id, err := strconv.Atoi(p.ByName("id")) | ||
298 | if err != nil { | ||
299 | log.Println("invalid viewListSettings ID") | ||
300 | http.Redirect(w, r, "/", 400) | ||
301 | return | ||
302 | } | ||
303 | |||
304 | list, err := m.FromID(id, false) | ||
305 | if err != nil { | ||
306 | log.Println("invalid viewListSettings ID (could not get list)") | ||
307 | http.Redirect(w, r, fmt.Sprintf("/list/%d", id), 500) | ||
308 | return | ||
309 | } | ||
310 | |||
311 | // checken, ob der user auch list owner ist | ||
312 | if user.ID != list.Owner.ID { | ||
313 | log.Println("invalid viewListSettings request: user not list owner") | ||
314 | http.Redirect(w, r, fmt.Sprintf("/list/%d", id), 403) | ||
315 | return | ||
316 | } | ||
317 | |||
318 | data := m.g.Renderer.DefaultData() | ||
319 | data["user"] = user | ||
320 | data["list"] = list | ||
321 | m.g.Renderer.RenderPage("list_settings", w, data) | ||
322 | } | ||
323 | |||
288 | func (m *Module) addGrilToList(w http.ResponseWriter, r *http.Request, p httprouter.Params) { | 324 | func (m *Module) addGrilToList(w http.ResponseWriter, r *http.Request, p httprouter.Params) { |
289 | slistID := p.ByName("id") | 325 | slistID := p.ByName("id") |
290 | 326 | ||
diff --git a/views/pages/list_settings.html b/views/pages/list_settings.html new file mode 100644 index 0000000..0ce3860 --- /dev/null +++ b/views/pages/list_settings.html | |||
@@ -0,0 +1,49 @@ | |||
1 | {{ define "list_settings" }} | ||
2 | <html> | ||
3 | <head> | ||
4 | {{ template "materialize" }} | ||
5 | {{ template "materialize_js" }} | ||
6 | <link rel="stylesheet" href="/assets/css/list.css" /> | ||
7 | <title>{{ .list.Name }} Einstellungen - grilist</title> | ||
8 | <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> | ||
9 | </head> | ||
10 | <body> | ||
11 | {{ template "navbar" . }} | ||
12 | <div class="container"> | ||
13 | <h1>Listeneinstellungen</h1> | ||
14 | <div class="row"> | ||
15 | <div class="col s12 m6 offset-m3 l4 offset-l4"> | ||
16 | {{ if .error }} | ||
17 | <div class="col s12 m8 offset-m2"> | ||
18 | <div class="card red lighten-2"> | ||
19 | <div class="card-content white-text"> | ||
20 | <span class="card-title">Fehler</span> | ||
21 | <p>Es gab einen Fehler: {{ .error }}</p> | ||
22 | </div> | ||
23 | </div> | ||
24 | </div> | ||
25 | {{ end }} | ||
26 | <form method="POST" name="list" action="#"> | ||
27 | <div class="input-field col s12"> | ||
28 | <i class="material-icons prefix">assignment_ind</i> | ||
29 | <input name="name" type="text" placeholder="Name" class="validate" value="{{ .list.Name }}"/> | ||
30 | </div> | ||
31 | <div class="input-field col s12"> | ||
32 | <i class="material-icons prefix">mode_edit</i> | ||
33 | <textarea id="description" name="description" class="materialize-textarea">{{ .list.Description }}</textarea> | ||
34 | <label for="description">Beschreibung</label> | ||
35 | </div> | ||
36 | <div class="col s12"> | ||
37 | <div class="right-align"> | ||
38 | <button class="btn waves-effect waves-light purple lighten-2" type="submit" name="action"> | ||
39 | Speichern <i class="material-icons right">send</i> | ||
40 | </button> | ||
41 | </div> | ||
42 | </div> | ||
43 | </form> | ||
44 | </div> | ||
45 | </div> | ||
46 | </div> | ||
47 | </body> | ||
48 | </html> | ||
49 | {{ end }} | ||