✨ Use @TemplatePath annotations on most pages
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / DeleteSonePage.kt
1 package net.pterodactylus.sone.web.pages
2
3 import net.pterodactylus.sone.data.Sone
4 import net.pterodactylus.sone.main.*
5 import net.pterodactylus.sone.utils.isPOST
6 import net.pterodactylus.sone.web.WebInterface
7 import net.pterodactylus.sone.web.page.*
8 import net.pterodactylus.util.template.Template
9 import net.pterodactylus.util.template.TemplateContext
10 import javax.inject.Inject
11
12 /**
13  * Lets the user delete a Sone. Of course the Sone is not really deleted from
14  * Freenet; merely all references to it are removed from the local plugin
15  * installation.
16  */
17 @MenuName("DeleteSone")
18 @TemplatePath("/templates/deleteSone.html")
19 class DeleteSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
20                 LoggedInPage("deleteSone.html", template, "Page.DeleteSone.Title", webInterface, loaders, templateRenderer) {
21
22         override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
23                 if (soneRequest.isPOST) {
24                         if (soneRequest.httpRequest.isPartSet("deleteSone")) {
25                                 soneRequest.core.deleteSone(currentSone)
26                         }
27                         throw RedirectException("index.html")
28                 }
29         }
30
31 }