✨ Annotate IndexPage with MenuName
[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.*
6 import net.pterodactylus.util.template.Template
7 import net.pterodactylus.util.template.TemplateContext
8 import javax.inject.Inject
9
10 /**
11  * This page lets the user lock a [net.pterodactylus.sone.data.Sone] to prevent it from being inserted.
12  */
13 class LockSonePage @Inject constructor(template: Template, webInterface: WebInterface):
14                 SoneTemplatePage("lockSone.html", webInterface, template, "Page.LockSone.Title") {
15
16         override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
17                 soneRequest.parameters["returnPage", 256]!!.let { returnPage ->
18                         soneRequest.parameters["sone", 44]!!
19                                         .let { soneRequest.core.getLocalSone(it) }
20                                         ?.let { soneRequest.core.lockSone(it) }
21                         throw RedirectException(returnPage)
22                 }
23         }
24
25 }