Clean up some imports
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / DeleteImagePage.kt
index 183705a..de118be 100644 (file)
@@ -1,7 +1,6 @@
 package net.pterodactylus.sone.web.pages
 
 import net.pterodactylus.sone.utils.isPOST
-import net.pterodactylus.sone.web.pages.SoneTemplatePage
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.web.page.FreenetRequest
 import net.pterodactylus.util.template.Template
@@ -14,17 +13,21 @@ class DeleteImagePage(template: Template, webInterface: WebInterface):
                SoneTemplatePage("deleteImage.html", template, "Page.DeleteImage.Title", webInterface, true) {
 
        override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
-               val image = webInterface.core.getImage(request.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html")
-               if (!image.sone.isLocal) {
-                       throw RedirectException("noPermission.html")
-               }
                if (request.isPOST) {
+                       val image = webInterface.core.getImage(request.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html")
+                       if (!image.sone.isLocal) {
+                               throw RedirectException("noPermission.html")
+                       }
                        if (request.httpRequest.isPartSet("abortDelete")) {
                                throw RedirectException("imageBrowser.html?image=${image.id}")
                        }
                        webInterface.core.deleteImage(image)
                        throw RedirectException("imageBrowser.html?album=${image.album.id}")
                }
+               val image = webInterface.core.getImage(request.httpRequest.getParam("image")) ?: throw RedirectException("invalid.html")
+               if (!image.sone.isLocal) {
+                       throw RedirectException("noPermission.html")
+               }
                templateContext["image"] = image
        }