Skip to content
Browse files

Merge branch '1.3' of github.com:clubmaster/clubmaster into 1.3

  • Loading branch information...
2 parents def27df + 56fdcd0 commit ca02f818db0e336b6995bcaf26372f1f26b47676 @hollodk hollodk committed May 8, 2012
Showing with 271 additions and 129 deletions.
  1. +29 −0 src/Club/LayoutBundle/Resources/translations/messages.da.xliff
  2. +38 −0 src/Club/MailBundle/Listener/RequestComment.php
  3. +5 −0 src/Club/MailBundle/Resources/config/listener.yml
  4. +2 −2 src/Club/MailBundle/Resources/views/Template/request_comment.html.twig
  5. +3 −0 src/Club/RequestBundle/Controller/CommentController.php
  6. +8 −0 src/Club/RequestBundle/Event/Events.php
  7. +19 −0 src/Club/RequestBundle/Event/FilterRequestCommentEvent.php
  8. +2 −2 src/Club/RequestBundle/Resources/views/Comment/index.html.twig
  9. +0 −1 src/Club/RequestBundle/Resources/views/PlayerMarket/edit.html.twig
  10. +7 −7 src/Club/RequestBundle/Resources/views/PlayerMarket/index.html.twig
  11. +0 −1 src/Club/RequestBundle/Resources/views/PlayerMarket/new.html.twig
  12. +1 −1 src/Club/RequestBundle/Resources/views/base.html.twig
  13. +0 −1 src/Club/TODO
  14. +40 −17 src/Club/TournamentBundle/Controller/TournamentController.php
  15. +2 −2 src/Club/TournamentBundle/DependencyInjection/ClubTournamentExtension.php
  16. +52 −0 src/Club/TournamentBundle/Helper/Tournament.php
  17. +0 −20 src/Club/TournamentBundle/Resources/config/services.xml
  18. +4 −0 src/Club/TournamentBundle/Resources/config/services.yml
  19. +0 −9 src/Club/TournamentBundle/Resources/public/css/bracket.css
  20. +32 −51 src/Club/TournamentBundle/Resources/views/Tournament/index.html.twig
  21. +3 −0 src/Club/TournamentBundle/Resources/views/base.html.twig
  22. +3 −9 src/Club/UserBundle/Controller/UserController.php
  23. +17 −3 src/Club/UserBundle/Entity/Profile.php
  24. +1 −1 src/Club/UserBundle/Entity/ProfileEmail.php
  25. +1 −1 src/Club/UserBundle/Entity/User.php
  26. +2 −1 src/Club/UserBundle/Form/AdminProfile.php
