Added anime edit page

This commit is contained in:
2017-06-28 17:55:08 +02:00
parent de46187216
commit ba24b6e2d0
6 changed files with 90 additions and 2 deletions

View File

@ -0,0 +1,28 @@
package editanime
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// 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)
}
return ctx.HTML(components.EditAnime(anime))
}

View File

@ -0,0 +1,7 @@
component EditAnime(anime *arn.Anime)
h2= anime.Title.Canonical
.widgets
.widget(data-api="/api/anime/" + anime.ID)
h3.anime-section-name Mappings
InputText("ShoboiID", anime.GetMapping("shoboi/anime"), "Shoboi TID", "TID on http://cal.syoboi.jp")