1 package net.pterodactylus.sone.web
3 import net.pterodactylus.sone.utils.isPOST
4 import net.pterodactylus.sone.web.page.FreenetRequest
5 import net.pterodactylus.util.template.Template
6 import net.pterodactylus.util.template.TemplateContext
9 * Page that lets the user delete an {@link Image}.
11 class DeleteImagePage(template: Template, webInterface: WebInterface):
12 SoneTemplatePage("deleteImage.html", template, "Page.DeleteImage.Title", webInterface, true) {
14 override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
15 val image = webInterface.core.getImage(request.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html")
16 if (!image.sone.isLocal) {
17 throw RedirectException("noPermission.html")
20 if (request.httpRequest.isPartSet("abortDelete")) {
21 throw RedirectException("imageBrowser.html?image=${image.id}")
23 webInterface.core.deleteImage(image)
24 throw RedirectException("imageBrowser.html?album=${image.album.id}")
26 templateContext["image"] = image