Commit 9029146c by Antti Tonkyra

Tournament stuff

- viewing own participations (captain)
- deleting own participation
- able to change tournament parameters from management side
- i18n stuff
1 parent 2528830b
...@@ -131,6 +131,7 @@ public class MenuBean implements MenuBeanLocal { ...@@ -131,6 +131,7 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation tournaments = usermenu.addPage(null, null); MenuNavigation tournaments = usermenu.addPage(null, null);
tournaments.setKey("tournaments.menutitle"); tournaments.setKey("tournaments.menutitle");
tournaments.addPage(menuitemfacade.findOrCreate("/tournaments/index"), TournamentPermission.VIEW); tournaments.addPage(menuitemfacade.findOrCreate("/tournaments/index"), TournamentPermission.VIEW);
tournaments.addPage(menuitemfacade.findOrCreate("/tournaments/myparticipations"), TournamentPermission.VIEW);
tournaments.addPage(menuitemfacade.findOrCreate("/tournaments/showrules"), TournamentPermission.VIEW).setVisible(false); tournaments.addPage(menuitemfacade.findOrCreate("/tournaments/showrules"), TournamentPermission.VIEW).setVisible(false);
tournaments.addPage(menuitemfacade.findOrCreate("/tournaments/participate_single"), TournamentPermission.PARTICIPATE).setVisible(false); tournaments.addPage(menuitemfacade.findOrCreate("/tournaments/participate_single"), TournamentPermission.PARTICIPATE).setVisible(false);
tournaments.addPage(menuitemfacade.findOrCreate("/tournaments/participate_multi"), TournamentPermission.PARTICIPATE).setVisible(false); tournaments.addPage(menuitemfacade.findOrCreate("/tournaments/participate_multi"), TournamentPermission.PARTICIPATE).setVisible(false);
......
...@@ -16,6 +16,7 @@ import fi.codecrew.moya.facade.TournamentFacade; ...@@ -16,6 +16,7 @@ import fi.codecrew.moya.facade.TournamentFacade;
import fi.codecrew.moya.facade.TournamentGameFacade; import fi.codecrew.moya.facade.TournamentGameFacade;
import fi.codecrew.moya.facade.TournamentParticipantFacade; import fi.codecrew.moya.facade.TournamentParticipantFacade;
import fi.codecrew.moya.facade.TournamentRuleFacade; import fi.codecrew.moya.facade.TournamentRuleFacade;
import fi.codecrew.moya.facade.TournamentTeamMemberFacade;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Tournament; import fi.codecrew.moya.model.Tournament;
import fi.codecrew.moya.model.TournamentGame; import fi.codecrew.moya.model.TournamentGame;
...@@ -42,6 +43,10 @@ public class TournamentBean implements TournamentBeanLocal { ...@@ -42,6 +43,10 @@ public class TournamentBean implements TournamentBeanLocal {
private EventUserFacade eventUserFacade; private EventUserFacade eventUserFacade;
@EJB @EJB
private EventBean eventBean; private EventBean eventBean;
@EJB
private PermissionBean permissionBean;
@EJB
private TournamentTeamMemberFacade tournamentTeamMemberFacade;
/** /**
* Default constructor. * Default constructor.
...@@ -188,6 +193,14 @@ public class TournamentBean implements TournamentBeanLocal { ...@@ -188,6 +193,14 @@ public class TournamentBean implements TournamentBeanLocal {
@Override @Override
@RolesAllowed(TournamentPermission.S_VIEW) @RolesAllowed(TournamentPermission.S_VIEW)
public List<TournamentParticipant> findOwnParticipations() {
EventUser currentUser = permissionBean.getCurrentUser();
return tournamentParticipantFacade.findByParticipator(currentUser);
}
@Override
@RolesAllowed(TournamentPermission.S_VIEW)
public EventUser findAvailablePlayerForTournamentByLogin(Tournament t, String login) throws Exception { public EventUser findAvailablePlayerForTournamentByLogin(Tournament t, String login) throws Exception {
EventUser u = eventUserFacade.findByLogin(login.toLowerCase().trim()); EventUser u = eventUserFacade.findByLogin(login.toLowerCase().trim());
...@@ -200,4 +213,33 @@ public class TournamentBean implements TournamentBeanLocal { ...@@ -200,4 +213,33 @@ public class TournamentBean implements TournamentBeanLocal {
throw new Exception("tournaments.participated_user_not_found"); throw new Exception("tournaments.participated_user_not_found");
} }
} }
@Override
@RolesAllowed(TournamentPermission.S_REMOVE_OWN_PARTICIPATION)
public void deleteParticipationById(Integer tpid) throws Exception {
TournamentParticipant tp = tournamentParticipantFacade.find(tpid);
EventUser executor = permissionBean.getCurrentUser();
// Assert we have permission to remove participant
// TODO: this will include check for remove any participation too!
if(!permissionBean.hasPermission(TournamentPermission.REMOVE_OWN_PARTICIPATION) || !tp.getParticipator().equals(executor)) {
throw new Exception("tournaments.can_only_remove_own_participations");
}
// Assert that tournament has not closed participation
// TODO: admin exception!
if(!tp.getTournament().getRegistrationClosesAt().after(new Date())) {
throw new Exception("tournaments.cannot_remove_participation_from_closed_tournament");
}
// All ok, do nukage
for(TournamentTeamMember ttm : tp.getTeamMembers()) {
tournamentTeamMemberFacade.remove(ttm);
}
// Let's not leave anything in cache :)
tp.getTournament().getParticipants().remove(tp);
tournamentParticipantFacade.remove(tp);
}
} }
...@@ -30,7 +30,6 @@ public class TournamentGameFacade extends IntegerPkGenericFacade<TournamentGame> ...@@ -30,7 +30,6 @@ public class TournamentGameFacade extends IntegerPkGenericFacade<TournamentGame>
CriteriaQuery<TournamentGame> cq = cb.createQuery(TournamentGame.class); CriteriaQuery<TournamentGame> cq = cb.createQuery(TournamentGame.class);
Root<TournamentGame> root = cq.from(TournamentGame.class); Root<TournamentGame> root = cq.from(TournamentGame.class);
cq.where(cb.equal(root.get(TournamentGame_.lanEvent), eventBean.getCurrentEvent())); cq.where(cb.equal(root.get(TournamentGame_.lanEvent), eventBean.getCurrentEvent()));
return getEm().createQuery(cq).getResultList(); return getEm().createQuery(cq).getResultList();
} }
} }
......
package fi.codecrew.moya.facade; package fi.codecrew.moya.facade;
import java.util.List;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.TournamentGame;
import fi.codecrew.moya.model.TournamentGame_;
import fi.codecrew.moya.model.TournamentParticipant; import fi.codecrew.moya.model.TournamentParticipant;
import fi.codecrew.moya.model.TournamentParticipant_;
@Stateless @Stateless
@LocalBean @LocalBean
...@@ -11,5 +20,14 @@ public class TournamentParticipantFacade extends IntegerPkGenericFacade<Tourname ...@@ -11,5 +20,14 @@ public class TournamentParticipantFacade extends IntegerPkGenericFacade<Tourname
public TournamentParticipantFacade() { public TournamentParticipantFacade() {
super(TournamentParticipant.class); super(TournamentParticipant.class);
} }
public List<TournamentParticipant> findByParticipator(EventUser eu) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<TournamentParticipant> cq = cb.createQuery(TournamentParticipant.class);
Root<TournamentParticipant> root = cq.from(TournamentParticipant.class);
cq.where(cb.equal(root.get(TournamentParticipant_.participator), eu));
return getEm().createQuery(cq).getResultList();
}
} }
package fi.codecrew.moya.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.codecrew.moya.model.TournamentMatchResult;
import fi.codecrew.moya.model.TournamentTeamMember;
@Stateless
@LocalBean
public class TournamentTeamMemberFacade extends IntegerPkGenericFacade<TournamentTeamMember> {
public TournamentTeamMemberFacade() {
super(TournamentTeamMember.class);
}
}
\ No newline at end of file
...@@ -30,5 +30,7 @@ public interface TournamentBeanLocal { ...@@ -30,5 +30,7 @@ public interface TournamentBeanLocal {
EventUser findAvailablePlayerForTournamentByLogin(Tournament t, String login) throws Exception; EventUser findAvailablePlayerForTournamentByLogin(Tournament t, String login) throws Exception;
List<Tournament> getTournamentsInStatus(TournamentStatus status, List<Tournament> getTournamentsInStatus(TournamentStatus status,
boolean useTimeConstraints, boolean invertMatch); boolean useTimeConstraints, boolean invertMatch);
List<TournamentParticipant> findOwnParticipations();
void deleteParticipationById(Integer tpid) throws Exception;
} }
...@@ -6,13 +6,15 @@ public enum TournamentPermission implements IAppPermission { ...@@ -6,13 +6,15 @@ public enum TournamentPermission implements IAppPermission {
VIEW, VIEW,
MANAGE_ALL, MANAGE_ALL,
PARTICIPATE PARTICIPATE,
REMOVE_OWN_PARTICIPATION
; ;
public static final String S_VIEW = "TOURNAMENT/VIEW"; public static final String S_VIEW = "TOURNAMENT/VIEW";
public static final String S_MANAGE_ALL = "TOURNAMENT/MANAGE_ALL"; public static final String S_MANAGE_ALL = "TOURNAMENT/MANAGE_ALL";
public static final String S_PARTICIPATE = "TOURNAMENT/PARTICIPATE"; public static final String S_PARTICIPATE = "TOURNAMENT/PARTICIPATE";
public static final String S_REMOVE_OWN_PARTICIPATION = "TOURNAMENT/REMOVE_OWN_PARTICIPATION";
private final String fullName; private final String fullName;
private final String key; private final String key;
......
...@@ -22,7 +22,19 @@ ...@@ -22,7 +22,19 @@
<p:slider for="maxPartSlider" /> <p:slider for="maxPartSlider" />
</h:panelGroup> </h:panelGroup>
</h:panelGrid> </h:panelGrid>
<h2>#{i18n['tournaments.tournament_gameplay']}</h2>
<h:panelGrid columns="2">
<h:outputText value="#{i18n['tournaments.tournament_type']}" />
<h:selectOneMenu value="#{tournamentEditView.tournament.tournamentType}">
<f:selectItems value="#{tournamentEditView.tournamentTypes}" var="val" itemLabel="#{i18n[val.i18nKey]}" />
</h:selectOneMenu>
<h:outputText value="#{i18n['tournament.rules']}" />
<h:selectOneMenu value="#{tournamentEditView.tournament.rules}" converter="#{tournamentRuleConverter}">
<f:selectItems var="rule" itemLabel="#{rule.name}" value="#{tournamentEditView.tournamentRules}" itemValue="#{rule}" />
</h:selectOneMenu>
</h:panelGrid>
<h2>#{i18n['tournaments.admin.registration_time_constraints']}</h2> <h2>#{i18n['tournaments.admin.registration_time_constraints']}</h2>
...@@ -39,8 +51,8 @@ ...@@ -39,8 +51,8 @@
<p:calendar stepHour="1" stepMinute="10" pattern="dd.MM.yyyy HH:mm" value="#{tournamentEditView.tournament.beginsAt}"/> <p:calendar stepHour="1" stepMinute="10" pattern="dd.MM.yyyy HH:mm" value="#{tournamentEditView.tournament.beginsAt}"/>
</h:panelGrid> </h:panelGrid>
<p:commandButton value="#{i18n['tournaments.admin.cancel_edits']}" action="#{tournamentEditView.cancel}"/> <p:commandButton value="#{i18n['tournaments.admin.cancel_edits']}" action="#{tournamentEditView.cancel}" ajax="false" />
<p:commandButton value="#{i18n['tournaments.admin.edit_tournament']}" action="#{tournamentEditView.commit}"/> <p:commandButton value="#{i18n['tournaments.admin.edit_tournament']}" action="#{tournamentEditView.commit}" ajax="false" />
</h:form> </h:form>
</ui:define> </ui:define>
......
...@@ -39,8 +39,9 @@ ...@@ -39,8 +39,9 @@
</ui:repeat> </ui:repeat>
</p:column> </p:column>
</p:dataTable> </p:dataTable>
</h:form> </h:form>
<h:form> <h:form>
<p:commandButton value="#{i18n['tournament.admin.back_to_index']}" action="#{tournamentParticipantsView.cancel}" /> <p:commandButton value="#{i18n['tournament.admin.back_to_index']}" action="#{tournamentParticipantsView.cancel}" />
</h:form> </h:form>
......
...@@ -163,6 +163,7 @@ ...@@ -163,6 +163,7 @@
</h:panelGrid> </h:panelGrid>
</p:rowExpansion> </p:rowExpansion>
</p:dataTable> </p:dataTable>
<!--
<h2>#{i18n['tournaments.in_progress_tournaments']}</h2> <h2>#{i18n['tournaments.in_progress_tournaments']}</h2>
<p:dataTable value="#{tournamentListView.inProgressTournaments}" var="tournament"> <p:dataTable value="#{tournamentListView.inProgressTournaments}" var="tournament">
<p:column style="width:2%"> <p:column style="width:2%">
...@@ -301,6 +302,7 @@ ...@@ -301,6 +302,7 @@
</h:panelGrid> </h:panelGrid>
</p:rowExpansion> </p:rowExpansion>
</p:dataTable> </p:dataTable>
-->
</h:form> </h:form>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:event type="preRenderView" listener="#{tournamentEditParticipationView.initView}" />
</f:metadata>
<ui:define name="content">
<h1>#{i18n['tournament.my_participations']}</h1>
<h:form>
<p:dataTable value="#{tournamentEditParticipationView.ownParticipations}" var="participation">
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['tournament.name']}" />
</f:facet>
<h:outputText value="#{participation.tournament.tournamentName}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['tournament.game']}" />
</f:facet>
<h:outputText value="#{participation.tournament.tournamentGame.name}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['tournament.rules']}" />
</f:facet>
<h:link value="#{participation.tournament.rules.name}" outcome="/tournaments/showrules.xhtml">
<f:param name="tournament_id" value="#{participation.tournament.id}" />
</h:link>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['tournament.control']}" />
</f:facet>
<h:commandButton actionListener="#{tournamentEditParticipationView.cancelParticipation(participation.id)}" value="#{i18n['tournament.cancel_participation']}" rendered="#{participation.tournament.registrationClosesAt.after(tournamentEditParticipationView.now) and tournamentEditParticipationView.canRemove}" />
</p:column>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
...@@ -951,6 +951,7 @@ submenu.shop.shopToUser = Shop to user ...@@ -951,6 +951,7 @@ submenu.shop.shopToUser = Shop to user
submenu.shop.showReaderEvents = Reader events submenu.shop.showReaderEvents = Reader events
submenu.tournaments.admin.index = View and manage submenu.tournaments.admin.index = View and manage
submenu.tournaments.index = View and participate submenu.tournaments.index = View and participate
submenu.tournaments.myparticipations = My Participations
submenu.user.accountEvents = Account events submenu.user.accountEvents = Account events
submenu.user.changePassword = Change password submenu.user.changePassword = Change password
submenu.user.create = Create new user submenu.user.create = Create new user
...@@ -1038,9 +1039,11 @@ tournament.admin.delete = Delete ...@@ -1038,9 +1039,11 @@ tournament.admin.delete = Delete
tournament.admin.delete_cancel = Cancel Deletion tournament.admin.delete_cancel = Cancel Deletion
tournament.admin.delete_confirm = Confirm Deletion tournament.admin.delete_confirm = Confirm Deletion
tournament.admin.edit = Edit tournament.admin.edit = Edit
tournament.admin.tournament_edited_successfully = Edited successfully
tournament.admin.view = View tournament.admin.view = View
tournament.already_participated_into_tournament = Already participated into the selected tournament! tournament.already_participated_into_tournament = Already participated into the selected tournament!
tournament.backup_player_successfully_added_to_team = Backup player added tournament.backup_player_successfully_added_to_team = Backup player added
tournament.cancel_participation = Cancel participation
tournament.cannot_add_anon_user = Cannot add anonymous user tournament.cannot_add_anon_user = Cannot add anonymous user
tournament.cannot_remove_captain = Cannot remove the team captain (you) tournament.cannot_remove_captain = Cannot remove the team captain (you)
tournament.control = Control tournament.control = Control
...@@ -1049,6 +1052,7 @@ tournament.edit = Edit tournamen ...@@ -1049,6 +1052,7 @@ tournament.edit = Edit tournamen
tournament.fillamount = Places taken tournament.fillamount = Places taken
tournament.full = Tournament Full tournament.full = Tournament Full
tournament.game = Game tournament.game = Game
tournament.my_participations = My Participations
tournament.name = Tournament name tournament.name = Tournament name
tournament.not_within_participation_time = Not within the participation time for the tournament tournament.not_within_participation_time = Not within the participation time for the tournament
tournament.participant_captain = Captain tournament.participant_captain = Captain
...@@ -1131,6 +1135,7 @@ tournaments.start_time = Start Time ...@@ -1131,6 +1135,7 @@ tournaments.start_time = Start Time
tournaments.team_details = Team Details tournaments.team_details = Team Details
tournaments.title = Tournaments tournaments.title = Tournaments
tournaments.tournament_details = Tournament details tournaments.tournament_details = Tournament details
tournaments.tournament_gameplay = Gameplay settings
tournaments.tournament_name = Tournament name tournaments.tournament_name = Tournament name
tournaments.tournament_type = Tournament type tournaments.tournament_type = Tournament type
......
...@@ -933,6 +933,7 @@ submenu.shop.shopToUser = Osta k\u00E4ytt\u00E4j\u00E4lle ...@@ -933,6 +933,7 @@ submenu.shop.shopToUser = Osta k\u00E4ytt\u00E4j\u00E4lle
submenu.shop.showReaderEvents = Lukijan tapahtumat submenu.shop.showReaderEvents = Lukijan tapahtumat
submenu.tournaments.admin.index = Katsele ja hallinnoi submenu.tournaments.admin.index = Katsele ja hallinnoi
submenu.tournaments.index = Listaa turnaukset submenu.tournaments.index = Listaa turnaukset
submenu.tournaments.myparticipations = Omat ilmoittautumiset
submenu.user.accountEvents = Tilitapahtumat submenu.user.accountEvents = Tilitapahtumat
submenu.user.changePassword = Vaihda salasana submenu.user.changePassword = Vaihda salasana
submenu.user.create = Luo k\u00E4ytt\u00E4j\u00E4 submenu.user.create = Luo k\u00E4ytt\u00E4j\u00E4
...@@ -1023,9 +1024,11 @@ tournament.admin.delete = Poista ...@@ -1023,9 +1024,11 @@ tournament.admin.delete = Poista
tournament.admin.delete_cancel = Peruuta tournament.admin.delete_cancel = Peruuta
tournament.admin.delete_confirm = Vahvista Poisto tournament.admin.delete_confirm = Vahvista Poisto
tournament.admin.edit = Muokkaa tournament.admin.edit = Muokkaa
tournament.admin.tournament_edited_successfully = Turnauksen asetuksia muutettu
tournament.admin.view = Tarkastele tournament.admin.view = Tarkastele
tournament.already_participated_into_tournament = Olet jo osallistunut valittuun turnaukseen! tournament.already_participated_into_tournament = Olet jo osallistunut valittuun turnaukseen!
tournament.backup_player_successfully_added_to_team = Varapelaaja lis\u00E4tty tournament.backup_player_successfully_added_to_team = Varapelaaja lis\u00E4tty
tournament.cancel_participation = Peruuta osallistuminen
tournament.cannot_add_anon_user = Ei voida lis\u00E4t\u00E4 anomuumia tournament.cannot_add_anon_user = Ei voida lis\u00E4t\u00E4 anomuumia
tournament.cannot_remove_captain = Kapteenia (sinua) ei voi poistaa joukkueesta tournament.cannot_remove_captain = Kapteenia (sinua) ei voi poistaa joukkueesta
tournament.control = Hallitse tournament.control = Hallitse
...@@ -1034,6 +1037,7 @@ tournament.edit = Muokkaa turnau ...@@ -1034,6 +1037,7 @@ tournament.edit = Muokkaa turnau
tournament.fillamount = Osallistujaa ilmottautunut tournament.fillamount = Osallistujaa ilmottautunut
tournament.full = Turnaus t\u00E4ynn\u00E4 tournament.full = Turnaus t\u00E4ynn\u00E4
tournament.game = Peli tournament.game = Peli
tournament.my_participations = Omat ilmoittautumiset
tournament.name = Turnauksen nimi tournament.name = Turnauksen nimi
tournament.not_within_participation_time = Turnauksen ilmoittautuminen ei ole aktiivinen tournament.not_within_participation_time = Turnauksen ilmoittautuminen ei ole aktiivinen
tournament.participant_captain = Kapteeni tournament.participant_captain = Kapteeni
...@@ -1116,6 +1120,7 @@ tournaments.start_time = Aloitusaika ...@@ -1116,6 +1120,7 @@ tournaments.start_time = Aloitusaika
tournaments.team_details = Joukkuekohtaiset tiedot tournaments.team_details = Joukkuekohtaiset tiedot
tournaments.title = Turnaukset tournaments.title = Turnaukset
tournaments.tournament_details = Turnauksen yksityiskohdat tournaments.tournament_details = Turnauksen yksityiskohdat
tournaments.tournament_gameplay = Peliasetukset
tournaments.tournament_name = Turnauksen nimi tournaments.tournament_name = Turnauksen nimi
tournaments.tournament_type = Turnauksen tyyppi tournaments.tournament_type = Turnauksen tyyppi
......
...@@ -115,6 +115,7 @@ public class PlaceView extends GenericCDIView { ...@@ -115,6 +115,7 @@ public class PlaceView extends GenericCDIView {
if (!placebean.reservePlace(place, user)) { if (!placebean.reservePlace(place, user)) {
this.addFaceMessage("mapView.errorWhenReservingPlace"); this.addFaceMessage("mapView.errorWhenReservingPlace");
} }
} else { } else {
if (balance.compareTo(BigDecimal.ZERO) > 0) { if (balance.compareTo(BigDecimal.ZERO) > 0) {
addFaceMessage("mapView.notEnoughCreditsToReserve"); addFaceMessage("mapView.notEnoughCreditsToReserve");
......
package fi.codecrew.moya.web.cdiview.tournaments;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import fi.codecrew.moya.beans.TournamentBeanLocal;
import fi.codecrew.moya.enums.apps.TournamentPermission;
import fi.codecrew.moya.model.TournamentParticipant;
import fi.codecrew.moya.utilities.jsf.MessageHelper;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@RequestScoped
public class TournamentEditParticipationView extends GenericCDIView {
private static final long serialVersionUID = -1769196668352780319L;
@EJB
private TournamentBeanLocal tournamentBean;
public void initView() {
super.requirePermissions(TournamentPermission.VIEW);
}
public List<TournamentParticipant> getOwnParticipations() {
return tournamentBean.findOwnParticipations();
}
public void cancelParticipation(String tournamentParticipationId) {
try {
Integer tpid = Integer.parseInt(tournamentParticipationId);
tournamentBean.deleteParticipationById(tpid);
} catch(Exception ex) {
MessageHelper.err(ex.getMessage());
}
}
public Date getNow() {
return new Date();
}
public Boolean getCanRemove() {
return super.hasPermission(TournamentPermission.REMOVE_OWN_PARTICIPATION);
}
}
package fi.codecrew.moya.web.cdiview.tournaments; package fi.codecrew.moya.web.cdiview.tournaments;
import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped; import javax.enterprise.context.ConversationScoped;
import javax.inject.Named; import javax.inject.Named;
import fi.codecrew.moya.beans.TournamentBeanLocal; import fi.codecrew.moya.beans.TournamentBeanLocal;
import fi.codecrew.moya.enums.TournamentType;
import fi.codecrew.moya.enums.apps.TournamentPermission; import fi.codecrew.moya.enums.apps.TournamentPermission;
import fi.codecrew.moya.model.Tournament; import fi.codecrew.moya.model.Tournament;
import fi.codecrew.moya.model.TournamentRule;
import fi.codecrew.moya.utilities.I18n; import fi.codecrew.moya.utilities.I18n;
import fi.codecrew.moya.utilities.jsf.MessageHelper; import fi.codecrew.moya.utilities.jsf.MessageHelper;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
...@@ -53,6 +57,15 @@ public class TournamentEditView extends GenericCDIView { ...@@ -53,6 +57,15 @@ public class TournamentEditView extends GenericCDIView {
this.endConversation(); this.endConversation();
return "/tournaments/admin/index.xhtml"; return "/tournaments/admin/index.xhtml";
} }
public TournamentType[] getTournamentTypes() {
TournamentType[] items = TournamentType.values();
return items;
}
public List<TournamentRule> getTournamentRules() {
return tournamentBean.getRulesByGame(tournament.getTournamentGame());
}
public Tournament getTournament() { public Tournament getTournament() {
return tournament; return tournament;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!