1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.data.*
4 import net.pterodactylus.sone.main.*
5 import net.pterodactylus.sone.utils.*
6 import net.pterodactylus.sone.web.*
7 import net.pterodactylus.sone.web.page.*
8 import net.pterodactylus.util.template.*
12 * Page that lets the user confirm the deletion of a profile field.
14 @TemplatePath("/templates/deleteProfileField.html")
15 @ToadletPath("deleteProfileField.html")
16 class DeleteProfileFieldPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
17 LoggedInPage("Page.DeleteProfileField.Title", webInterface, loaders, templateRenderer) {
19 override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
20 if (soneRequest.isPOST) {
21 val field = currentSone.profile.getFieldById(soneRequest.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html")
22 if (soneRequest.httpRequest.getPartAsStringFailsafe("confirm", 4) == "true") {
23 currentSone.profile = currentSone.profile.apply { removeField(field) }
25 throw RedirectException("editProfile.html#profile-fields")
27 val field = currentSone.profile.getFieldById(soneRequest.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html")
28 templateContext["field"] = field