add playlist deletion from web ui
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
@@ -117,3 +118,20 @@ func (c *Controller) ServeUploadPlaylistDo(r *http.Request) *Response {
|
||||
flashW: errors,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Controller) ServeDeletePlaylistDo(r *http.Request) *Response {
|
||||
user := r.Context().Value(CtxUser).(*db.User)
|
||||
id, err := strconv.Atoi(r.URL.Query().Get("id"))
|
||||
if err != nil {
|
||||
return &Response{
|
||||
err: "please provide a valid id",
|
||||
code: 400,
|
||||
}
|
||||
}
|
||||
c.DB.
|
||||
Where("user_id=? AND id=?", user.ID, id).
|
||||
Delete(db.Playlist{})
|
||||
return &Response{
|
||||
redirect: "/admin/home",
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user