From d51058834f5ec8f28b535af61ef984dd49db5e90 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Tue, 22 Dec 2015 15:44:15 +0100 Subject: [PATCH 01/19] Add Manager entity * Manager are separated from players and teams * Teams/SoloPlayers are related to Managers throught Participant class --- .../TournamentBundle/Entity/Manager.php | 221 ++++++++++++++++++ .../Entity/ManagerRepository.php | 15 ++ .../TournamentBundle/Entity/Participant.php | 28 +++ 3 files changed, 264 insertions(+) create mode 100644 src/InsaLan/TournamentBundle/Entity/Manager.php create mode 100644 src/InsaLan/TournamentBundle/Entity/ManagerRepository.php diff --git a/src/InsaLan/TournamentBundle/Entity/Manager.php b/src/InsaLan/TournamentBundle/Entity/Manager.php new file mode 100644 index 00000000..ca2c32e3 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Entity/Manager.php @@ -0,0 +1,221 @@ +paymentDone = false; + $this->arrived = false; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Get user + * + * @return \InsaLan\UserBundle\Entity\User + */ + public function getUser() + { + return $this->user; + } + + /** + * Set user + * + * @param \InsaLan\UserBundle\Entity\User $user + * @return Manager + */ + public function setUser(\InsaLan\UserBundle\Entity\User $user = null) + { + $this->user = $user; + return $this; + } + + /** + * Get realted participant + * + * @return \InsaLan\UserBundle\Entity\Participant + */ + public function getParticipant() + { + return $this->participant; + } + + /** + * Set related participant + * + * @param \InsaLan\UserBundle\Entity\Participant $participant + * @return Manager + */ + public function setParticipant(\InsaLan\TournamentBundle\Entity\Participant $participant = null) + { + $this->participant->setManager($this); // One-to-one relationship + $this->participant = $participant; + return $this; + } + + /** + * Get gameName + * + * @return string + */ + public function getGameName() + { + return $this->gameName; + } + + /** + * Set gameName + * + * @param string $gameName + * @return Manager + */ + public function setGameName($gameName) + { + $this->gameName = $gameName; + + return $this; + } + + /** + * Get paymentDone + * + * @return boolean + */ + public function getPaymentDone() + { + return $this->paymentDone; + } + + /** + * Set paymentDone + * + * @param boolean $paymentDone + * @return Manager + */ + public function setPaymentDone($paymentDone) + { + $this->paymentDone = $paymentDone; + + return $this; + } + + public function isOk() { + return $this->paymentDone; + } + + /** + * Set arrived + * + * @param boolean $arrived + * @return Manager + */ + public function setArrived($arrived) + { + $this->arrived = $arrived; + + return $this; + } + + /** + * Get arrived + * + * @return boolean + */ + public function getArrived() + { + return $this->arrived; + } + + /** + * To string + * + * @return String + */ + public function __toString() { + return $this->getName(); + } + + /** + * is set + */ + public function isNamed($type) { + return $this->gameName !== null; + } + + /** + * Get name + * + * @return string + */ + public function getName() { + if (isset($this->gameName)) { + return $this->gameName; + } else { + return "Manager sans nom"; + } + } +} diff --git a/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php b/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php new file mode 100644 index 00000000..7bcaf68d --- /dev/null +++ b/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php @@ -0,0 +1,15 @@ +placement; } + + /** + * Set manager + * + * @param integer manager + * @return Participant + */ + public function setManager($manager) + { + $manager->setParticipant($this); // One-to-one relationship + $this->manager = $manager; + return $this; + } + + /** + * Get Manager + * + * @return integer + */ + public function getManager() + { + return $this->manager; + } } From 50b8c1247845afc76c77d4b9cbbdcdb32509a221 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Tue, 22 Dec 2015 16:16:31 +0100 Subject: [PATCH 02/19] Generate DoctrineMigration for Managers Fix typo on 'participant' Another typo fixup for migration Another typo fixup for migration - 2nd time --- .../Version20151222161500.php | 35 +++++++++++++++++++ .../TournamentBundle/Entity/Manager.php | 4 +-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 app/DoctrineMigrations/Version20151222161500.php diff --git a/app/DoctrineMigrations/Version20151222161500.php b/app/DoctrineMigrations/Version20151222161500.php new file mode 100644 index 00000000..0baefe94 --- /dev/null +++ b/app/DoctrineMigrations/Version20151222161500.php @@ -0,0 +1,35 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE intra_Manager (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, participant_id INT DEFAULT NULL, game_name VARCHAR(50) NOT NULL, payment_done TINYINT(1) NOT NULL, arrived TINYINT(1) NOT NULL, INDEX IDX_94DDEA20A76ED395 (user_id), UNIQUE INDEX UNIQ_94DDEA20BBABFC4A (participant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); + $this->addSql('ALTER TABLE intra_Manager ADD CONSTRAINT FK_94DDEA20A76ED395 FOREIGN KEY (user_id) REFERENCES intra_User (id)'); + $this->addSql('ALTER TABLE intra_Manager ADD CONSTRAINT FK_94DDEA20BBABFC4A FOREIGN KEY (participant_id) REFERENCES intra_Participant (id)'); + } + + /** + * @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('DROP TABLE intra_Manager'); + } +} diff --git a/src/InsaLan/TournamentBundle/Entity/Manager.php b/src/InsaLan/TournamentBundle/Entity/Manager.php index ca2c32e3..eae9bf34 100644 --- a/src/InsaLan/TournamentBundle/Entity/Manager.php +++ b/src/InsaLan/TournamentBundle/Entity/Manager.php @@ -33,7 +33,7 @@ class Manager * The associated player or team * @ORM\OneToOne(targetEntity="Participant", inversedBy="manager") */ - protected $paticipant; + protected $participant; /** * In-game name of the manager @@ -112,7 +112,7 @@ public function getParticipant() */ public function setParticipant(\InsaLan\TournamentBundle\Entity\Participant $participant = null) { - $this->participant->setManager($this); // One-to-one relationship + $participant->setManager($this); // One-to-one relationship $this->participant = $participant; return $this; } From ffc3bda9af620221d392d6bf579085985870c585 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Mon, 28 Dec 2015 16:08:30 +0100 Subject: [PATCH 03/19] Manager join team with password --- .../Controller/ManagerController.php | 116 ++++++++++++++++++ .../TournamentBundle/Entity/Manager.php | 4 + .../Entity/ManagerRepository.php | 13 ++ 3 files changed, 133 insertions(+) create mode 100644 src/InsaLan/TournamentBundle/Controller/ManagerController.php diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php new file mode 100644 index 00000000..a1cdae9c --- /dev/null +++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php @@ -0,0 +1,116 @@ +getDoctrine()->getManager(); + $usr = $this->get('security.context')->getToken()->getUser(); + + // handle only team tournaments + if($tournament->getParticipantType() !== "team") + throw new ControllerException("Équipes 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, $tournaments); + + if($manager === null) + return $this->redirect($this->generateUrl('insalan_tournament_manager_create', array('tournament' => $tournament->getId()))); + + $form_team = new Team(); + $form = $this->createForm(new TeamLoginType(), $team); // fill name and plainPassword + $form->handleRequest($request); + + // inspired by UserController::joinExistingTeam + // TODO rework this by putting the password hash into the request ? + $error_details = null; + if ($form->isValid()) { + try { + // hash password + $factory = $this->get('security.encoder_factory'); + $encoder = $factory->getEncoder($usr); + $form_team->setPassword($encoder->encodePassword($form_team->getPlainPassword(), sha1('pleaseHashPasswords'.$form_team->getName()))); + $team = $em + ->getRepository('InsaLanTournamentBundle:Manager') + ->findOneByNameAndTournament($form_team->getName(), $tournament); + + if ($team === null || $team->getTournament()->getId() !== $tournament->getId()) + throw new ControllerException("Équipe invalide"); + + if ($team->getPassword() === $form_team->getPassword()) { + // denied if there is already a manager in the team + if ($team->getManager() != null) + throw new ControllerException("L'équipe a déjà un manager"); + + $manager->setParticipant($team); + $team->setManager($manager); + $em->persist($manager); + $em->persist($team); + $em->flush(); + return $this->redirect($this->generateUrl('insalan_tournament_manager_pay', array('tournament' => $tournament->getId()))); + + } else + throw new ControllerException("Mot de passe invalide"); + } catch (ControllerException $e) { + $error_details = $e->getMessage(); + } + + } + return array('tournament' => $tournament, 'user' => $usr, 'player' => $player, 'error' => $error_details, 'form' => $form->createView()); + } + + /** + * Allow a new manager to join a team with a specific token + * @Route("/team/{team}/enroll/{authToken}") + */ + public function joinTeamWithToken() + { + # code ... + } + + /** + * Payment for managers + */ + + +} + +?> \ No newline at end of file diff --git a/src/InsaLan/TournamentBundle/Entity/Manager.php b/src/InsaLan/TournamentBundle/Entity/Manager.php index eae9bf34..742f64f7 100644 --- a/src/InsaLan/TournamentBundle/Entity/Manager.php +++ b/src/InsaLan/TournamentBundle/Entity/Manager.php @@ -14,6 +14,10 @@ */ class Manager { + // Define the price payed by managers + const ONLINE_PRICE = 5; // price to be paid online in EUR + const ONSITE_PRICE = 10; // price to be paid onsite in EUR + /** * @var integer * diff --git a/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php b/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php index 7bcaf68d..53427483 100644 --- a/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php +++ b/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php @@ -12,4 +12,17 @@ */ class ManagerRepository extends EntityRepository { + public function findOneByUserAndPendingTournament(\InsaLan\UserBundle\Entity\User $u, Tournament $t) { + + $q = $this->createQueryBuilder('m') + ->where('m.user = :user AND m.pendingTournament = :tournament') + ->setParameter('user', $u) + ->setParameter('tournament', $t); + + try { + return $q->getQuery()->getSingleResult(); + } catch(\Exception $e) { + return null; + } + } } From 3d059160d833393a0bb84f6c83b928f1e54e792a Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Tue, 29 Dec 2015 15:40:59 +0100 Subject: [PATCH 04/19] Add form for new manager name --- .../TournamentBundle/Form/SetManagerName.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/InsaLan/TournamentBundle/Form/SetManagerName.php diff --git a/src/InsaLan/TournamentBundle/Form/SetManagerName.php b/src/InsaLan/TournamentBundle/Form/SetManagerName.php new file mode 100644 index 00000000..fd39abe1 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Form/SetManagerName.php @@ -0,0 +1,39 @@ +add('gameName') + ; + } + + /** + * @param OptionsResolverInterface $resolver + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'InsaLan\TournamentBundle\Entity\Manager' + )); + } + + /** + * @return string + */ + public function getName() + { + return 'insalan_tournamentbundle_manager'; + } +} From 272352072bf4b2359872ee4fb70f72269a412d51 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Tue, 29 Dec 2015 15:41:14 +0100 Subject: [PATCH 05/19] Add view for new manager name --- .../views/Manager/setManager.html.twig | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/setManager.html.twig diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/setManager.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/setManager.html.twig new file mode 100644 index 00000000..6ed41977 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/setManager.html.twig @@ -0,0 +1,23 @@ +{% extends 'InsaLanTournamentBundle::layout.html.twig' %} + +{% block body %} + {{ parent() }} + +
+ + +
+

Inscription à un tournoi en tant que manager

+
+ +
+ + {% include 'InsaLanTournamentBundle:Part:ChooseGameNameActive.html.twig' with {'counter': 1}%} + +
+
+{% endblock %} \ No newline at end of file From a1fd78059cd8d9f18d6c6edfe04fd87cd4b5c63c Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 30 Dec 2015 09:53:16 +0100 Subject: [PATCH 06/19] Implement manager creation --- .../Controller/ManagerController.php | 37 +++++++++++++++++-- .../Part/ChooseManagerNameActive.html.twig | 16 ++++++++ .../views/Manager/setManager.html.twig | 2 +- 3 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/Part/ChooseManagerNameActive.html.twig diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php index a1cdae9c..eaf4bf01 100644 --- a/src/InsaLan/TournamentBundle/Controller/ManagerController.php +++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php @@ -17,6 +17,7 @@ use InsaLan\TournamentBundle\Form\TeamLoginType; use InsaLan\TournamentBundle\Exception\ControllerException; +use InsaLan\TournamentBundle\Entity\Manager; use InsaLan\TournamentBundle\Entity\Participant; use InsaLan\TournamentBundle\Entity\Tournament; @@ -30,14 +31,39 @@ class ManagerController /** * Create a new manager related to a tournament + * @Route("/{tournament}/user/set") */ - public function createManagerAction() { + public function setNameAction(Request $request, Entity\Tournament $tournament) + { + $em = $this->getDoctrine()->getManager(); + $usr = $this->get('security.context')->getToken()->getUser(); + + $manager = $em->getRepository('InsaLanTournamentBundle:Manager')->findOneByUserAndPendingTournament($usr, $tournament); + + if ($manager === null) { + $manager = new Manager(); + $manager->setUser($usr); + $manager->setPendingTournament($tournament); + } + + $form = $this->createForm(new SetManagerName(), $manager); + $form->handleRequest($request); + if ($form->isValid()) { + $em->persist($manager); + $em->flush(); + + return $this->redirect( + $this->generateUrl('insalan_tournament_manager_jointeamwithpassword', array('tournament' => $tournament->getId())) + ); + } + + return array('form' => $form->createView(), 'selectedGame' => $tournament->getType(), 'tournamentId' => $tournament->getId()); } /** * Allow a new manager to join a team with name and password - * @Route("/tournament/{tournament}/enroll") + * @Route("/{tournament}/user/enroll") */ public function joinTeamWithPassword(Request $request, Entity\Tournament $tournament) { @@ -94,7 +120,7 @@ public function joinTeamWithPassword(Request $request, Entity\Tournament $tourna } } - return array('tournament' => $tournament, 'user' => $usr, 'player' => $player, 'error' => $error_details, 'form' => $form->createView()); + return array('tournament' => $tournament, 'user' => $usr, 'manager' => $manager, 'error' => $error_details, 'form' => $form->createView()); } /** @@ -109,7 +135,10 @@ public function joinTeamWithToken() /** * Payment for managers */ - + public function payAction() + { + # code ... + } } diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/Part/ChooseManagerNameActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/Part/ChooseManagerNameActive.html.twig new file mode 100644 index 00000000..8f49f566 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/Part/ChooseManagerNameActive.html.twig @@ -0,0 +1,16 @@ +
+
+
+ {{ counter }} +
+
Entrez votre pseudonyme en jeu :
+
+
+
+ +
+ +
+ Ok +
+
\ No newline at end of file diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/setManager.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/setManager.html.twig index 6ed41977..c5def602 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/Manager/setManager.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/setManager.html.twig @@ -16,7 +16,7 @@
- {% include 'InsaLanTournamentBundle:Part:ChooseGameNameActive.html.twig' with {'counter': 1}%} + {% include 'InsaLanTournamentBundle:Manager:Part:ChooseManagerNameActive.html.twig' with {'counter': 1}%}
From 6a298029fdd22416f158d27ba2ba8913d902d0ba Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 30 Dec 2015 11:13:44 +0100 Subject: [PATCH 07/19] Add manager naming route --- .../Controller/ManagerController.php | 9 ++++-- .../TournamentBundle/Entity/Manager.php | 29 ++++++++++++++++++- .../ChooseManagerNameActive.html.twig | 2 +- ...setManager.html.twig => setName.html.twig} | 2 +- .../Resources/views/User/index.html.twig | 2 ++ 5 files changed, 38 insertions(+), 6 deletions(-) rename src/InsaLan/TournamentBundle/Resources/views/Manager/{Part => }/ChooseManagerNameActive.html.twig (81%) rename src/InsaLan/TournamentBundle/Resources/views/Manager/{setManager.html.twig => setName.html.twig} (75%) diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php index eaf4bf01..db275c4f 100644 --- a/src/InsaLan/TournamentBundle/Controller/ManagerController.php +++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php @@ -13,25 +13,27 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; -use InsaLan\TournamentBundle\Form\TeamType; +use InsaLan\TournamentBundle\Form\SetManagerName; use InsaLan\TournamentBundle\Form\TeamLoginType; use InsaLan\TournamentBundle\Exception\ControllerException; use InsaLan\TournamentBundle\Entity\Manager; use InsaLan\TournamentBundle\Entity\Participant; use InsaLan\TournamentBundle\Entity\Tournament; +use InsaLan\TournamentBundle\Entity; /** * ManagerController * All the stuff realted to managers management * @Route("/manager") */ -class ManagerController +class ManagerController extends Controller { /** * Create a new manager related to a tournament * @Route("/{tournament}/user/set") + * @Template() */ public function setNameAction(Request $request, Entity\Tournament $tournament) { @@ -43,7 +45,7 @@ public function setNameAction(Request $request, Entity\Tournament $tournament) if ($manager === null) { $manager = new Manager(); $manager->setUser($usr); - $manager->setPendingTournament($tournament); + $manager->setTournament($tournament); } $form = $this->createForm(new SetManagerName(), $manager); @@ -64,6 +66,7 @@ public function setNameAction(Request $request, Entity\Tournament $tournament) /** * Allow a new manager to join a team with name and password * @Route("/{tournament}/user/enroll") + * @Template() */ public function joinTeamWithPassword(Request $request, Entity\Tournament $tournament) { diff --git a/src/InsaLan/TournamentBundle/Entity/Manager.php b/src/InsaLan/TournamentBundle/Entity/Manager.php index 742f64f7..c19c8d69 100644 --- a/src/InsaLan/TournamentBundle/Entity/Manager.php +++ b/src/InsaLan/TournamentBundle/Entity/Manager.php @@ -33,6 +33,12 @@ class Manager */ protected $user; + /** + * The related tournament, used for team filtering + * @var \InsaLan\TournamentBundle\Entity\Tournament + */ + protected $tournament; + /** * The associated player or team * @ORM\OneToOne(targetEntity="Participant", inversedBy="manager") @@ -61,7 +67,6 @@ class Manager */ public function __construct() { - parent::__construct(); $this->paymentDone = false; $this->arrived = false; } @@ -98,6 +103,28 @@ public function setUser(\InsaLan\UserBundle\Entity\User $user = null) return $this; } + /** + * Get tournament + * + * @return \InsaLan\TournamentBundle\Entity\Tournament + */ + public function getTournament() + { + return $this->tournament; + } + + /** + * Set tournament + * + * @param \InsaLan\TournamentBundle\Entity\Tournament $tournament + * @return Manager + */ + public function setTournament(\InsaLan\TournamentBundle\Entity\Tournament $tournament = null) + { + $this->tournament = $tournament; + return $this; + } + /** * Get realted participant * diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/Part/ChooseManagerNameActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/ChooseManagerNameActive.html.twig similarity index 81% rename from src/InsaLan/TournamentBundle/Resources/views/Manager/Part/ChooseManagerNameActive.html.twig rename to src/InsaLan/TournamentBundle/Resources/views/Manager/ChooseManagerNameActive.html.twig index 8f49f566..b15a8ba1 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/Manager/Part/ChooseManagerNameActive.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/ChooseManagerNameActive.html.twig @@ -6,7 +6,7 @@
Entrez votre pseudonyme en jeu :

-
+
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/setManager.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/setName.html.twig similarity index 75% rename from src/InsaLan/TournamentBundle/Resources/views/Manager/setManager.html.twig rename to src/InsaLan/TournamentBundle/Resources/views/Manager/setName.html.twig index c5def602..812df601 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/Manager/setManager.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/setName.html.twig @@ -16,7 +16,7 @@
- {% include 'InsaLanTournamentBundle:Manager:Part:ChooseManagerNameActive.html.twig' with {'counter': 1}%} + {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameActive.html.twig' with {'counter': 1}%}
diff --git a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig index 074d0eb1..e0f7ef5c 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig @@ -143,6 +143,8 @@

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

+
Inscription joueur + Inscription manager

{{ t.teamMinPlayer }} joueur(s) - From 2dc20758dd6357d85255821c32f55e204938f406 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 30 Dec 2015 11:59:21 +0100 Subject: [PATCH 08/19] Fix: missing tournament field in managers Doctrine migration for missing tournament --- .../Version20151230115740.php | 38 +++++++++++++++++++ .../TournamentBundle/Entity/Manager.php | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 app/DoctrineMigrations/Version20151230115740.php diff --git a/app/DoctrineMigrations/Version20151230115740.php b/app/DoctrineMigrations/Version20151230115740.php new file mode 100644 index 00000000..c43a256c --- /dev/null +++ b/app/DoctrineMigrations/Version20151230115740.php @@ -0,0 +1,38 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE intra_Manager ADD tournament_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE intra_Manager ADD CONSTRAINT FK_94DDEA2033D1A3E7 FOREIGN KEY (tournament_id) REFERENCES intra_Tournament (id)'); + $this->addSql('CREATE INDEX IDX_94DDEA2033D1A3E7 ON intra_Manager (tournament_id)'); + } + + /** + * @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_Manager DROP FOREIGN KEY FK_94DDEA2033D1A3E7'); + $this->addSql('DROP INDEX IDX_94DDEA2033D1A3E7 ON intra_Manager'); + $this->addSql('ALTER TABLE intra_Manager DROP tournament_id'); + } +} diff --git a/src/InsaLan/TournamentBundle/Entity/Manager.php b/src/InsaLan/TournamentBundle/Entity/Manager.php index c19c8d69..29b0b014 100644 --- a/src/InsaLan/TournamentBundle/Entity/Manager.php +++ b/src/InsaLan/TournamentBundle/Entity/Manager.php @@ -35,7 +35,7 @@ class Manager /** * The related tournament, used for team filtering - * @var \InsaLan\TournamentBundle\Entity\Tournament + * @ORM\ManyToOne(targetEntity="Tournament") */ protected $tournament; From 76420f991f3daf2754f1b9f501289f4cc6e2fd9a Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 30 Dec 2015 16:37:39 +0100 Subject: [PATCH 09/19] Multiple fixes in manager controller --- .../TournamentBundle/Controller/ManagerController.php | 9 +++++---- .../TournamentBundle/Entity/ManagerRepository.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php index db275c4f..ea852133 100644 --- a/src/InsaLan/TournamentBundle/Controller/ManagerController.php +++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php @@ -20,6 +20,7 @@ use InsaLan\TournamentBundle\Entity\Manager; use InsaLan\TournamentBundle\Entity\Participant; use InsaLan\TournamentBundle\Entity\Tournament; +use InsaLan\TournamentBundle\Entity\Team; use InsaLan\TournamentBundle\Entity; /** @@ -68,7 +69,7 @@ public function setNameAction(Request $request, Entity\Tournament $tournament) * @Route("/{tournament}/user/enroll") * @Template() */ - public function joinTeamWithPassword(Request $request, Entity\Tournament $tournament) + public function joinTeamWithPasswordAction(Request $request, Entity\Tournament $tournament) { $em = $this->getDoctrine()->getManager(); $usr = $this->get('security.context')->getToken()->getUser(); @@ -79,13 +80,13 @@ public function joinTeamWithPassword(Request $request, Entity\Tournament $tourna // check if there is already a pending manager for this user and tournament $manager = $em->getRepository('InsaLanTournamentBundle:Manager') - ->findOneByUserAndPendingTournament($usr, $tournaments); + ->findOneByUserAndPendingTournament($usr, $tournament); if($manager === null) - return $this->redirect($this->generateUrl('insalan_tournament_manager_create', array('tournament' => $tournament->getId()))); + return $this->redirect($this->generateUrl('insalan_tournament_manager_setname', array('tournament' => $tournament->getId()))); $form_team = new Team(); - $form = $this->createForm(new TeamLoginType(), $team); // fill name and plainPassword + $form = $this->createForm(new TeamLoginType(), $form_team); // fill name and plainPassword $form->handleRequest($request); // inspired by UserController::joinExistingTeam diff --git a/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php b/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php index 53427483..d7f054f4 100644 --- a/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php +++ b/src/InsaLan/TournamentBundle/Entity/ManagerRepository.php @@ -15,7 +15,7 @@ class ManagerRepository extends EntityRepository public function findOneByUserAndPendingTournament(\InsaLan\UserBundle\Entity\User $u, Tournament $t) { $q = $this->createQueryBuilder('m') - ->where('m.user = :user AND m.pendingTournament = :tournament') + ->where('m.user = :user AND m.tournament = :tournament') ->setParameter('user', $u) ->setParameter('tournament', $t); From 9790e11cb2c50b20e57c62f770ab69fe10be38c8 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 30 Dec 2015 16:49:48 +0100 Subject: [PATCH 10/19] Add 2nd step views Add validated view for manager name --- .../ChooseManagerNameValidated.html.twig | 11 +++++ .../views/Manager/JoinTeamActive.html.twig | 41 +++++++++++++++++++ .../Manager/joinTeamWithPassword.html.twig | 25 +++++++++++ 3 files changed, 77 insertions(+) create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/ChooseManagerNameValidated.html.twig create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/JoinTeamActive.html.twig create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/joinTeamWithPassword.html.twig diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/ChooseManagerNameValidated.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/ChooseManagerNameValidated.html.twig new file mode 100644 index 00000000..11ac4f51 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/ChooseManagerNameValidated.html.twig @@ -0,0 +1,11 @@ +

+
+
+ {{ counter }} +
+
+ Pseudonyme sélectionné : {{ manager.gameName }} +
+
+
+
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinTeamActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinTeamActive.html.twig new file mode 100644 index 00000000..938e2204 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinTeamActive.html.twig @@ -0,0 +1,41 @@ +{% if error %} +
+
+
+ {{ counter }} +
+
Rejoindre une équipe existante
+
+
+
+

{{ error }}

+
+{% else %} +
+
+
+ {{ counter }} +
+
Rejoindre une équipe existante
+
+
+{% endif %} + + + + {{ form_widget(form._token) }} + {{ form_errors(form) }} + +
+ {{ form_widget(form.name, {'attr': {'placeholder': 'Nom de l\'équipe que vous voulez rejoindre'}}) }} +
+ +
+ {{ form_widget(form.plainPassword, {'attr': {'placeholder': 'Mot de passe'}}) }} +
+ + Annuler + Rejoindre mon équipe +
+ +
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/joinTeamWithPassword.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/joinTeamWithPassword.html.twig new file mode 100644 index 00000000..a1454739 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/joinTeamWithPassword.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:JoinTeamActive.html.twig' with {'counter': 2}%} + +
+
+{% endblock %} From 5b0cb46116202a34731211e398ac88ba61104087 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 30 Dec 2015 17:23:09 +0100 Subject: [PATCH 11/19] Remove player register button when full --- .../TournamentBundle/Resources/views/User/index.html.twig | 2 +- 1 file changed, 1 insertion(+), 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 e0f7ef5c..fa162b03 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig @@ -143,8 +143,8 @@

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

-
Inscription joueur Inscription manager + {% if not t.isFull %}Inscription joueur{% endif %}

{{ t.teamMinPlayer }} joueur(s) - From 385d2c54e1101403cf07703d0bc187113c05ef65 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Thu, 31 Dec 2015 10:38:36 +0100 Subject: [PATCH 12/19] Initiate payment route & view --- .../Controller/ManagerController.php | 25 ++++++++--- .../Manager/BeforePaymentActive.html.twig | 42 +++++++++++++++++++ .../Manager/CreateJoinTeamValidated.html.twig | 9 ++++ .../views/Manager/JoinTeamActive.html.twig | 2 +- .../Resources/views/Manager/pay.html.twig | 31 ++++++++++++++ 5 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/CreateJoinTeamValidated.html.twig create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php index ea852133..e4fc2580 100644 --- a/src/InsaLan/TournamentBundle/Controller/ManagerController.php +++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php @@ -99,7 +99,7 @@ public function joinTeamWithPasswordAction(Request $request, Entity\Tournament $ $encoder = $factory->getEncoder($usr); $form_team->setPassword($encoder->encodePassword($form_team->getPlainPassword(), sha1('pleaseHashPasswords'.$form_team->getName()))); $team = $em - ->getRepository('InsaLanTournamentBundle:Manager') + ->getRepository('InsaLanTournamentBundle:Team') ->findOneByNameAndTournament($form_team->getName(), $tournament); if ($team === null || $team->getTournament()->getId() !== $tournament->getId()) @@ -137,11 +137,26 @@ public function joinTeamWithToken() } /** - * Payment for managers + * Payement doing and details for managers + * @Route("/{tournament}/user/pay/details") + * @Template() */ - public function payAction() - { - # code ... + public function payAction(Entity\Tournament $tournament) { + $em = $this->getDoctrine()->getManager(); + + $usr = $this->get('security.context')->getToken()->getUser(); + $manager = $em + ->getRepository('InsaLanTournamentBundle:Manager') + ->findOneByUserAndPendingTournament($usr, $tournament); + + if($tournament->isFree()) { + $manager->setPaymentDone(true); + $em->persist($manager); + $em->flush(); + return $this->redirect($this->generateUrl('insalan_tournament_manager_paydone', array("tournament" => $tournament->getId()))); + } + + return array('tournament' => $tournament, 'user' => $usr, 'manager' => $manager); } } diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig new file mode 100644 index 00000000..28c3141f --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig @@ -0,0 +1,42 @@ +

+
+
+ {{ counter }} +
+
Récapitulatif avant paiement
+
+
+
+ + + + + + + + + +
Prix de la place{{ constant('ONLINE_PRICE', manager) }} {{ tournament.currency }}
Majoration si paiement en ligne{{ tournament.onlineIncreaseInPrice }} {{ tournament.currency }}
+
+ +
+ + {% if tournament.participantType == 'team' %} + Annuler + {% else %} + Annuler + {% endif %} + + {% if manager.participant.validated %} + + Chèque/Sur place + Paiement en ligne + + {% else %} + + L'équipe choisie n'est pas validée ! + + {% endif %} + +
+
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/CreateJoinTeamValidated.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/CreateJoinTeamValidated.html.twig new file mode 100644 index 00000000..798a0871 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/CreateJoinTeamValidated.html.twig @@ -0,0 +1,9 @@ +
+
+
+ {{ counter }} +
+
Équipe sélectionnée : {{ manager.participant }}
+
+
+
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinTeamActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinTeamActive.html.twig index 938e2204..3aeb3cd1 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinTeamActive.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/JoinTeamActive.html.twig @@ -21,7 +21,7 @@ {% endif %} -
+ {{ form_widget(form._token) }} {{ form_errors(form) }} diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig new file mode 100644 index 00000000..829327e6 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig @@ -0,0 +1,31 @@ +{% extends 'InsaLanTournamentBundle::layout.html.twig' %} + +{% block body %} +{{ parent() }} + +
+ + +
+

Inscription à « {{ tournament.name }} »

+ {{ tournament.description }} +
+ +
+ + {% if tournament.participantType == 'team' %} + {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameValidated.html.twig' with {'counter': 1}%} + {% include 'InsaLanTournamentBundle:Manager:CreateJoinTeamValidated.html.twig' with {'counter': 2}%} + {% include 'InsaLanTournamentBundle:Part:BeforePaymentActive.html.twig' with {'counter': 3}%} + {% else %} + {% include 'InsaLanTournamentBundle:Part:ChooseGameNameValidated.html.twig' with {'counter': 1}%} + {% include 'InsaLanTournamentBundle:Part:BeforePaymentActive.html.twig' with {'counter': 2} %} + {% endif %} + +
+
+{% endblock %} From 6a5afa83a42016ec0280929b881078b48021366c Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Thu, 31 Dec 2015 16:27:46 +0100 Subject: [PATCH 13/19] SIGSEGEV: PHP is so broken --- .../Resources/views/Manager/BeforePaymentActive.html.twig | 2 +- .../TournamentBundle/Resources/views/Manager/pay.html.twig | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig index 28c3141f..524dcb6d 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig @@ -10,7 +10,7 @@ - + diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig index 829327e6..c728b2de 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig @@ -20,10 +20,11 @@ {% if tournament.participantType == 'team' %} {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameValidated.html.twig' with {'counter': 1}%} {% include 'InsaLanTournamentBundle:Manager:CreateJoinTeamValidated.html.twig' with {'counter': 2}%} - {% include 'InsaLanTournamentBundle:Part:BeforePaymentActive.html.twig' with {'counter': 3}%} + {% include 'InsaLanTournamentBundle:Manager:BeforePaymentActive.html.twig' with {'counter': 3}%} {% else %} - {% include 'InsaLanTournamentBundle:Part:ChooseGameNameValidated.html.twig' with {'counter': 1}%} - {% include 'InsaLanTournamentBundle:Part:BeforePaymentActive.html.twig' with {'counter': 2} %} + {% 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} %} {% endif %} From 5d918e2293a185c2e05aa3ceb7513140ed2d2dc7 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Thu, 31 Dec 2015 18:53:34 +0100 Subject: [PATCH 14/19] Fix infinite loop in OtO relation --- .../TournamentBundle/Controller/ManagerController.php | 7 ++++++- src/InsaLan/TournamentBundle/Entity/Manager.php | 1 - src/InsaLan/TournamentBundle/Entity/Participant.php | 1 - .../Resources/views/Manager/BeforePaymentActive.html.twig | 2 +- .../TournamentBundle/Resources/views/Manager/pay.html.twig | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php index e4fc2580..eedaaa9d 100644 --- a/src/InsaLan/TournamentBundle/Controller/ManagerController.php +++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php @@ -110,11 +110,16 @@ public function joinTeamWithPasswordAction(Request $request, Entity\Tournament $ if ($team->getManager() != null) throw new ControllerException("L'équipe a déjà un manager"); - $manager->setParticipant($team); + // Because PHP don't support polymorphism, we must get the corresponding Participant object + $team_participant = $em + ->getRepository('InsaLanTournamentBundle:Participant')-> + findOneById($team->getId()); + $manager->setParticipant($team_participant); $team->setManager($manager); $em->persist($manager); $em->persist($team); $em->flush(); + return $this->redirect($this->generateUrl('insalan_tournament_manager_pay', array('tournament' => $tournament->getId()))); } else diff --git a/src/InsaLan/TournamentBundle/Entity/Manager.php b/src/InsaLan/TournamentBundle/Entity/Manager.php index 29b0b014..ddd17a0e 100644 --- a/src/InsaLan/TournamentBundle/Entity/Manager.php +++ b/src/InsaLan/TournamentBundle/Entity/Manager.php @@ -143,7 +143,6 @@ public function getParticipant() */ public function setParticipant(\InsaLan\TournamentBundle\Entity\Participant $participant = null) { - $participant->setManager($this); // One-to-one relationship $this->participant = $participant; return $this; } diff --git a/src/InsaLan/TournamentBundle/Entity/Participant.php b/src/InsaLan/TournamentBundle/Entity/Participant.php index 37129cd6..e7967358 100644 --- a/src/InsaLan/TournamentBundle/Entity/Participant.php +++ b/src/InsaLan/TournamentBundle/Entity/Participant.php @@ -202,7 +202,6 @@ public function getPlacement() */ public function setManager($manager) { - $manager->setParticipant($this); // One-to-one relationship $this->manager = $manager; return $this; } diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig index 524dcb6d..28c3141f 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig @@ -10,7 +10,7 @@
Prix de la place{{ constant('ONLINE_PRICE', manager) }} {{ tournament.currency }}{{ 5 }} {{ tournament.currency }}
Majoration si paiement en ligne
- + diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig index c728b2de..d25a94d7 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/pay.html.twig @@ -11,7 +11,7 @@
-

Inscription à « {{ tournament.name }} »

+

Inscription à « {{ tournament.name }} » en tant que manager

{{ tournament.description }}
From 4f08933184a6386e00e7b21de5bdc15977775f44 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Fri, 1 Jan 2016 18:53:42 +0100 Subject: [PATCH 15/19] Manager payment views --- .../Controller/ManagerController.php | 107 +++++++++++++++++- .../Manager/AfterPaymentActive.html.twig | 94 +++++++++++++++ .../Manager/BeforePaymentValidated.html.twig | 13 +++ .../views/Manager/WaitPaymentActive.html.twig | 35 ++++++ .../Resources/views/Manager/payDone.html.twig | 33 ++++++ .../views/Manager/payOffline.html.twig | 34 ++++++ 6 files changed, 315 insertions(+), 1 deletion(-) create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/AfterPaymentActive.html.twig create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentValidated.html.twig create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/WaitPaymentActive.html.twig create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/payDone.html.twig create mode 100644 src/InsaLan/TournamentBundle/Resources/views/Manager/payOffline.html.twig diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php index eedaaa9d..2345f3a9 100644 --- a/src/InsaLan/TournamentBundle/Controller/ManagerController.php +++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php @@ -164,6 +164,111 @@ public function payAction(Entity\Tournament $tournament) { return array('tournament' => $tournament, 'user' => $usr, 'manager' => $manager); } + /** + * Paypal stuff + * @Route("/{tournament}/user/pay/paypal_ec") + */ + public function payPaypalECAction(Entity\Tournament $tournament) { + $em = $this->getDoctrine()->getManager(); + + $usr = $this->get('security.context')->getToken()->getUser(); + $manager = $em + ->getRepository('InsaLanTournamentBundle:Manager') + ->findOneByUserAndPendingTournament($usr, $tournament); + + $paymentName = 'paypal_express_checkout_and_doctrine_orm'; + + $price = ($manager::ONLINE_PRICE + $tournament->getOnlineIncreaseInPrice()); + + $storage = $this->get('payum')->getStorage('InsaLan\UserBundle\Entity\PaymentDetails'); + $order = $storage->createModel(); + $order->setUser($usr); + + $order['PAYMENTREQUEST_0_CURRENCYCODE'] = $tournament->getCurrency(); + $order['PAYMENTREQUEST_0_AMT'] = $price; + + $order['L_PAYMENTREQUEST_0_NAME0'] = 'Place manager pour le tournoi '.$tournament->getName(); + $order['L_PAYMENTREQUEST_0_AMT0'] = $manager::ONLINE_PRICE; + $order['L_PAYMENTREQUEST_0_DESC0'] = $tournament->getDescription(); + $order['L_PAYMENTREQUEST_0_NUMBER0'] = 1; + + $order['L_PAYMENTREQUEST_0_NAME1'] = 'Majoration paiement en ligne'; + $order['L_PAYMENTREQUEST_0_AMT1'] = $tournament->getOnlineIncreaseInPrice(); + $order['L_PAYMENTREQUEST_0_DESC1'] = 'Frais de gestion du paiement'; + $order['L_PAYMENTREQUEST_0_NUMBER1'] = 1; + + $storage->updateModel($order); + + $payment = $this->get('payum')->getPayment('paypal_express_checkout_and_doctrine_orm'); + $captureToken = $this->get('payum.security.token_factory')->createCaptureToken( + $paymentName, + $order, + 'insalan_tournament_manager_paydonetemp', + array('tournament' => $tournament->getId()) + ); + + $order['RETURNURL'] = $captureToken->getTargetUrl(); + $order['CANCELURL'] = $captureToken->getTargetUrl(); + $order['INVNUM'] = $usr->getId(); + $storage->updateModel($order); + return $this->redirect($captureToken->getTargetUrl()); + } + + /** + * Payment sum up + * @Route("/{tournament}/user/pay/done") + * @Template() + */ + public function payDoneAction(Request $request, Entity\Tournament $tournament) { + $em = $this->getDoctrine()->getManager(); + $usr = $this->get('security.context')->getToken()->getUser(); + $manager = $em + ->getRepository('InsaLanTournamentBundle:Manager') + ->findOneByUserAndPendingTournament($usr, $tournament); + + return array('tournament' => $tournament, 'user' => $usr, 'manager' => $manager); + } + + /** + * @Route("/{tournament}/user/pay/done_temp") + */ + public function payDoneTempAction(Request $request, Entity\Tournament $tournament) { + $em = $this->getDoctrine()->getManager(); + $usr = $this->get('security.context')->getToken()->getUser(); + $player = $em + ->getRepository('InsaLanTournamentBundle:Manager') + ->findOneByUserAndPendingTournament($usr, $tournament); + + $token = $this->get('payum.security.http_request_verifier')->verify($request); + $payment = $this->get('payum')->getPayment($token->getPaymentName()); + + //$this->get('payum.security.http_request_verifier')->invalidate($token); + + $payment->execute($status = new GetHumanStatus($token)); + + if ($status->isCaptured()) { + $player->setPaymentDone(true); + $em->persist($player); + $em->flush(); + } + return $this->redirect($this->generateUrl('insalan_tournament_manager_paydone', array('tournament' => $tournament->getId()))); + } + + /** + * Offer offline payment choices + * @Route("/{tournament}/user/pay/offline") + * @Template() + */ + public function payOfflineAction(Request $request, Entity\Tournament $tournament) { + $em = $this->getDoctrine()->getManager(); + $usr = $this->get('security.context')->getToken()->getUser(); + $player = $em + ->getRepository('InsaLanTournamentBundle:Manager') + ->findOneByUserAndPendingTournament($usr, $tournament); + + return array('tournament' => $tournament, 'user' => $usr, 'manager' => $manager); + } + } -?> \ No newline at end of file +?> diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/AfterPaymentActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/AfterPaymentActive.html.twig new file mode 100644 index 00000000..2fa3b880 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/AfterPaymentActive.html.twig @@ -0,0 +1,94 @@ +{% if manager.paymentDone %} +
+
+
+ {{ counter }} +
+ {% if tournament.free %} +
Inscription manager terminée
+ {% else %} +
Paiement validé
+ {% endif %} +
+
+
+ {% if tournament.free %} + Votre inscription en tant que manager est validée. Si vous êtes en équipe, votre équipe sera validée quand plus de la moitié des joueurs auront validé leur inscription. + {% else %} + Votre paiement a été validé. + {% endif %} + + Ces informations vous seront utiles plus tard : +
+
Prix de la place{{ 5 }} {{ tournament.currency }}{{ constant('ONLINE_PRICE', manager) }} {{ tournament.currency }}
Majoration si paiement en ligne
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Nom de votre compte insalan.fr + + {{ user.username }} +
+ Email de contact + + {{ user.email }} +
+ Tournoi + + {{ tournament.name }} +
+ Pseudonyme en jeu + + {{ manager.name }} +
+ Début du tournoi + + Le {{ tournament.tournamentOpen|date('d/m/Y à H:i') }} +
+ Fin du tournoi + + Le {{ tournament.tournamentClose|date('d/m/Y à H:i') }} +
+ +
+ Ok +
+
+{% else %} +
+
+
+ {{ counter }} +
+
Echec du paiement
+
+
+
+ Une erreur est survenue. Vous pouvez contacter un administrateur via contact@insalan.fr ou au 06 29 57 89 95. +
+ Réessayer +
+{% endif %} diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentValidated.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentValidated.html.twig new file mode 100644 index 00000000..df282800 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentValidated.html.twig @@ -0,0 +1,13 @@ +
+
+
+ {{ counter }} +
+ {% if tournament.free %} +
Tournoi gratuit, pas de paiement
+ {% else %} +
Récapitulatif avant paiement
+ {% endif %} +
+
+
diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/WaitPaymentActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/WaitPaymentActive.html.twig new file mode 100644 index 00000000..fe5a1d70 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/WaitPaymentActive.html.twig @@ -0,0 +1,35 @@ +
+
+
+ {{ counter }} +
+
Paiement en attente
+
+
+
+ + Paiement par chèque
+ Vous devez envoyer un chèque de {{ constant('ONLINE_PRICE', manager) }}€ à l'ordre de "AEIR InsaLan" par la poste à l'adresse suivante : +
+ Vincent Giraud
+ DB104 INSA Rennes
+ 20 avenue des Buttes de Coësmes CS 70839
+ 35708 Rennes CEDEX 7
+
+ Votre inscription sera validé par le staff à la réception du chèque. + + Paiement sur place
+ Le tarif manager sur place s'élève à {{ constant('ONSITE_PRICE', manager) }}€.
+ Vous pourrez régler sur place en liquide, par chèque ou par carte bancaire (avec une majoration de 1€ pour la CB).
+

+ + Points importants
+
    +
  • Si vous coachez une équipe, celle-ci ne doit pas comporter de remplaçant afin que vous ayez la place de vous installer.
  • +
+
+
+ Ok +
+
+ diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/payDone.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/payDone.html.twig new file mode 100644 index 00000000..19c72923 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/payDone.html.twig @@ -0,0 +1,33 @@ +{% extends 'InsaLanTournamentBundle::layout.html.twig' %} + +{% block body %} +{{ parent() }} + +
+ + +
+

Inscription à « {{ tournament.name }} » en tant que manager

+ {{ tournament.description }} +
+ +
+ + {% if tournament.participantType == 'team' %} + {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameValidated.html.twig' with {'counter': 1}%} + {% include 'InsaLanTournamentBundle:Manager:CreateJoinTeamValidated.html.twig' with {'counter': 2}%} + {% 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} %} + {% endif %} + +
+
+{% endblock %} diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/payOffline.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/payOffline.html.twig new file mode 100644 index 00000000..f71e9f3e --- /dev/null +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/payOffline.html.twig @@ -0,0 +1,34 @@ +{% extends 'InsaLanTournamentBundle::layout.html.twig' %} + +{% block body %} +{{ parent() }} + +
+ + +
+

Inscription à « {{ tournament.name }} »

+ {{ tournament.description }} +
+ +
+ + {% if tournament.participantType == 'team' %} + {% include 'InsaLanTournamentBundle:Part:ChooseGameNameValidated.html.twig' with {'counter': 1} %} + {% include 'InsaLanTournamentBundle:Part:ChoiceTeamValidated.html.twig' with {'counter': 2} %} + {% include 'InsaLanTournamentBundle:Part:CreateJoinTeamValidated.html.twig' with {'counter': 3} %} + {% include 'InsaLanTournamentBundle:Part:BeforePaymentValidated.html.twig' with {'counter': 4} %} + {% include 'InsaLanTournamentBundle:Part:WaitPaymentActive.html.twig' with {'counter': 5} %} + {% else %} + {% include 'InsaLanTournamentBundle:Part:ChooseGameNameValidated.html.twig' with {'counter': 1} %} + {% include 'InsaLanTournamentBundle:Part:BeforePaymentValidated.html.twig' with {'counter': 2} %} + {% include 'InsaLanTournamentBundle:Part:WaitPaymentActive.html.twig' with {'counter': 3} %} + {% endif %} + +
+
+{% endblock %} From 271e7445aaa8b9046781175a14c4937ab8cf3aef Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Thu, 7 Jan 2016 23:27:24 +0100 Subject: [PATCH 16/19] Fix payment templates & leave route --- .../Controller/ManagerController.php | 75 ++++++++++++++++++- .../Manager/BeforePaymentActive.html.twig | 8 +- .../views/Manager/payOffline.html.twig | 15 ++-- 3 files changed, 85 insertions(+), 13 deletions(-) diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php index 2345f3a9..51b0a505 100644 --- a/src/InsaLan/TournamentBundle/Controller/ManagerController.php +++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php @@ -13,6 +13,14 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Payum\Core\Model\Order; +use Payum\Core\Reply\HttpRedirect; +use Payum\Core\Reply\HttpResponse; +use Payum\Core\Request\Capture; +use Payum\Core\Request\GetHumanStatus; +use Payum\Offline\PaymentFactory as OfflinePaymentFactory; +use Payum\Paypal\ExpressCheckout\Nvp\Api; + use InsaLan\TournamentBundle\Form\SetManagerName; use InsaLan\TournamentBundle\Form\TeamLoginType; use InsaLan\TournamentBundle\Exception\ControllerException; @@ -262,12 +270,77 @@ public function payDoneTempAction(Request $request, Entity\Tournament $tournamen public function payOfflineAction(Request $request, Entity\Tournament $tournament) { $em = $this->getDoctrine()->getManager(); $usr = $this->get('security.context')->getToken()->getUser(); - $player = $em + $manager = $em ->getRepository('InsaLanTournamentBundle:Manager') ->findOneByUserAndPendingTournament($usr, $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") + */ + public function leaveAction(Entity\Tournament $tournament) { + $em = $this->getDoctrine()->getManager(); + + $usr = $this->get('security.context')->getToken()->getUser(); + $manager = $em + ->getRepository('InsaLanTournamentBundle:Manager') + ->findOneByUserAndPendingTournament($usr, $tournament); + + if($manager->getTournament()->getParticipantType() !== "player") + throw new ControllerException("Not Allowed"); // must be a player only tournament + + $em->remove($manager); + $em->flush(); + + return $this->redirect($this->generateUrl('insalan_tournament_user_index')); + } + + /** + * Allow a manager to drop a pending tournament registration managed by teams + * @Route("/user/leave/team/{teamId}") + * @Template() + */ + public function leaveTeamAction($teamId) { + $em = $this->getDoctrine()->getManager(); + $team = $em + ->getRepository('InsaLanTournamentBundle:Team') + ->findOneById($teamId); + + if($team === null) + return $this->redirect($this->generateUrl('insalan_tournament_user_index')); + + // get targeted manager + $usr = $this->get('security.context')->getToken()->getUser(); + $manager = $em + ->getRepository('InsaLanTournamentBundle:Manager') + ->findOneByUserAndPendingTournament($usr, $team->getTournament()); + + // is he part of the team roster ? + if($team->getManager() != $manager) + return $this->redirect($this->generateUrl('insalan_tournament_user_index')); + + // not allowed if he paid something + if(!$team->getTournament()->isFree() && $manager->getPaymentDone()){ + $this->get('session')->getFlashBag()->add('error', "Vous avez payé votre place, merci de contacter l'équipe si vous souhaitez vous désistez."); + return $this->redirect($this->generateUrl('insalan_tournament_user_index')); + } + // not allowed either if registration are closed + if(!$team->getTournament()->isOpenedNow()) + return $this->redirect($this->generateUrl('insalan_tournament_user_index')); + + // TODO + // $manager->setParticipant(null); + // $team->setManager(null); + + $em->persist($team); + + $em->remove($player); + $em->flush(); + return $this->redirect($this->generateUrl('insalan_tournament_user_index')); + } } diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig index 28c3141f..c635fa94 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/BeforePaymentActive.html.twig @@ -22,15 +22,15 @@ {% if tournament.participantType == 'team' %} - Annuler + Annuler {% else %} - Annuler + Annuler {% endif %} {% if manager.participant.validated %} - Chèque/Sur place - Paiement en ligne + Chèque/Sur place + Paiement en ligne {% else %} diff --git a/src/InsaLan/TournamentBundle/Resources/views/Manager/payOffline.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Manager/payOffline.html.twig index f71e9f3e..f53214c1 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/Manager/payOffline.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/Manager/payOffline.html.twig @@ -18,15 +18,14 @@
{% if tournament.participantType == 'team' %} - {% include 'InsaLanTournamentBundle:Part:ChooseGameNameValidated.html.twig' with {'counter': 1} %} - {% include 'InsaLanTournamentBundle:Part:ChoiceTeamValidated.html.twig' with {'counter': 2} %} - {% include 'InsaLanTournamentBundle:Part:CreateJoinTeamValidated.html.twig' with {'counter': 3} %} - {% include 'InsaLanTournamentBundle:Part:BeforePaymentValidated.html.twig' with {'counter': 4} %} - {% include 'InsaLanTournamentBundle:Part:WaitPaymentActive.html.twig' with {'counter': 5} %} + {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameValidated.html.twig' with {'counter': 1} %} + {% include 'InsaLanTournamentBundle:Manager:CreateJoinTeamValidated.html.twig' with {'counter': 3} %} + {% include 'InsaLanTournamentBundle:Manager:BeforePaymentValidated.html.twig' with {'counter': 4} %} + {% include 'InsaLanTournamentBundle:Manager:WaitPaymentActive.html.twig' with {'counter': 5} %} {% else %} - {% include 'InsaLanTournamentBundle:Part:ChooseGameNameValidated.html.twig' with {'counter': 1} %} - {% include 'InsaLanTournamentBundle:Part:BeforePaymentValidated.html.twig' with {'counter': 2} %} - {% include 'InsaLanTournamentBundle:Part:WaitPaymentActive.html.twig' with {'counter': 3} %} + {% include 'InsaLanTournamentBundle:Manager:ChooseManagerNameValidated.html.twig' with {'counter': 1} %} + {% include 'InsaLanTournamentBundle:Manager:BeforePaymentValidated.html.twig' with {'counter': 2} %} + {% include 'InsaLanTournamentBundle:Manager:WaitPaymentActive.html.twig' with {'counter': 3} %} {% endif %}
From 844a3ed63172f74e916bd53d3ecb002e82273dbc Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Sat, 9 Jan 2016 19:48:22 +0100 Subject: [PATCH 17/19] Manager integration into tournament index --- .../Controller/ManagerController.php | 40 ++++++++++++++----- .../Controller/UserController.php | 4 +- .../TournamentBundle/Entity/Manager.php | 4 ++ .../Entity/ParticipantRepository.php | 21 +++++++++- .../Resources/views/User/index.html.twig | 36 ++++++++++++----- 5 files changed, 83 insertions(+), 22 deletions(-) diff --git a/src/InsaLan/TournamentBundle/Controller/ManagerController.php b/src/InsaLan/TournamentBundle/Controller/ManagerController.php index 51b0a505..7284b9db 100644 --- a/src/InsaLan/TournamentBundle/Controller/ManagerController.php +++ b/src/InsaLan/TournamentBundle/Controller/ManagerController.php @@ -39,6 +39,29 @@ class ManagerController extends Controller { + /** + * Manage all steps for registering into a tournament as manager + * @Route("/{tournament}/user/enroll") + */ + public function enrollAction(Request $request, Entity\Tournament $tournament) { + $em = $this->getDoctrine()->getManager(); + + $usr = $this->get('security.context')->getToken()->getUser(); + + $manager = $em + ->getRepository('InsaLanTournamentBundle:Manager') + ->findOneByUserAndPendingTournament($usr, $tournament); + + if ($manager === null) + return $this->redirect($this->generateUrl('insalan_tournament_manager_setname',array('tournament' => $tournament->getId()))); + else if ($tournament->getParticipantType() === 'team' && $manager->getParticipant() === null) + return $this->redirect($this->generateUrl('insalan_tournament_manager_jointeamwithpassword',array('tournament' => $tournament->getId()))); + else if (!$manager->getPaymentDone()) + return $this->redirect($this->generateUrl('insalan_tournament_manager_pay',array('tournament' => $tournament->getId()))); + else + return $this->redirect($this->generateUrl('insalan_tournament_manager_paydone',array('tournament' => $tournament->getId()))); + } + /** * Create a new manager related to a tournament * @Route("/{tournament}/user/set") @@ -74,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/enroll") + * @Route("/{tournament}/user/setname") * @Template() */ public function joinTeamWithPasswordAction(Request $request, Entity\Tournament $tournament) @@ -238,6 +261,7 @@ public function payDoneAction(Request $request, Entity\Tournament $tournament) { } /** + * Perform payment validation * @Route("/{tournament}/user/pay/done_temp") */ public function payDoneTempAction(Request $request, Entity\Tournament $tournament) { @@ -324,20 +348,18 @@ public function leaveTeamAction($teamId) { // not allowed if he paid something if(!$team->getTournament()->isFree() && $manager->getPaymentDone()){ - $this->get('session')->getFlashBag()->add('error', "Vous avez payé votre place, merci de contacter l'équipe si vous souhaitez vous désistez."); + $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(!$team->getTournament()->isOpenedNow()) - return $this->redirect($this->generateUrl('insalan_tournament_user_index')); - - // TODO - // $manager->setParticipant(null); - // $team->setManager(null); + return $this->redirect($this->generateUrl('insalan_tournament_user_index')); - $em->persist($team); + $manager->setParticipant(null); + $team->setManager(null); - $em->remove($player); + $em->persist($team); + $em->remove($manager); $em->flush(); return $this->redirect($this->generateUrl('insalan_tournament_user_index')); } diff --git a/src/InsaLan/TournamentBundle/Controller/UserController.php b/src/InsaLan/TournamentBundle/Controller/UserController.php index 56ec6921..87283c06 100644 --- a/src/InsaLan/TournamentBundle/Controller/UserController.php +++ b/src/InsaLan/TournamentBundle/Controller/UserController.php @@ -55,7 +55,7 @@ public function indexAction() { } $rawTournaments = $em->getRepository('InsaLanTournamentBundle:Tournament')->findThisYearTournaments(); - // participants can be either a single player of a team + // participants can be either a single player, a team or a manager $participants = $em->getRepository('InsaLanTournamentBundle:Participant')->findByUser($usr); $tournaments = array(); @@ -454,7 +454,7 @@ public function leaveTeamAction($teamId) { // not allowed if he paid something if(!$team->getTournament()->isFree() && $player->getPaymentDone()){ - $this->get('session')->getFlashBag()->add('error', "Vous avez payé votre place, merci de contacter l'équipe si vous souhaitez vous désistez."); + $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 diff --git a/src/InsaLan/TournamentBundle/Entity/Manager.php b/src/InsaLan/TournamentBundle/Entity/Manager.php index ddd17a0e..2296f466 100644 --- a/src/InsaLan/TournamentBundle/Entity/Manager.php +++ b/src/InsaLan/TournamentBundle/Entity/Manager.php @@ -62,6 +62,10 @@ class Manager */ protected $arrived; + public function getParticipantType() { + return "manager"; + } + /** * Constructor */ diff --git a/src/InsaLan/TournamentBundle/Entity/ParticipantRepository.php b/src/InsaLan/TournamentBundle/Entity/ParticipantRepository.php index c5e15d8b..e8b47b3f 100644 --- a/src/InsaLan/TournamentBundle/Entity/ParticipantRepository.php +++ b/src/InsaLan/TournamentBundle/Entity/ParticipantRepository.php @@ -37,8 +37,25 @@ public function findByUser(\InsaLan\UserBundle\Entity\User $u) { $query->execute(); $result2 = $query->getResult(); + + $query = $em->createQuery(" + SELECT pa + FROM InsaLanTournamentBundle:Participant pa, + InsaLanTournamentBundle:Manager ma + + JOIN ma.participant t + + WHERE ma.user = :user + AND pa.id = t.id + AND pa.tournament IS NOT NULL + ")->setParameter('user', $u); + + $query->execute(); + + $result3 = $query->getResult(); + - return new ArrayCollection(array_merge($result1, $result2)); + return new ArrayCollection(array_merge($result1, $result2, $result3)); } @@ -53,4 +70,4 @@ public function findOneByUserAndTournament(\InsaLan\UserBundle\Entity\User $u, T return null; } -} \ No newline at end of file +} diff --git a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig index fa162b03..bf954c03 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig @@ -56,6 +56,16 @@
{% endfor %} + {% if participant.manager is not null %} +
  • + {% if participant.manager.ok %} + + {% else %} + + {% endif %} + {{ participant.manager.gameName }} [Manager] +
  • + {% endif %} {% endif %} @@ -85,8 +95,16 @@ {% endif %} - {% if participant.validated == 2 %} + {% if participant.participantType == 'team' and participant.manager.user == app.user %} + {# 2-button layout #}{% if participant.tournament.isOpenedNow %} + Annuler + Mon inscription + {# tournament is closed #}{% else %} + Inscription archivée + {% endif %} + {% else %} + {% if participant.validated == 2 %} {# 2-button layout #}{% if participant.tournament.isPlaying %} Jouer mes matchs Mon inscription @@ -104,14 +122,14 @@ Inscription archivée {% endif %} - {% else %} - {# 2-button layout #}{% if participant.tournament.isOpenedNow %} - Annuler - Mon inscription - {% endif %} - {% endif %}{# endif validated == 2 #} - - + {# endif validated == 2 #} + {% else %} {# over validation status #} + {# 2-button layout #}{% if participant.tournament.isOpenedNow %} + Annuler + Mon inscription + {% endif %} + {% endif %} + {% endif %}{# endif not a manager #}
    From ee0dd5beb63a9d1aa6e1e7576febb0739ce2114e Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Sat, 9 Jan 2016 19:53:28 +0100 Subject: [PATCH 18/19] Fix team index when no manager is set --- .../TournamentBundle/Resources/views/User/index.html.twig | 2 +- 1 file changed, 1 insertion(+), 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 bf954c03..5aad60ba 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig @@ -95,7 +95,7 @@ {% endif %} - {% if participant.participantType == 'team' and participant.manager.user == app.user %} + {% if participant.participantType == 'team' and participant.manager is not null and participant.manager.user == app.user %} {# 2-button layout #}{% if participant.tournament.isOpenedNow %} Annuler Mon inscription From 8795d19c3bfc2cdbfb8a793cb6d936048f6f47e9 Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Sat, 9 Jan 2016 20:10:40 +0100 Subject: [PATCH 19/19] Differenciate managers in team list * Center manager in index view * Put managers in italics --- .../TournamentBundle/Resources/views/User/index.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig index 5aad60ba..3b7be2f3 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig @@ -57,13 +57,13 @@ {% endfor %} {% if participant.manager is not null %} -
  • +
  • {% if participant.manager.ok %} {% else %} {% endif %} - {{ participant.manager.gameName }} [Manager] + {{ participant.manager.gameName }} [Manager]
  • {% endif %}