Added anime list deletion

This commit is contained in:
2019-08-29 14:08:32 +09:00
parent 1d6cdd3c9f
commit ede2c5dc75
6 changed files with 82 additions and 2 deletions

36
pages/animelist/delete.go Normal file
View File

@ -0,0 +1,36 @@
package animelist
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// DeleteConfirmation shows the confirmation page before deleting an anime list.
func DeleteConfirmation(ctx aero.Context) error {
user := utils.GetUser(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")
}
return ctx.HTML(components.DeleteAnimeList(user))
}
// Delete deletes your entire anime list.
func Delete(ctx aero.Context) error {
user := utils.GetUser(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")
}
animeList := user.AnimeList()
animeList.Lock()
animeList.Items = nil
animeList.Unlock()
return ctx.String("ok")
}

View File

@ -0,0 +1,9 @@
component DeleteAnimeList(user *arn.User)
h1.mountable Delete your anime list
p.text-center.mountable This will delete your entire anime list. Are you sure you want to proceed?
.buttons
button.action.mountable(data-action="deleteAnimeList", data-trigger="click", data-return-path="/+" + user.Nick + "/animelist/watching")
Icon("trash")
span Yes, delete my anime list.