move admin playlist handlers to own file
This commit is contained in:
@@ -274,36 +274,6 @@ func (c *Controller) ServeStartScanDo(r *http.Request) *Response {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) ServeUploadPlaylist(r *http.Request) *Response {
|
|
||||||
return &Response{template: "upload_playlist.tmpl"}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Controller) ServeUploadPlaylistDo(r *http.Request) *Response {
|
|
||||||
if err := r.ParseMultipartForm((1 << 10) * 24); nil != err {
|
|
||||||
return &Response{
|
|
||||||
err: "couldn't parse mutlipart",
|
|
||||||
code: 500,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
user := r.Context().Value(CtxUser).(*db.User)
|
|
||||||
var playlistCount int
|
|
||||||
var errors []string
|
|
||||||
for _, headers := range r.MultipartForm.File {
|
|
||||||
for _, header := range headers {
|
|
||||||
headerErrors, created := playlistParseUpload(c, user.ID, header)
|
|
||||||
if created {
|
|
||||||
playlistCount++
|
|
||||||
}
|
|
||||||
errors = append(errors, headerErrors...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return &Response{
|
|
||||||
redirect: "/admin/home",
|
|
||||||
flashN: []string{fmt.Sprintf("%d playlist(s) created", playlistCount)},
|
|
||||||
flashW: errors,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Controller) ServeCreateTranscodePrefDo(r *http.Request) *Response {
|
func (c *Controller) ServeCreateTranscodePrefDo(r *http.Request) *Response {
|
||||||
client := r.FormValue("client")
|
client := r.FormValue("client")
|
||||||
profile := r.FormValue("profile")
|
profile := r.FormValue("profile")
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
@@ -71,3 +72,33 @@ func playlistParseUpload(c *Controller, userID int, header *multipart.FileHeader
|
|||||||
c.DB.Save(playlist)
|
c.DB.Save(playlist)
|
||||||
return errors, true
|
return errors, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Controller) ServeUploadPlaylist(r *http.Request) *Response {
|
||||||
|
return &Response{template: "upload_playlist.tmpl"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Controller) ServeUploadPlaylistDo(r *http.Request) *Response {
|
||||||
|
if err := r.ParseMultipartForm((1 << 10) * 24); nil != err {
|
||||||
|
return &Response{
|
||||||
|
err: "couldn't parse mutlipart",
|
||||||
|
code: 500,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
user := r.Context().Value(CtxUser).(*db.User)
|
||||||
|
var playlistCount int
|
||||||
|
var errors []string
|
||||||
|
for _, headers := range r.MultipartForm.File {
|
||||||
|
for _, header := range headers {
|
||||||
|
headerErrors, created := playlistParseUpload(c, user.ID, header)
|
||||||
|
if created {
|
||||||
|
playlistCount++
|
||||||
|
}
|
||||||
|
errors = append(errors, headerErrors...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &Response{
|
||||||
|
redirect: "/admin/home",
|
||||||
|
flashN: []string{fmt.Sprintf("%d playlist(s) created", playlistCount)},
|
||||||
|
flashW: errors,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
// a) write to response writer
|
// a) write to response writer
|
||||||
// b) return a non-nil spec.Response
|
// b) return a non-nil spec.Response
|
||||||
// _but not both_
|
// _but not both_
|
||||||
|
|
||||||
func (c *Controller) ServeGetCoverArt(w http.ResponseWriter, r *http.Request) *spec.Response {
|
func (c *Controller) ServeGetCoverArt(w http.ResponseWriter, r *http.Request) *spec.Response {
|
||||||
params := r.Context().Value(CtxParams).(params.Params)
|
params := r.Context().Value(CtxParams).(params.Params)
|
||||||
id, err := params.GetInt("id")
|
id, err := params.GetInt("id")
|
||||||
|
|||||||
Reference in New Issue
Block a user