plugins/caldav: add route to delete event
This commit is contained in:
parent
36f3fb9567
commit
7157627dcf
2 changed files with 25 additions and 1 deletions
|
@ -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>
|
||||
|
|
|
@ -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")
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue