972e4440f1537d954e767966ff2045edfd4959f4
[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.utils.isPOST
5 import net.pterodactylus.sone.web.WebInterface
6 import net.pterodactylus.sone.web.page.*
7 import net.pterodactylus.util.template.Template
8 import net.pterodactylus.util.template.TemplateContext
9 import javax.inject.Inject
10
11 /**
12  * Lets the user delete a Sone. Of course the Sone is not really deleted from
13  * Freenet; merely all references to it are removed from the local plugin
14  * installation.
15  */
16 @MenuName("DeleteSone")
17 class DeleteSonePage @Inject constructor(template: Template, webInterface: WebInterface):
18                 LoggedInPage("deleteSone.html", template, "Page.DeleteSone.Title", webInterface) {
19
20         override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
21                 if (soneRequest.isPOST) {
22                         if (soneRequest.httpRequest.isPartSet("deleteSone")) {
23                                 soneRequest.core.deleteSone(currentSone)
24                         }
25                         throw RedirectException("index.html")
26                 }
27         }
28
29 }