Replace delete profile field ajax page with Kotlin version
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / LockSonePage.kt
1 package net.pterodactylus.sone.web.pages
2
3 import net.pterodactylus.sone.utils.parameters
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  * This page lets the user lock a [net.pterodactylus.sone.data.Sone] to prevent it from being inserted.
11  */
12 class LockSonePage(template: Template, webInterface: WebInterface):
13                 SoneTemplatePage("lockSone.html", template, "Page.LockSone.Title", webInterface, false) {
14
15         override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
16                 request.parameters["returnPage", 256]!!.let { returnPage ->
17                         request.parameters["sone", 44]!!
18                                         .let { webInterface.core.getLocalSone(it) }
19                                         ?.let { webInterface.core.lockSone(it) }
20                         throw RedirectException(returnPage)
21                 }
22         }
23
24 }