From 49f7ec4e634c22c07df461b45840e6bd0830a88b Mon Sep 17 00:00:00 2001 From: jan Date: Mon, 10 Oct 2016 12:27:27 +0200 Subject: view fuer list settings 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) { m.g.Router.POST("/list/:id/order", m.updateGrilOrder) m.g.Router.POST("/list/:id", m.addGrilToList) m.g.Router.DELETE("/list/:id/order", m.removeGrilFromList) + m.g.Router.GET("/list/:id/settings", m.viewListSettings) m.g.Router.GET("/new/list", m.displayCreateList) m.g.Router.POST("/new/list", m.createList) @@ -285,6 +286,41 @@ func (m *Module) viewList(w http.ResponseWriter, r *http.Request, p httprouter.P m.g.Renderer.RenderPage("list", w, data) } +func (m *Module) viewListSettings(w http.ResponseWriter, r *http.Request, p httprouter.Params) { + user, err := m.g.Charakterin.GetUserFromRequest(r) + if err != nil { + log.Println("invalid viewListSettings user") + http.Redirect(w, r, fmt.Sprintf("/list/%s", p.ByName("id")), 403) + return + } + + id, err := strconv.Atoi(p.ByName("id")) + if err != nil { + log.Println("invalid viewListSettings ID") + http.Redirect(w, r, "/", 400) + return + } + + list, err := m.FromID(id, false) + if err != nil { + log.Println("invalid viewListSettings ID (could not get list)") + http.Redirect(w, r, fmt.Sprintf("/list/%d", id), 500) + return + } + + // checken, ob der user auch list owner ist + if user.ID != list.Owner.ID { + log.Println("invalid viewListSettings request: user not list owner") + http.Redirect(w, r, fmt.Sprintf("/list/%d", id), 403) + return + } + + data := m.g.Renderer.DefaultData() + data["user"] = user + data["list"] = list + m.g.Renderer.RenderPage("list_settings", w, data) +} + func (m *Module) addGrilToList(w http.ResponseWriter, r *http.Request, p httprouter.Params) { slistID := p.ByName("id") 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 @@ +{{ define "list_settings" }} + + + {{ template "materialize" }} + {{ template "materialize_js" }} + + {{ .list.Name }} Einstellungen - grilist + + + + {{ template "navbar" . }} +
+

Listeneinstellungen

+
+
+ {{ if .error }} +
+
+
+ Fehler +

Es gab einen Fehler: {{ .error }}

+
+
+
+ {{ end }} +
+
+ assignment_ind + +
+
+ mode_edit + + +
+
+
+ +
+
+
+
+
+
+ + +{{ end }} -- cgit v0.10.1