View
29 src/Club/LayoutBundle/Resources/translations/messages.da.xliff
@@ -2454,6 +2454,35 @@
<source>Choose shipping</source>
<target>Vælg fragt</target>
</trans-unit>
+ <trans-unit id="618">
+ <source>Player market</source>
+ <target>Spillermarked</target>
+ </trans-unit>
+ <trans-unit id="619">
+ <source>Create comment</source>
+ <target>Opret kommentar</target>
+ </trans-unit>
+ <trans-unit id="620">
+ <source>Play time</source>
+ <target>Spilletid</target>
+ </trans-unit>
+ <trans-unit id="621">
+ <source>There are no comments for this request.</source>
+ <target>Der er ingen kommentarer i denne anmodning.</target>
+ </trans-unit>
+ <trans-unit id="622">
+ <source>Create request</source>
+ <target>Opret anmodning</target>
+ </trans-unit>
+ <trans-unit id="623">
+ <source>If you want to go play but dont have a partner, you can write in a timestamp here when you can play. Other can contact you and you can meet up and play a game.</source>
+ <target>Hvis du mangler en makker men gerne vil ned at spille, kan du skrive et tidspunkt her for hvornår du vil spille. Andre kan så kontakte dig i kommentar feltet og i kan tage ned og spille.</target>
+ </trans-unit>
+ <trans-unit id="624">
+ <source>There are not requests in the players market.</source>
+ <target>Der er ingen anmodninger i spillermarkedet.</target>
+ </trans-unit>
+
</body>
</file>
</xliff>
View
38 src/Club/MailBundle/Listener/RequestComment.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Club\MailBundle\Listener;
+
+class RequestComment
+{
+ protected $container;
+ protected $em;
+ protected $templating;
+ protected $router;
+ protected $clubmaster_mailer;
+
+ public function __construct($container)
+ {
+ $this->container = $container;
+ $this->em = $container->get('doctrine.orm.entity_manager');
+ $this->templating = $container->get('templating');
+ $this->router = $container->get('router');
+ $this->clubmaster_mailer = $container->get('clubmaster_mailer');
+ }
+
+ public function onRequestCommentNew(\Club\RequestBundle\Event\FilterRequestCommentEvent $event)
+ {
+ $comment = $event->getRequestComment();
+ $email = $comment->getUser()->getProfile()->getProfileEmail();
+
+ if ($email) {
+ $this->clubmaster_mailer
+ ->setSubject('Player market comment')
+ ->setFrom()
+ ->setTo($email->getEmailAddress())
+ ->setBody($this->templating->render('ClubMailBundle:Template:request_comment.html.twig',array(
+ 'comment' => $comment
+ )))
+ ->send();
+ }
+ }
+}
View
5 src/Club/MailBundle/Resources/config/listener.yml
@@ -30,3 +30,8 @@ services:
tags:
- { name: kernel.event_listener, event: booking.confirm, method: onBookingConfirm }
- { name: kernel.event_listener, event: booking.cancel, method: onBookingCancel }
+ club.mailbundle.listener.request:
+ class: Club\MailBundle\Listener\RequestComment
+ arguments: [@service_container]
+ tags:
+ - { name: kernel.event_listener, event: request.comment.new, method: onRequestCommentNew }
View
4 src/Club/MailBundle/Resources/views/Template/request_comment.html.twig
@@ -1,6 +1,6 @@
-Dear {{ user.profile.name }},
+Dear {{ comment.request.user.profile.name }},
-You have a request in the players market at {{ comment.request.play_time|club_datetime }}.
+You have a request in the players market at {{ comment.request.playTime|club_datetime }}.
{{ comment.user.name }} has just responded to your request with:
View
3 src/Club/RequestBundle/Controller/CommentController.php
@@ -31,6 +31,9 @@ public function newAction(\Club\RequestBundle\Entity\Request $request)
$em->persist($comment);
$em->flush();
+ $event = new \Club\RequestBundle\Event\FilterRequestCommentEvent($comment);
+ $this->get('event_dispatcher')->dispatch(\Club\RequestBundle\Event\Events::onRequestCommentNew, $event);
+
$this->get('session')->setFlash('notice', $this->get('translator')->trans('Your changes are saved.'));
return $this->redirect($this->generateUrl('club_request_playermarket_index'));
}
View
8 src/Club/RequestBundle/Event/Events.php
@@ -0,0 +1,8 @@
+<?php
+
+namespace Club\RequestBundle\Event;
+
+final class Events
+{
+ const onRequestCommentNew = 'request.comment.new';
+}
View
19 src/Club/RequestBundle/Event/FilterRequestCommentEvent.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Club\RequestBundle\Event;
+
+use Symfony\Component\EventDispatcher\Event;
+
+class FilterRequestCommentEvent extends Event
+{
+ protected $request_comment;
+
+ public function __construct(\Club\RequestBundle\Entity\RequestComment $request_comment)
+ {
+ $this->request_comment = $request_comment;
+ }
+
+ public function getRequestComment() {
+ return $this->request_comment;
+ }
+}
View
4 src/Club/RequestBundle/Resources/views/Comment/index.html.twig
@@ -11,11 +11,11 @@
<table class="style">
<tbody>
<tr>
- <th>Time</th>
+ <th>{% trans %}Play time{% endtrans %}</th>
<td>{{ request.playtime|club_datetime }}</td>
</tr>
<tr>
- <th>User</th>
+ <th>{% trans %}User{% endtrans %}</th>
<td>{{ request.user.name }}</td>
</tr>
</tbody>
View
1 src/Club/RequestBundle/Resources/views/PlayerMarket/edit.html.twig
@@ -3,7 +3,6 @@
{% block body %}
<form method="post" action="{{ path('club_request_playermarket_edit', {'id':request.id}) }}">
-<p>When are you available for a game.</p>
{% include "ClubLayoutBundle:Default:form.html.twig" %}
</form>
View
14 src/Club/RequestBundle/Resources/views/PlayerMarket/index.html.twig
@@ -8,16 +8,16 @@
</p>
{% endif %}
-<h2>Players market</h2>
+<h2>{% trans %}Player market{% endtrans %}</h2>
-<p>If you want to go play but dont have a partner, you can write in a timestamp here when you can play. Other can contact you and you can meet up and play a game.</p>
+<p>{% trans %}If you want to go play but dont have a partner, you can write in a timestamp here when you can play. Other can contact you and you can meet up and play a game.{% endtrans %}</p>
<table class="style">
<thead>
<tr class="bg">
- <th>Time</th>
- <th>User</th>
- <th>Comments</th>
- <th>Action</th>
+ <th>{% trans %}Play time{% endtrans %}</th>
+ <th>{% trans %}User{% endtrans %}</th>
+ <th>{% trans %}Comments{% endtrans %}</th>
+ <th>{% trans %}Action{% endtrans %}</th>
</tr>
<thead>
<tfoot>
@@ -41,7 +41,7 @@
</tr>
{% else %}
<tr>
- <td colspan="4">There are not items in the players market.</td>
+ <td colspan="4">{% trans %}There are not requests in the players market.{% endtrans %}</td>
</tr>
{% endfor %}
</tbody>
View
1 src/Club/RequestBundle/Resources/views/PlayerMarket/new.html.twig
@@ -3,7 +3,6 @@
{% block body %}
<form method="post" action="{{ path('club_request_playermarket_new') }}">
-<p>When are you available for a game.</p>
{% include "ClubLayoutBundle:Default:form.html.twig" %}
</form>
View
2 src/Club/RequestBundle/Resources/views/base.html.twig
@@ -1,3 +1,3 @@
{% extends "ClubLayoutBundle::base.html.twig" %}
-{% block header %}<h1>{% trans %}Market{% endtrans %}</h1>{% endblock %}
+{% block header %}<h1>{% trans %}Player market{% endtrans %}</h1>{% endblock %}
View
1 src/Club/TODO
@@ -10,7 +10,6 @@ rewrite failure handler to a listerner
users should be able to create multiple emails, phone
add images to products
add category priority regarding to account numbers
-request partner
admin user batch, select search
make sure user only can book in member status period
knockout management, checkout myplayoffs.com
View
57 src/Club/TournamentBundle/Controller/TournamentController.php
@@ -17,96 +17,119 @@ class TournamentController extends Controller
*/
public function indexAction()
{
+ $users = array(
+ 'Michael Holm',
+ 'Rikke Jensen',
+ 'Lars Johannesen',
+ 'Poul Larsen',
+ 'Henrik Hansen',
+ 'Cecilie Eriksson',
+ 'Poul Larsen',
+ 'Anders Kvist'
+ );
+
+ $this->get('club_tournament.tournament')->setUsers($users);
+ $tournament = $this->get('club_tournament.tournament')->getBracket();
+
+ /*
$tournament = array(
array(
- 'round' => 0,
+ 'round' => 1,
'name' => 'First round',
'matches' => array(
array(
array(
'name' => 'Michael Holm',
- 'result' => 3
+ 'result' => '6-6'
),
array(
'name' => 'Poul Larsen',
- 'result' => 1
+ 'result' => '4-4'
)
),
array(
array(
'name' => 'Kresten Kjeldsen',
- 'result' => 1
+ 'result' => '1-1'
),
array(
'name' => 'Lars Johannesen',
- 'result' => 3
+ 'result' => '6-6'
)
),
array(
array(
'name' => 'Rikke Jensen',
- 'result' => 3
+ 'result' => '6-6'
),
array(
'name' => 'Mona Larsen',
- 'result' => 1
+ 'result' => '1-1'
)
),
array(
array(
'name' => 'Lonni Petersen',
- 'result' => 1
+ 'result' => '1-1'
),
array(
'name' => 'Henrik Hansen',
- 'result' => 3
+ 'result' => '6-6'
)
),
),
),
array(
'name' => 'Semi final',
- 'round' => 1,
+ 'round' => 2,
'matches' => array(
array(
array(
'name' => 'Michael Holm',
- 'result' => 3
+ 'result' => '6-6'
),
array(
'name' => 'Lars Johannesen',
- 'result' => 1
+ 'result' => '0-0'
)
),
array(
array(
'name' => 'Rikke Jsensen',
- 'result' => 3
+ 'result' => '6-6'
),
array(
'name' => 'Henrik Hansen',
- 'result' => 1
+ 'result' => '1-1'
)
),
),
),
array(
'name' => 'Final',
- 'round' => 2,
+ 'round' => 3,
'matches' => array(
array(
array(
'name' => 'Michael Holm',
- 'result' => -1
+ 'result' => '6-6'
),
array(
'name' => 'Rikke Jensen',
- 'result' => -1
+ 'result' => '0-3'
)
)
+ ),
+ ),
+ array(
+ 'name' => 'Champion',
+ 'round' => 4,
+ 'winner' => array(
+ 'name' => 'Michael Holm'
)
)
);
+ */
return array(
'tournament' => $tournament
View
4 src/Club/TournamentBundle/DependencyInjection/ClubTournamentExtension.php
@@ -22,7 +22,7 @@ public function load(array $configs, ContainerBuilder $container)
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
- $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
- $loader->load('services.xml');
+ $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+ $loader->load('services.yml');
}
}
View
52 src/Club/TournamentBundle/Helper/Tournament.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace Club\TournamentBundle\Helper;
+
+class Tournament
+{
+ private $users;
+ private $bracket;
+
+ public function setUsers(array $users)
+ {
+ $this->users = $users;
+ }
+
+ public function getBracket()
+ {
+ $this->bracket = array();
+
+ $r1 = pow(2, floor(log(count($this->users), 2)));
+ $r0 = count($this->users) - $r1;
+
+ $round = array(
+ 'round' => 1,
+ 'name' => 'First round',
+ 'matches' => array()
+ );
+
+ while (count($this->users) > $r0) {
+ array_push($round['matches'], array(
+ array(
+ 'name' => array_shift($this->users),
+ 'result' => 0
+ ),
+ array(
+ 'name' => array_shift($this->users),
+ 'result' => 0
+ )
+ ));
+ }
+
+ $this->bracket[0] = $round;
+ $this->bracket[1] = array(
+ 'name' => 'Champion',
+ 'round' => 2,
+ 'winner' => array(
+ 'name' => 'Michael Holm'
+ )
+ );
+
+ return $this->bracket;
+ }
+}
View
20 src/Club/TournamentBundle/Resources/config/services.xml
@@ -1,20 +0,0 @@
-<?xml version="1.0" ?>
-
-<container xmlns="http://symfony.com/schema/dic/services"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
-
- <!--
- <parameters>
- <parameter key="club_tournament.example.class">Club\TournamentBundle\Example</parameter>
- </parameters>
-
- <services>
- <service id="club_tournament.example" class="%club_tournament.example.class%">
- <argument type="service" id="service_id" />
- <argument>plain_value</argument>
- <argument>%parameter_name%</argument>
- </service>
- </services>
- -->
-</container>
View
4 src/Club/TournamentBundle/Resources/config/services.yml
@@ -0,0 +1,4 @@
+services:
+ club_tournament.tournament:
+ class: Club\TournamentBundle\Helper\Tournament
+ arguments: []
View
9 src/Club/TournamentBundle/Resources/public/css/bracket.css
@@ -1,15 +1,6 @@
-body
-{
- margin: 0px 0px 0px 0px;
- min-width: 640px;
- font-family: Arial;
- font-size: 15px;
-}
-
div#bracket_base {
margin: 0px 0px 0px 15px;
position:relative; height: 466px; width: 675px
-
}
div#bracket_base div {
View
83 src/Club/TournamentBundle/Resources/views/Tournament/index.html.twig
@@ -1,59 +1,40 @@
-<html>
-<head>
+{% extends "ClubTournamentBundle::base.html.twig" %}
+
+{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('bundles/clubtournament/css/bracket.css') }}" />
-</head>
-<body>
+{% endblock %}
+{% block body %}
<div id="bracket_base">
<div id="bracket_body">
- <div class='round' id='r1'>
- <div class='header'>Round 1&nbsp;</div>
- <div class='top'><p>Burton</p></div>
- <div class='odd'><p>PUSD</p></div>
- <div class='blank'><p></p></div>
- <div class='blank'><p></p></div>
- <div class='blank'><p></p></div>
- <div class='blank'><p></p></div>
- <div><p>Competitor2</p></div>
- <div class='odd'><p>Competitor3</p></div>
- <div><p>Competitor4</p></div>
- <div class='odd'><p>Competitor5</p></div>
- <div class='blank'><p></p></div>
- <div class='blank'><p></p></div>
- <div class='blank'><p></p></div>
- <div class='blank'><p></p></div>
- <div><p>Competitor6</p></div>
- <div class='odd'><p>Competitor7</p></div>
- </div>
- <div class='round' id='r2'>
- <div class='header'>Round 2&nbsp;</div>
- <div class='top'><p>Burton<span class="score">7/6 7/6</span></p></div>
- <div class='odd'><p>Young's</p></div>
- <div><p>Competitor9</p></div>
- <div class='odd'><p></p></div>
- <div><p></p></div>
- <div class='odd'><p>Competitor10</p></div>
- <div><p>Competitor11</p></div>
- <div class='odd'><p></p></div>
- </div>
- <div class='round' id='r3'>
- <div class='header'>Round 3&nbsp;</div>
- <div class='top'><p></p></div>
- <div class='odd'><p></p></div>
- <div><p></p></div>
- <div class='odd'><p></p></div>
- </div>
- <div class='round' id='r4'>
- <div class='header'>Round 4&nbsp;</div>
- <div class='top'><p></p></div>
- <div class='odd'><p></p></div>
- </div>
- <div class='round' id='r5'>
- <div class='header'>Champion&nbsp;</div>
- <div class='champ'><p></p></div>
+
+ {% for round in tournament %}
+ <div class='round' id='r{{ round.round }}'>
+ <div class='header'>{{ round.name }}</div>
+
+ {% if round.round == tournament|length %}
+ <div class='champ'><p>{{ round.winner.name }}</p></div>
+ {% else %}
+
+ {% set top = true %}
+ {% for match in round.matches %}
+
+ {% if top %}
+ <div class='top'><p>{{ match.0.name }} {% if match.0.result != '' %}<span class="score">{{ match.0.result }}</span>{% endif %}</p></div>
+ <div class='odd'><p>{{ match.1.name }} {% if match.1.result != '' %}<span class="score">{{ match.1.result }}</span>{% endif %}</p></div>
+ {% set top = false %}
+ {% else %}
+ <div><p>{{ match.0.name }} {% if match.0.result %}<span class="score">{{ match.0.result }}</span>{% endif %}</p></div>
+ <div class='odd'><p>{{ match.1.name }} {% if match.1.result %}<span class="score">{{ match.1.result }}</span>{% endif %}</p></div>
+ {% endif %}
+
+ {% endfor %}
+ {% endif %}
+
</div>
+ {% endfor %}
+
</div>
</div>
-</body>
-</html>
+{% endblock %}
View
3 src/Club/TournamentBundle/Resources/views/base.html.twig
@@ -0,0 +1,3 @@
+{% extends "ClubLayoutBundle::base.html.twig" %}
+
+{% block header %}<h1>{% trans %}Tournament{% endtrans %}</h1>{% endblock %}
View
12 src/Club/UserBundle/Controller/UserController.php
@@ -14,19 +14,12 @@ class UserController extends Controller
*/
public function indexAction()
{
- $user = $this->get('security.context')->getToken()->getUser();
- $user = $this->getUser($user);
-
+ $user = $this->getUser();
$form = $this->createForm(new \Club\UserBundle\Form\User(), $user);
if ($this->getRequest()->getMethod() == 'POST') {
$form->bindRequest($this->getRequest());
- foreach ($user->getProfile()->getProfileEmails() as $email) {
- var_dump($email->getEmailAddress());
- $email->setProfile($user->getProfile());
- }
-
if ($form->isValid()) {
$em = $this->getDoctrine()->getEntityManager();
$em->persist($user);
@@ -84,8 +77,9 @@ public function resetAction()
);
}
- protected function getUser($user)
+ protected function getUser()
{
+ $user = $this->get('security.context')->getToken()->getUser();
$em = $this->getDoctrine()->getEntityManager();
if (!$user->getProfile()->getProfileAddress()) {
View
20 src/Club/UserBundle/Entity/Profile.php
@@ -64,19 +64,19 @@ class Profile
/**
* @ORM\ManyToOne(targetEntity="ProfileAddress", cascade={"persist"})
- * @ORM\JoinColumn(name="profile_address_id", referencedColumnName="id", onDelete="cascade")
+ * @ORM\JoinColumn(name="profile_address_id", referencedColumnName="id")
*/
protected $profile_address;
/**
* @ORM\ManyToOne(targetEntity="ProfilePhone", cascade={"persist"})
- * @ORM\JoinColumn(name="profile_phone_id", referencedColumnName="id", onDelete="cascade")
+ * @ORM\JoinColumn(name="profile_phone_id", referencedColumnName="id")
*/
protected $profile_phone;
/**
* @ORM\ManyToOne(targetEntity="ProfileEmail", cascade={"persist"})
- * @ORM\JoinColumn(name="profile_email_id", referencedColumnName="id", onDelete="cascade")
+ * @ORM\JoinColumn(name="profile_email_id", referencedColumnName="id")
*/
protected $profile_email;
@@ -335,6 +335,20 @@ public function getProfilePhones()
}
/**
+ * Set profile_emails
+ *
+ * @param Club\UserBundle\Entity\ProfileEmail $profileEmails
+ */
+ public function setProfileEmails($profileEmails)
+ {
+ foreach ($profileEmails as $email) {
+ $email->setProfile($this);
+ }
+
+ $this->profile_emails = $profileEmails;
+ }
+
+ /**
* Add profile_emails
*
* @param Club\UserBundle\Entity\ProfileEmail $profileEmails
View
2 src/Club/UserBundle/Entity/ProfileEmail.php
@@ -107,7 +107,7 @@ public function getContactType()
*
* @param Club\UserBundle\Entity\Profile $profile
*/
- public function setProfile(\Club\UserBundle\Entity\Profile $profile)
+ public function setProfile(\Club\UserBundle\Entity\Profile $profile=null)
{
$this->profile = $profile;
}
View
2 src/Club/UserBundle/Entity/User.php
@@ -103,7 +103,7 @@ class User implements AdvancedUserInterface
protected $updated_at;
/**
- * @ORM\OneToOne(targetEntity="Profile", fetch="EAGER", cascade={"persist"})
+ * @ORM\OneToOne(targetEntity="Profile", cascade={"persist"})
* @ORM\JoinColumn(name="profile_id", referencedColumnName="id", onDelete="cascade")
*
* @var Club\UserBundle\Entity\Profile
View
3 src/Club/UserBundle/Form/AdminProfile.php
@@ -22,7 +22,8 @@ public function buildForm(FormBuilder $builder, array $options)
$builder->add('profile_emails', 'collection', array(
'type' => new \Club\UserBundle\Form\AdminProfileEmail(),
'allow_add' => true,
- 'allow_delete' => true
+ 'allow_delete' => true,
+ 'by_reference' => false
));
$builder->add('profile_phone', new \Club\UserBundle\Form\AdminProfilePhone());
}

0 comments on commit ca02f81

Please sign in to comment.
Something went wrong with that request. Please try again.