X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FCreateAlbumPage.kt;h=2db3148bfd173806fff922f3a03c92f468c0c2e0;hb=9bb01bc8fe281e6748ebd744ade8945bee841213;hp=ee3936e1e9d558372ce1dd11a92a5000d8b03921;hpb=ffd92ca2374c0b2218e583d02e0bdd24b8c110ae;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateAlbumPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateAlbumPage.kt index ee3936e..2db3148 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateAlbumPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateAlbumPage.kt @@ -1,20 +1,22 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.sone.data.Album.Modifier.AlbumTitleMustNotBeEmpty +import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.text.TextFilter 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 javax.inject.Inject /** * Page that lets the user create a new album. */ -class CreateAlbumPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("createAlbum.html", template, "Page.CreateAlbum.Title", webInterface, true) { +class CreateAlbumPage @Inject constructor(template: Template, webInterface: WebInterface): + LoggedInPage("createAlbum.html", template, "Page.CreateAlbum.Title", webInterface) { - override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { if (freenetRequest.isPOST) { val name = freenetRequest.httpRequest.getPartAsStringFailsafe("name", 64).trim() if (name.isEmpty()) { @@ -22,7 +24,6 @@ class CreateAlbumPage(template: Template, webInterface: WebInterface): return } val description = freenetRequest.httpRequest.getPartAsStringFailsafe("description", 256).trim() - val currentSone = webInterface.getCurrentSoneCreatingSession(freenetRequest.toadletContext) val parentId = freenetRequest.httpRequest.getPartAsStringFailsafe("parent", 36) val parent = if (parentId == "") currentSone.rootAlbum else webInterface.core.getAlbum(parentId) val album = webInterface.core.createAlbum(currentSone, parent)