diff options
Diffstat (limited to 'modules/lists')
-rw-r--r-- | modules/lists/lists.go | 36 |
1 files changed, 36 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 | ||