Remove obsolete loading animation
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / DeleteImagePage.kt
1 package net.pterodactylus.sone.web
2
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
7
8 /**
9  * Page that lets the user delete an {@link Image}.
10  */
11 class DeleteImagePage(template: Template, webInterface: WebInterface):
12                 SoneTemplatePage("deleteImage.html", template, "Page.DeleteImage.Title", webInterface, true) {
13
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")
18                 }
19                 if (request.isPOST) {
20                         if (request.httpRequest.isPartSet("abortDelete")) {
21                                 throw RedirectException("imageBrowser.html?image=${image.id}")
22                         }
23                         webInterface.core.deleteImage(image)
24                         throw RedirectException("imageBrowser.html?album=${image.album.id}")
25                 }
26                 templateContext["image"] = image
27         }
28
29 }