diff options
author | Simon Ser <contact@emersion.fr> | 2020-05-20 16:54:33 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-05-20 16:54:33 +0200 |
commit | 7157627dcfdec4c2f0da5e497f9a1988cd3c60cc (patch) | |
tree | dbf39dfa30394f55cb86eb6658a2baf07187bd19 /plugins | |
parent | 36f3fb9567fad51e54c11d7d7cb4c30ad3b17db2 (diff) | |
download | alps-7157627dcfdec4c2f0da5e497f9a1988cd3c60cc.tar.gz alps-7157627dcfdec4c2f0da5e497f9a1988cd3c60cc.zip |
plugins/caldav: add route to delete event
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/caldav/public/event.html | 8 | ||||
-rw-r--r-- | plugins/caldav/routes.go | 18 |
2 files changed, 25 insertions, 1 deletions
diff --git a/plugins/caldav/public/event.html b/plugins/caldav/public/event.html index de755d8..3192344 100644 --- a/plugins/caldav/public/event.html +++ b/plugins/caldav/public/event.html @@ -4,13 +4,19 @@ <p> <a href="/calendar">Back</a> - ยท <a href="{{.Event.URL}}/update">Edit</a> </p> {{$event := index .Event.Data.Events 0}} <h2>Event: {{$event.Props.Text "SUMMARY"}}</h2> +<p> + <a href="{{.Event.URL}}/update">Edit</a> + <form action="{{.Event.URL}}/delete" method="post"> + <input type="submit" value="Delete"> + </form> +</p> + <ul> <li><strong>Start date</strong>: {{$event.DateTimeStart nil | formatdate}}</li> <li><strong>End date</strong>: {{$event.DateTimeEnd nil | formatdate}}</li> diff --git a/plugins/caldav/routes.go b/plugins/caldav/routes.go index 020882e..52f8d31 100644 --- a/plugins/caldav/routes.go +++ b/plugins/caldav/routes.go @@ -239,4 +239,22 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) { p.GET("/calendar/:path/update", updateEvent) p.POST("/calendar/:path/update", updateEvent) + + p.POST("/calendar/:path/delete", func(ctx *alps.Context) error { + path, err := parseObjectPath(ctx.Param("path")) + if err != nil { + return err + } + + c, _, err := getCalendar(u, ctx.Session) + if err != nil { + return err + } + + if err := c.RemoveAll(path); err != nil { + return fmt.Errorf("failed to delete calendar object: %v", err) + } + + return ctx.Redirect(http.StatusFound, "/calendar") + }) } |