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