X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FEditAlbumPage.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FEditAlbumPage.kt;h=aeaf14eeb9f53497af3eeabcbfb4f923ff80239c;hp=26d7c3a316d00d0285dea8833e7273b5f595619a;hb=03cec6a6772c2d836d94864adddaf544cbe9d72f;hpb=6f1f26e3998cfef155b0cf59152827accea70d30 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPage.kt index 26d7c3a..aeaf14e 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPage.kt @@ -1,41 +1,43 @@ package net.pterodactylus.sone.web.pages -import net.pterodactylus.sone.data.Album.Modifier.AlbumTitleMustNotBeEmpty -import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.utils.isPOST -import net.pterodactylus.sone.web.WebInterface -import net.pterodactylus.sone.web.page.FreenetRequest -import net.pterodactylus.util.template.Template -import net.pterodactylus.util.template.TemplateContext +import net.pterodactylus.sone.data.* +import net.pterodactylus.sone.data.Album.Modifier.* +import net.pterodactylus.sone.main.* +import net.pterodactylus.sone.utils.* +import net.pterodactylus.sone.web.* +import net.pterodactylus.sone.web.page.* +import net.pterodactylus.util.template.* +import javax.inject.* /** * Page that lets the user edit the name and description of an album. */ -class EditAlbumPage(template: Template, webInterface: WebInterface): - LoggedInPage("editAlbum.html", template, "Page.EditAlbum.Title", webInterface) { +@ToadletPath("editAlbum.html") +class EditAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : + LoggedInPage("Page.EditAlbum.Title", webInterface, loaders, templateRenderer) { - override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { - if (freenetRequest.isPOST) { - val album = webInterface.core.getAlbum(freenetRequest.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html") + override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) { + if (soneRequest.isPOST) { + val album = soneRequest.core.getAlbum(soneRequest.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html") album.takeUnless { it.sone.isLocal }?.run { throw RedirectException("noPermission.html") } - if (freenetRequest.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") { + if (soneRequest.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") { album.parent?.moveAlbumUp(album) - webInterface.core.touchConfiguration() + soneRequest.core.touchConfiguration() throw RedirectException("imageBrowser.html?album=${album.parent?.id}") - } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("moveRight", 4) == "true") { + } else if (soneRequest.httpRequest.getPartAsStringFailsafe("moveRight", 4) == "true") { album.parent?.moveAlbumDown(album) - webInterface.core.touchConfiguration() + soneRequest.core.touchConfiguration() throw RedirectException("imageBrowser.html?album=${album.parent?.id}") } else { try { album.modify() - .setTitle(freenetRequest.httpRequest.getPartAsStringFailsafe("title", 100)) - .setDescription(freenetRequest.httpRequest.getPartAsStringFailsafe("description", 1000)) + .setTitle(soneRequest.httpRequest.getPartAsStringFailsafe("title", 100)) + .setDescription(soneRequest.httpRequest.getPartAsStringFailsafe("description", 1000)) .update() } catch (e: AlbumTitleMustNotBeEmpty) { throw RedirectException("emptyAlbumTitle.html") } - webInterface.core.touchConfiguration() + soneRequest.core.touchConfiguration() throw RedirectException("imageBrowser.html?album=${album.id}") } }