Added list of all tracks by one user

This commit is contained in:
2017-06-27 20:12:08 +02:00
parent 9ce39df2eb
commit c1765a23ea
4 changed files with 41 additions and 1 deletions

32
pages/profile/tracks.go Normal file
View File

@ -0,0 +1,32 @@
package profile
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// GetSoundTracksByUser shows all soundtracks of a particular user.
func GetSoundTracksByUser(ctx *aero.Context) string {
nick := ctx.Get("nick")
user := utils.GetUser(ctx)
viewUser, err := arn.GetUserByNick(nick)
if err != nil {
return ctx.Error(http.StatusNotFound, "User not found", err)
}
tracks, err := arn.GetSoundTracksByUser(viewUser)
if err != nil {
return ctx.Error(http.StatusInternalServerError, "Error fetching soundtracks", err)
}
arn.SortSoundTracksLatestFirst(tracks)
return ctx.HTML(components.TrackList(tracks, viewUser, user))
}