From 17fef4126099246a9fae942b49c50a4d41652d50 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 30 Jul 2012 14:57:44 +0200 Subject: [PATCH] Add party management on track page. --- .../demoscenemusic/page/admin/EditTrackPage.java | 30 +++++++++++++++++--- src/main/resources/templates/admin.edit-track | 33 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/pterodactylus/demoscenemusic/page/admin/EditTrackPage.java b/src/main/java/net/pterodactylus/demoscenemusic/page/admin/EditTrackPage.java index af02681..c8a9be2 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/page/admin/EditTrackPage.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/page/admin/EditTrackPage.java @@ -17,7 +17,10 @@ package net.pterodactylus.demoscenemusic.page.admin; +import java.util.Collection; + import net.pterodactylus.demoscenemusic.core.Core; +import net.pterodactylus.demoscenemusic.data.Party; import net.pterodactylus.demoscenemusic.data.Track; import net.pterodactylus.demoscenemusic.page.ServletRequest; import net.pterodactylus.util.database.DatabaseException; @@ -68,12 +71,31 @@ public class EditTrackPage extends AdminBasePage { templateContext.set("track", track); if (request.getMethod() == Method.POST) { - String name = request.getServletRequest().getParameter("name").trim(); - if (name.length() > 0) { + + /* check if a party should be removed. */ + if ("true".equals(request.getServletRequest().getParameter("delete-party"))) { + String partyId = request.getServletRequest().getParameter("party"); + Party party = getCore().getDataManager().getPartyById(partyId); + Collection parties = track.getParties(); + parties.remove(party); + track.setParties(parties); + } + + /* check if a party should be added. */ + if ("true".equals(request.getServletRequest().getParameter("add-party"))) { + String partyId = request.getServletRequest().getParameter("party"); + Party party = getCore().getDataManager().getPartyById(partyId); + Collection parties = track.getParties(); + parties.add(party); + track.setParties(parties); + } + + String name = request.getServletRequest().getParameter("name"); + if ((name != null) && (name.trim().length() > 0)) { track.setName(name); } - String remix = request.getServletRequest().getParameter("remix").trim(); - if (remix.length() > 0) { + String remix = request.getServletRequest().getParameter("remix"); + if ((remix != null) && (remix.trim().length() > 0)) { track.setRemix(remix); } diff --git a/src/main/resources/templates/admin.edit-track b/src/main/resources/templates/admin.edit-track index c03d01d..cc535b9 100644 --- a/src/main/resources/templates/admin.edit-track +++ b/src/main/resources/templates/admin.edit-track @@ -37,6 +37,39 @@ +

Parties

+ +<%foreach track.parties party> + +
Released at: <%party.name|html>
+ +
+ + + +
+ +<%/foreach> + +

Add Party

+ +
+ + + +
+ Add Release: + +
+ + + +
+

Derivatives

<%foreach track.derivatives derivative> -- 2.7.4