From 31248ba405f50f727c1ed23e5026fb09fc0be45f Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 20 Jan 2016 10:52:02 +0100 Subject: [PATCH 1/8] Cleaning various files Clean forms Clean manager controller Remove generated comments --- .../TournamentBundle/Controller/ManagerController.php | 4 ++-- src/InsaLan/TournamentBundle/Entity/ManagerRepository.php | 6 ------ src/InsaLan/TournamentBundle/Form/SetPlayerName.php | 4 ++-- src/InsaLan/TournamentBundle/Form/TeamType.php | 4 ++-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php index 7284b9db..217ce8eb 100644 --- a/src/InsaLan/TournamentBundle/Controller/ManagerController.php +++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php @@ -97,7 +97,7 @@ public function setNameAction(Request $request, Entity\Tournament $tournament) /** * Allow a new manager to join a team with name and password - * @Route("/{tournament}/user/setname") + * @Route("/{tournament}/user/jointeam") * @Template() */ public function joinTeamWithPasswordAction(Request $request, Entity\Tournament $tournament) @@ -300,7 +300,7 @@ public function payOfflineAction(Request $request, Entity\Tournament $tournament return array('tournament' => $tournament, 'user' => $usr, 'manager' => $manager); } - + /** * Allow a manager to drop a pending tournament registration if not managed by team * @Route("/{tournament}/user/leave") diff --git a/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php b/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php index d7f054f4..abdcd6c2 100644 --- a/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php +++ b/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php @@ -4,12 +4,6 @@ use Doctrine\ORM\EntityRepository; -/** - * ManagerRepository - * - * This class was generated by the Doctrine ORM. Add your own custom - * repository methods below. - */ class ManagerRepository extends EntityRepository { public function findOneByUserAndPendingTournament(\InsaLan\UserBundle\Entity\User $u, Tournament $t) { diff --git a/src/InsaLan/TournamentBundle/Form/SetPlayerName.php b/src/InsaLan/TournamentBundle/Form/SetPlayerName.php index 9f3c463b..8ed7f97d 100644 --- a/src/InsaLan/TournamentBundle/Form/SetPlayerName.php +++ b/src/InsaLan/TournamentBundle/Form/SetPlayerName.php @@ -8,7 +8,7 @@ class SetPlayerName extends AbstractType { - /** + /** * @param FormBuilderInterface $builder * @param array $options */ @@ -18,7 +18,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ->add('gameName') ; } - + /** * @param OptionsResolverInterface $resolver */ diff --git a/src/InsaLan/TournamentBundle/Form/TeamType.php b/src/InsaLan/TournamentBundle/Form/TeamType.php index 3a3d60ad..f1c612bb 100644 --- a/src/InsaLan/TournamentBundle/Form/TeamType.php +++ b/src/InsaLan/TournamentBundle/Form/TeamType.php @@ -8,7 +8,7 @@ class TeamType extends AbstractType { - /** + /** * @param FormBuilderInterface $builder * @param array $options */ @@ -24,7 +24,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) )) ; } - + /** * @param OptionsResolverInterface $resolver */ From 43cde8bec32f462396c538b5362527f8c51ef1f5 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 20 Jan 2016 18:04:19 +0100 Subject: [PATCH 2/8] Add manager limit to tournaments --- .../Version20160120180223.php | 34 +++++++++++++++++++ .../TournamentBundle/Entity/Tournament.php | 29 ++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 app/DoctrineMigrations/Version20160120180223.php diff --git a/app/DoctrineMigrations/Version20160120180223.php b/app/DoctrineMigrations/Version20160120180223.php new file mode 100644 index 00000000..04ed8301 --- /dev/null +++ b/app/DoctrineMigrations/Version20160120180223.php @@ -0,0 +1,34 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE intra_Tournament ADD maxManager INT DEFAULT NULL'); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE intra_Tournament DROP maxManager'); + } +} diff --git a/src/InsaLan/TournamentBundle/Entity/Tournament.php b/src/InsaLan/TournamentBundle/Entity/Tournament.php index ea642292..5719ad1a 100644 --- a/src/InsaLan/TournamentBundle/Entity/Tournament.php +++ b/src/InsaLan/TournamentBundle/Entity/Tournament.php @@ -104,6 +104,14 @@ class Tournament */ protected $teamMaxPlayer; + /** + * Maximum number of manager allowed on the tournament. + * Only for solo tournaments at the moment. + * + * @ORM\Column(type="integer", nullable=true) + */ + protected $maxManager; + /** * @ORM\Column(type="string", nullable=true) */ @@ -451,6 +459,27 @@ public function getTeamMaxPlayer() return $this->teamMaxPlayer; } + /** + * Get the maximum allowed number of manager + * + * @return integer + */ + public function getMaxManager() + { + return $this->maxManager; + } + + /** + * Set the maximum allowed number of manager + */ + public function setMaxManager($maxManager) + { + $this->maxManager = $maxManager; + + return $this; + } + + /** * Set participantType * From cdbf2c283066768a9adc6363764271026202b09e Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 20 Jan 2016 18:50:30 +0100 Subject: [PATCH 3/8] Register managers into solo tournaments --- .../Controller/ManagerController.php | 69 ++++++++++++++++++- .../Manager/JoinSoloPlayerActive.html.twig | 31 +++++++++ .../Manager/JoinSoloPlayerValidated.html.twig | 9 +++ .../views/Manager/joinSoloPlayer.html.twig | 25 +++++++ .../Resources/views/Manager/pay.html.twig | 6 +- .../Resources/views/User/index.html.twig | 6 +- 6 files changed, 137 insertions(+), 9 deletions(-) create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/JoinSoloPlayerActive.html.twig create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/JoinSoloPlayerValidated.html.twig create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/joinSoloPlayer.html.twig diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php index 217ce8eb..6a98a3ac 100644 --- a/src/InsaLan/TournamentBundle/Controller/ManagerController.php +++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php @@ -22,11 +22,13 @@ use Payum\Paypal\ExpressCheckout\Nvp\Api; use InsaLan\TournamentBundle\Form\SetManagerName; +use InsaLan\TournamentBundle\Form\SetPlayerName; use InsaLan\TournamentBundle\Form\TeamLoginType; use InsaLan\TournamentBundle\Exception\ControllerException; use InsaLan\TournamentBundle\Entity\Manager; use InsaLan\TournamentBundle\Entity\Participant; +use InsaLan\TournamentBundle\Entity\Player; use InsaLan\TournamentBundle\Entity\Tournament; use InsaLan\TournamentBundle\Entity\Team; use InsaLan\TournamentBundle\Entity; @@ -87,14 +89,75 @@ public function setNameAction(Request $request, Entity\Tournament $tournament) $em->persist($manager); $em->flush(); - return $this->redirect( - $this->generateUrl('insalan_tournament_manager_jointeamwithpassword', array('tournament' => $tournament->getId())) - ); + if($tournament->getParticipantType() === "team") + return $this->redirect( + $this->generateUrl('insalan_tournament_manager_jointeamwithpassword', array('tournament' => $tournament->getId())) + ); + else // solo tournaments + return $this->redirect( + $this->generateUrl('insalan_tournament_manager_joinsoloplayer', array('tournament' => $tournament->getId())) + ); } return array('form' => $form->createView(), 'selectedGame' => $tournament->getType(), 'tournamentId' => $tournament->getId()); } + /** + * Allow a manager to join a player in a solo tournament + * @Route("/{tournament}/user/joinplayer") + * @Template() + */ + public function joinSoloPlayerAction(Request $request, Entity\Tournament $tournament) + { + $em = $this->getDoctrine()->getManager(); + $usr = $this->get('security.context')->getToken()->getUser(); + + // handle only solo tournaments + if($tournament->getParticipantType() !== "player") + throw new ControllerException("Joueurs solo non acceptées dans ce tournois"); + + // check if there is already a pending manager for this user and tournament + $manager = $em->getRepository('InsaLanTournamentBundle:Manager') + ->findOneByUserAndPendingTournament($usr, $tournament); + + if($manager === null) + return $this->redirect($this->generateUrl('insalan_tournament_manager_setname', array('tournament' => $tournament->getId()))); + + $form_player = new Player(); + $form = $this->createForm(new SetPlayerName(), $form_player); // fill player gamename + $form->handleRequest($request); + + $error_details = null; + if ($form->isValid()) { + try { + // find the targeted player related to the manager + $player = $em + ->getRepository('InsaLanTournamentBundle:Player') + ->findOneBy(array( + 'gameName' => $form_player->getGameName(), + 'tournament' => $tournament)); + + if ($player === null) + throw new ControllerException("Joueur introuvable !"); + if ($player->getManager() != null) + throw new ControllerException("Le joueur possède déjà un manager !"); + + $manager->setParticipant($player); + $player->setManager($manager); + $em->persist($manager); + $em->persist($player); + $em->flush(); + + return $this->redirect($this->generateUrl('insalan_tournament_manager_pay', array('tournament' => $tournament->getId()))); + + } catch (ControllerException $e) { + $error_details = $e->getMessage(); + } + + } + return array('tournament' => $tournament, 'user' => $usr, 'manager' => $manager, 'error' => $error_details, 'form' => $form->createView()); + } + /** * Allow a new manager to join a team with name and password * @Route("/{tournament}/user/jointeam") diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinSoloPlayerActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinSoloPlayerActive.html.twig new file mode 100644 index 00000000..5454b7df --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinSoloPlayerActive.html.twig @@ -0,0 +1,31 @@ +{% if error %} +
+
+
+ {{ counter }} +
+
Coacher un joueur inscrit
+
+
+
+

{{ error }}

+
+{% else %} +
+
+
+ {{ counter }} +
+
Coacher un joueur inscrit
+
+
+{% endif %} + +
+ +
+ +
+ Ok +
+
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinSoloPlayerValidated.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinSoloPlayerValidated.html.twig new file mode 100644 index 00000000..34091b5d --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinSoloPlayerValidated.html.twig @@ -0,0 +1,9 @@ +
+
+
+ {{ counter }} +
+
Joueur sélectionnée : {{ manager.participant }}
+
+
+
\ No newline at end of file diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/joinSoloPlayer.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/joinSoloPlayer.html.twig new file mode 100644 index 00000000..28154906 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/joinSoloPlayer.html.twig @@ -0,0 +1,25 @@ +{% extends 'InsaLanTournamentBundle::layout.html.twig' %} + +{% block body %} +{{ parent() }} + +
+ + +
+

Rejoindre le tournoi « {{ tournament.name }} » en tant que manager

+ {{ tournament.description }} +
+ +
+ + {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameValidated.html.twig' with {'counter': 1}%} + {% include 'InsaLanTournamentBundle:Manager:JoinSoloPlayerActive.html.twig' with {'counter': 2}%} + +
+
+{% endblock %} diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig index d25a94d7..44f4cc0a 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig @@ -22,9 +22,9 @@ {% include 'InsaLanTournamentBundle:Manager:CreateJoinTeamValidated.html.twig' with {'counter': 2}%} {% include 'InsaLanTournamentBundle:Manager:BeforePaymentActive.html.twig' with {'counter': 3}%} {% else %} - {% include 'InsaLanTournamentBundle:Manager:ChooseGameNameValidated.html.twig' with {'counter': 1}%} - {# player choice must be here if not given by URL #} - {% include 'InsaLanTournamentBundle:Manager:BeforePaymentActive.html.twig' with {'counter': 2} %} + {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameValidated.html.twig' with {'counter': 1}%} + {% include 'InsaLanTournamentBundle:Manager:JoinSoloPlayerValidated.html.twig' with {'counter': 2} %} + {% include 'InsaLanTournamentBundle:Manager:BeforePaymentActive.html.twig' with {'counter': 3} %} {% endif %} diff --git a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig index ce76cd49..b60d5fc7 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig @@ -161,13 +161,13 @@

{{ t.name }}{% if t.isFull %} - COMPLET {% endif %}

- {% if t.participantType == 'team' %} -
Inscription manager - {% endif %} + + Inscription manager {% if t.isFull and t.participantType == 'team' %} Rejoindre une équipe {% endif %} {% if not t.isFull %}Inscription joueur{% endif %} +

{{ t.teamMinPlayer }} joueur(s) - From cdb45b920897d30f0b03a11cbe7124c009f429ad Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 20 Jan 2016 21:11:18 +0100 Subject: [PATCH 4/8] User page support solo managers --- .../Resources/views/User/index.html.twig | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig index b60d5fc7..27253fb5 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig @@ -67,6 +67,19 @@

{% endif %} + {% endif %}{# paticipantType == 'team' #} + {% if participant.participantType == 'player' and participant.manager is not null %} +
    +
  • +
    + {% if participant.manager.ok %} + + {% else %} + + {% endif %} + {{ participant.manager.gameName }} [Manager] +
  • +
{% endif %}
@@ -95,7 +108,7 @@ {% endif %} - {% if participant.participantType == 'team' and participant.manager is not null and participant.manager.user == app.user %} + {% if participant.manager is not null and participant.manager.user == app.user %} {# 2-button layout #}{% if participant.tournament.isOpenedNow %} Annuler Mon inscription From 1171e0ae5d8ff2b1db3bbc5d7621fab6f012cec7 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 20 Jan 2016 21:18:32 +0100 Subject: [PATCH 5/8] Fix payment process for solo managers --- .../Resources/views/Manager/payDone.html.twig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/payDone.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/payDone.html.twig index 19c72923..4b415064 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/Manager/payDone.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/payDone.html.twig @@ -23,9 +23,10 @@ {% include 'InsaLanTournamentBundle:Manager:BeforePaymentValidated.html.twig' with {'counter': 3}%} {% include 'InsaLanTournamentBundle:Manager:AfterPaymentActive.html.twig' with {'counter': 4} %} {% else %} - {% include 'InsaLanTournamentBundle:Manager:ChooseGameNameValidated.html.twig' with {'counter': 1} %} - {% include 'InsaLanTournamentBundle:Manager:BeforePaymentValidated.html.twig' with {'counter': 2} %} - {% include 'InsaLanTournamentBundle:Manager:AfterPaymentActive.html.twig' with {'counter': 3} %} + {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameValidated.html.twig' with {'counter': 1} %} + {% include 'InsaLanTournamentBundle:Manager:JoinSoloPlayerValidated.html.twig' with {'counter': 2} %} + {% include 'InsaLanTournamentBundle:Manager:BeforePaymentValidated.html.twig' with {'counter': 3} %} + {% include 'InsaLanTournamentBundle:Manager:AfterPaymentActive.html.twig' with {'counter': 4} %} {% endif %} From bc1923b2ebef0b829bbc0e5d0be7f3b1f8705b93 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 20 Jan 2016 21:40:07 +0100 Subject: [PATCH 6/8] Fix leaving checks & routes --- .../Controller/ManagerController.php | 17 +++++++++++++++-- .../Resources/views/User/index.html.twig | 9 ++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php index 6a98a3ac..4a133b1e 100644 --- a/src/InsaLan/TournamentBundle/Controller/ManagerController.php +++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php @@ -366,6 +366,7 @@ public function payOfflineAction(Request $request, Entity\Tournament $tournament /** * Allow a manager to drop a pending tournament registration if not managed by team + * TODO add flashbag confirmation * @Route("/{tournament}/user/leave") */ public function leaveAction(Entity\Tournament $tournament) { @@ -379,6 +380,17 @@ public function leaveAction(Entity\Tournament $tournament) { if($manager->getTournament()->getParticipantType() !== "player") throw new ControllerException("Not Allowed"); // must be a player only tournament + // not allowed if he paid something + if(!$tournament->isFree() && $manager->getPaymentDone()){ + $this->get('session')->getFlashBag()->add('error', "Vous avez payé votre place, merci de contacter l'InsaLan si vous souhaitez vous désister."); + return $this->redirect($this->generateUrl('insalan_tournament_user_index')); + } + // not allowed either if registration are closed + if($tournament->isOpenedNow()) + return $this->redirect($this->generateUrl('insalan_tournament_user_index')); + + $manager->getParticipant()->setManager(null); + $manager->setParticipant(null); $em->remove($manager); $em->flush(); @@ -387,8 +399,8 @@ public function leaveAction(Entity\Tournament $tournament) { /** * Allow a manager to drop a pending tournament registration managed by teams + * TODO add flashbag confirmation * @Route("/user/leave/team/{teamId}") - * @Template() */ public function leaveTeamAction($teamId) { $em = $this->getDoctrine()->getManager(); @@ -416,7 +428,7 @@ public function leaveTeamAction($teamId) { } // not allowed either if registration are closed if(!$team->getTournament()->isOpenedNow()) - return $this->redirect($this->generateUrl('insalan_tournament_user_index')); + return $this->redirect($this->generateUrl('insalan_tournament_user_index')); $manager->setParticipant(null); $team->setManager(null); @@ -424,6 +436,7 @@ public function leaveTeamAction($teamId) { $em->persist($team); $em->remove($manager); $em->flush(); + return $this->redirect($this->generateUrl('insalan_tournament_user_index')); } diff --git a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig index 27253fb5..db0cc1da 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig @@ -110,9 +110,12 @@ {% if participant.manager is not null and participant.manager.user == app.user %} {# 2-button layout #}{% if participant.tournament.isOpenedNow %} - Annuler - Mon inscription - + {% if participant.participantType == 'team' %} + Annuler + {% elseif participant.participantType == 'player' %} + Annuler + {% endif %} + Mon inscription {# tournament is closed #}{% else %} Inscription archivée {% endif %} From b025313a8b491885456f37a740e251a9e0d1e97a Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 20 Jan 2016 22:25:48 +0100 Subject: [PATCH 7/8] Registration are closed if they are not open... --- src/InsaLan/TournamentBundle/Controller/ManagerController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php index 4a133b1e..9b0ba8e1 100644 --- a/src/InsaLan/TournamentBundle/Controller/ManagerController.php +++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php @@ -386,7 +386,7 @@ public function leaveAction(Entity\Tournament $tournament) { return $this->redirect($this->generateUrl('insalan_tournament_user_index')); } // not allowed either if registration are closed - if($tournament->isOpenedNow()) + if(!$tournament->isOpenedNow()) return $this->redirect($this->generateUrl('insalan_tournament_user_index')); $manager->getParticipant()->setManager(null); From 7046d986194f0a233b473665f63e82eab281073e Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 20 Jan 2016 22:28:03 +0100 Subject: [PATCH 8/8] Add Sonata management for managers --- .../TournamentBundle/Admin/ManagerAdmin.php | 50 +++++++++++++++++++ .../TournamentBundle/Admin/PlayerAdmin.php | 1 + .../TournamentBundle/Admin/TeamAdmin.php | 1 + .../Resources/config/services.yml | 11 ++++ 4 files changed, 63 insertions(+) create mode 100644 src/InsaLan/TournamentBundle/Admin/ManagerAdmin.php diff --git a/src/InsaLan/TournamentBundle/Admin/ManagerAdmin.php b/src/InsaLan/TournamentBundle/Admin/ManagerAdmin.php new file mode 100644 index 00000000..6da5f877 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Admin/ManagerAdmin.php @@ -0,0 +1,50 @@ +add('user') + ->add('gameName') + ->add('tournament') + ->add('participant') + ->add('paymentDone', null, array('required'=>false)) + ->add('arrived', null, array('required'=>false)) + ; + } + + // Fields to be shown on filter forms + protected function configureDatagridFilters(DatagridMapper $datagridMapper) + { + $datagridMapper + ->add('gameName') + ->add('user.username') + ->add('user.email') + ->add('tournament') + ->add('arrived') + ; + } + + // Fields to be shown on lists + protected function configureListFields(ListMapper $listMapper) + { + $listMapper + ->addIdentifier('user.username') + ->addIdentifier('gameName') + ->add('tournament') + ->add('user.email') + ->add('paymentDone') + ->add('arrived') + ; + } + +} diff --git a/src/InsaLan/TournamentBundle/Admin/PlayerAdmin.php b/src/InsaLan/TournamentBundle/Admin/PlayerAdmin.php index 76f6e22f..2b5d0ee0 100644 --- a/src/InsaLan/TournamentBundle/Admin/PlayerAdmin.php +++ b/src/InsaLan/TournamentBundle/Admin/PlayerAdmin.php @@ -15,6 +15,7 @@ protected function configureFormFields(FormMapper $formMapper) $formMapper ->add('user') ->add('team') + ->add('manager') ->add('gameName') ->add('gameValidated', null, array('required'=>false)) ->add('gameAvatar') diff --git a/src/InsaLan/TournamentBundle/Admin/TeamAdmin.php b/src/InsaLan/TournamentBundle/Admin/TeamAdmin.php index 4b92aaf0..c904d75d 100644 --- a/src/InsaLan/TournamentBundle/Admin/TeamAdmin.php +++ b/src/InsaLan/TournamentBundle/Admin/TeamAdmin.php @@ -19,6 +19,7 @@ protected function configureFormFields(FormMapper $formMapper) ->add('name') ->add('tournament') ->add('captain') + ->add('manager') ->add('validated', 'choice', array( 'required' => true, 'choices' => array( diff --git a/src/InsaLan/TournamentBundle/Resources/config/services.yml b/src/InsaLan/TournamentBundle/Resources/config/services.yml index 504ef260..b1924b1a 100644 --- a/src/InsaLan/TournamentBundle/Resources/config/services.yml +++ b/src/InsaLan/TournamentBundle/Resources/config/services.yml @@ -43,6 +43,17 @@ services: calls: - [ setTranslationDomain, [InsaLanTournamentBundle]] + sonata.admin.tournament.manager: + class: InsaLan\TournamentBundle\Admin\ManagerAdmin + tags: + - { name: sonata.admin, manager_type: orm, group: "Tournois", label: "Manager" } + arguments: + - ~ + - InsaLan\TournamentBundle\Entity\Manager + - ~ + calls: + - [ setTranslationDomain, [InsaLanTournamentBundle]] + sonata.admin.tournament.team: class: InsaLan\TournamentBundle\Admin\TeamAdmin tags: