31 lines
770 B
Go
Raw Normal View History

2017-06-27 18:12:08 +00:00
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)
}
2017-11-18 10:37:29 +00:00
tracks := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
2017-10-15 18:19:45 +00:00
return !track.IsDraft && len(track.Media) > 0 && track.CreatedBy == viewUser.ID
})
2017-06-27 18:12:08 +00:00
arn.SortSoundTracksLatestFirst(tracks)
2017-07-06 01:24:56 +00:00
return ctx.HTML(components.TrackList(tracks, viewUser, user, ctx.URI()))
2017-06-27 18:12:08 +00:00
}