X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDeleteAlbumPage.kt;h=0669aa49544289072888f93d37c98e2423c54900;hp=02a0f6550a69c52e1c7553a0819c81d1102b89f5;hb=110a933c2724aba6a604fc5eed6372ff1e1e6144;hpb=e1ea69b3822aefc6d1dd1f1cebe30980f79ae021 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt index 02a0f65..0669aa4 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt @@ -1,32 +1,33 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.sone.data.Sone +import net.pterodactylus.sone.main.* import net.pterodactylus.sone.utils.isPOST import net.pterodactylus.sone.web.WebInterface -import net.pterodactylus.sone.web.page.FreenetRequest -import net.pterodactylus.util.template.Template +import net.pterodactylus.sone.web.page.* import net.pterodactylus.util.template.TemplateContext import javax.inject.Inject /** * Page that lets the user delete an {@link Album}. */ -class DeleteAlbumPage @Inject constructor(template: Template, webInterface: WebInterface): - LoggedInPage("deleteAlbum.html", template, "Page.DeleteAlbum.Title", webInterface) { +@TemplatePath("/templates/deleteAlbum.html") +class DeleteAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer): + LoggedInPage("deleteAlbum.html", "Page.DeleteAlbum.Title", webInterface, loaders, templateRenderer) { - override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { - if (freenetRequest.isPOST) { - val album = webInterface.core.getAlbum(freenetRequest.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html") + override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) { + if (soneRequest.isPOST) { + val album = soneRequest.core.getAlbum(soneRequest.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html") if (!album.sone.isLocal) { throw RedirectException("noPermission.html") } - if (freenetRequest.httpRequest.getPartAsStringFailsafe("abortDelete", 4) == "true") { + if (soneRequest.httpRequest.getPartAsStringFailsafe("abortDelete", 4) == "true") { throw RedirectException("imageBrowser.html?album=${album.id}") } - webInterface.core.deleteAlbum(album) + soneRequest.core.deleteAlbum(album) throw RedirectException(if (album.parent.isRoot) "imageBrowser.html?sone=${album.sone.id}" else "imageBrowser.html?album=${album.parent.id}") } - val album = webInterface.core.getAlbum(freenetRequest.httpRequest.getParam("album")) + val album = soneRequest.core.getAlbum(soneRequest.httpRequest.getParam("album")) templateContext["album"] = album ?: throw RedirectException("invalid.html") }