X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FEditAlbumPage.java;h=fd4bf7c672ec7ed1462866cef6b744d7ce749e75;hb=7a14e6aab2b0458ee97452447845995bbf407ae7;hp=eaf8bf6efc354af74a74eb6717f18796df1aaaba;hpb=a23c4f218c3adf236d89d5927cae37d6e6e4feda;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java b/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java index eaf8bf6..fd4bf7c 100644 --- a/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java +++ b/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java @@ -18,22 +18,25 @@ package net.pterodactylus.sone.web; import net.pterodactylus.sone.data.Album; -import net.pterodactylus.sone.web.page.Page.Request.Method; +import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; +import net.pterodactylus.util.web.Method; /** - * TODO + * Page that lets the user edit the name and description of an album. * * @author David ‘Bombe’ Roden */ public class EditAlbumPage extends SoneTemplatePage { /** - * TODO + * Creates a new “edit album” page. * * @param template + * The template to render * @param webInterface + * The Sone web interface */ public EditAlbumPage(Template template, WebInterface webInterface) { super("editAlbum.html", template, "Page.EditAlbum.Title", webInterface, true); @@ -43,7 +46,7 @@ public class EditAlbumPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { + protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); if (request.getMethod() == Method.POST) { String albumId = request.getHttpRequest().getPartAsStringFailsafe("album", 36); @@ -54,6 +57,11 @@ public class EditAlbumPage extends SoneTemplatePage { if (!webInterface.getCore().isLocalSone(album.getSone())) { throw new RedirectException("noPermission.html"); } + String albumImageId = request.getHttpRequest().getPartAsStringFailsafe("album-image", 36); + if (webInterface.getCore().getImage(albumImageId, false) == null) { + albumImageId = null; + } + album.setAlbumImage(albumImageId); String title = request.getHttpRequest().getPartAsStringFailsafe("title", 100).trim(); if (title.length() == 0) { templateContext.set("titleMissing", true); @@ -61,7 +69,7 @@ public class EditAlbumPage extends SoneTemplatePage { } String description = request.getHttpRequest().getPartAsStringFailsafe("description", 1000).trim(); album.setTitle(title).setDescription(description); - webInterface.getCore().saveSone(album.getSone()); + webInterface.getCore().touchConfiguration(); throw new RedirectException("imageBrowser.html?album=" + album.getId()); } }