29 lines
666 B
Go
Raw Normal View History

2017-06-28 15:55:08 +00:00
package editanime
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/utils"
2017-11-27 18:57:58 +00:00
"github.com/animenotifier/notify.moe/utils/editform"
2017-06-28 15:55:08 +00:00
)
// Get anime edit page.
func Get(ctx *aero.Context) string {
id := ctx.Get("id")
user := utils.GetUser(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusBadRequest, "Not logged in or not auhorized to edit this anime", nil)
}
anime, err := arn.GetAnime(id)
if err != nil {
return ctx.Error(http.StatusNotFound, "Anime not found", err)
}
2017-11-27 18:57:58 +00:00
return ctx.HTML(editform.Render(anime, "Edit anime", user))
2017-06-28 15:55:08 +00:00
}