X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FEditAlbumPage.kt;h=4569e9a18157157c64ddabc907b417ac8316cec2;hp=6762332b126709bd6a56e8b4e764bd61fc6289ea;hb=faf66247a34f64946990a985d2ea3003465969cb;hpb=a76956e389fcfe6282ad4ca7156bbf76327bb0c0 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 6762332..4569e9a 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPage.kt @@ -12,21 +12,22 @@ import javax.inject.* /** * Page that lets the user edit the name and description of an album. */ -class EditAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer): - LoggedInPage("editAlbum.html", "Page.EditAlbum.Title", webInterface, loaders, templateRenderer) { +@ToadletPath("editAlbum.html") +class EditAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : + LoggedInPage("Page.EditAlbum.Title", webInterface, loaders, templateRenderer) { 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") } + val album = soneRequest.core.getAlbum(soneRequest.httpRequest.getPartAsStringFailsafe("album", 36)) ?: redirectTo("invalid.html") + album.takeUnless { it.sone.isLocal }?.run { redirectTo("noPermission.html") } if (soneRequest.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") { album.parent?.moveAlbumUp(album) soneRequest.core.touchConfiguration() - throw RedirectException("imageBrowser.html?album=${album.parent?.id}") + redirectTo("imageBrowser.html?album=${album.parent?.id}") } else if (soneRequest.httpRequest.getPartAsStringFailsafe("moveRight", 4) == "true") { album.parent?.moveAlbumDown(album) soneRequest.core.touchConfiguration() - throw RedirectException("imageBrowser.html?album=${album.parent?.id}") + redirectTo("imageBrowser.html?album=${album.parent?.id}") } else { try { album.modify() @@ -34,10 +35,10 @@ class EditAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loa .setDescription(soneRequest.httpRequest.getPartAsStringFailsafe("description", 1000)) .update() } catch (e: AlbumTitleMustNotBeEmpty) { - throw RedirectException("emptyAlbumTitle.html") + redirectTo("emptyAlbumTitle.html") } soneRequest.core.touchConfiguration() - throw RedirectException("imageBrowser.html?album=${album.id}") + redirectTo("imageBrowser.html?album=${album.id}") } } }