From: David ‘Bombe’ Roden Date: Mon, 30 Jul 2012 12:57:44 +0000 (+0200) Subject: Add party management on track page. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=17fef4126099246a9fae942b49c50a4d41652d50;p=demoscenemusic.git Add party management on track page. --- 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>