Skip to content

Commit

Permalink
Merge pull request #21 from pilot/feature/multi-events
Browse files Browse the repository at this point in the history
Feature/multi events
  • Loading branch information
pilot committed Aug 4, 2015
2 parents 7a87526 + 7db8df2 commit 864dad2
Show file tree
Hide file tree
Showing 73 changed files with 1,420 additions and 179 deletions.
2 changes: 1 addition & 1 deletion app/config/parameters.circle.yml
Expand Up @@ -13,7 +13,7 @@ parameters:
mailer_port: ~

locale: en
secret: ThisTokenIsNotSoSecretChangeIt
secret: o6l4q3mehlz4lcvax32z

behat_print_err: 1

Expand Down
2 changes: 1 addition & 1 deletion app/config/parameters.yml.dist
Expand Up @@ -13,7 +13,7 @@ parameters:
mailer_port: ~

locale: en
secret: ThisTokenIsNotSoSecretChangeIt
secret: 4yceqicrp8stv6qmwxnv

behat_print_err: 1

Expand Down
32 changes: 15 additions & 17 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion features/Context/FeatureContext.php
Expand Up @@ -138,7 +138,11 @@ public function printLastResponseOnError($scenarioEvent)
*/
public function areFollowingEntities($name, TableNode $table)
{
$objectName = 'Event\\EventBundle\\Entity\\' . $name;
if (strpos($name, 'Translation')) {
$objectName = 'Event\\EventBundle\\Entity\\Translation\\' . $name;
} else {
$objectName = 'Event\\EventBundle\\Entity\\' . $name;
}

$metadata = $this->getEntityManager()->getMetadataFactory()->getMetadataFor($objectName);
$class = $metadata->getName();
Expand All @@ -160,6 +164,14 @@ public function areFollowingEntities($name, TableNode $table)
$this->getEntityManager()->flush();
}

/**
* @Given /^following "([^"]*)" events:$/
*/
public function areFollowingEvents($name, TableNode $table)
{
// @todo implement load objects / events relations
}

/**
* @Given /^I delete "([^"]*)" record of "([^"]*)"$/
*/
Expand Down
47 changes: 47 additions & 0 deletions features/backend/event.feature
@@ -0,0 +1,47 @@
Feature: Event settings
As an admin
I should be able to edit event settings
In order to update my event description

Background:
Given following "Event":
| ref | title | description | startDate | endDate | venue | email | host |
| event | My event | My another awesome event! | 2014-10-10 | 2014-10-12 | Burj Khalifa Tower | eventator@email.com | http://event.com |
| event2 | His event | His another awesome event! | 2014-11-15 | 2014-11-16 | Kuala-lumpur Tower | eventator@gmail.com | http://event2.com |
And following "EventTranslation":
| locale |
| ru_RU |

@wip
Scenario: Admin should have access to the event manage
Given I am sign in as admin
When I follow "Events"
Then I should see "Events"
And the "Title" field should contain "My event"
And the "Event Description" field should contain "My super awesome event!"
And the "Venue Place" field should contain "Burj Khalifa Tower"

@wip
Scenario: Admin should have able to update event settings
Given I am sign in as admin
When I follow "Settings"
And I fill in "Brief Description" with "Awesome event"
And I select "United Arab Emirates" from "Country"
And I fill in "State" with "Dubai"
And I fill in "City" with "Dubai"
And I fill in "Twitter" with "myevent"
And I press "Update"
Then I should see "Event settings updated."
And I should see "Awesome event"
And the "City" field should contain "Dubai"

@wip @javascript
Scenario: Admin should have able to update Russian event settings
Given I am sign in as admin
When I follow "Settings"
And I follow "ru"
And I fill in "title" with "Мое событие"
And I press "Update"
Then I should see "Event settings updated."
When I follow "ru"
Then the "title" field should contain "Мое событие"
5 changes: 3 additions & 2 deletions features/backend/program.feature
Expand Up @@ -5,8 +5,9 @@ Feature: Event program

Background:
Given following "Event":
| ref | title | description | startDate | endDate | venue | email |
| event | My event | My another awesome event! | 2014-10-10 | 2014-10-12 | Burj Khalifa Tower | eventator@email.com |
| ref | title | description | startDate | endDate | venue | email | host |
| event | My event | My another awesome event! | 2014-10-10 | 2014-10-12 | Burj Khalifa Tower | eventator@email.com | http://event.com |
| event2 | His event | His another awesome event! | 2014-11-15 | 2014-11-16 | Kuala-lumpur Tower | eventator@gmail.com | http://event2.com |
And following "EventTranslation":
| locale |
| ru_RU |
Expand Down
8 changes: 5 additions & 3 deletions features/backend/setting.feature
@@ -1,7 +1,7 @@
Feature: Event settings
Feature: Manage cross events settings
As an admin
I should be able to edit event settings
In order to update my event description
I should be able to edit global settings
In order to update global events configuration

Background:
Given following "Event":
Expand All @@ -11,6 +11,7 @@ Background:
| locale |
| ru_RU |

@wip
Scenario: Admin should have access to the settings manage
Given I am sign in as admin
When I follow "Settings"
Expand All @@ -19,6 +20,7 @@ Scenario: Admin should have access to the settings manage
And the "Event Description" field should contain "My super awesome event!"
And the "Venue Place" field should contain "Burj Khalifa Tower"

@wip
Scenario: Admin should have able to update event settings
Given I am sign in as admin
When I follow "Settings"
Expand Down
10 changes: 8 additions & 2 deletions features/backend/speaker.feature
Expand Up @@ -5,8 +5,9 @@ Feature: Event speakers

Background:
Given following "Event":
| ref | title | description | startDate | endDate | venue | email |
| event | My event | My another awesome event! | 2014-10-10 | 2014-10-12 | Burj Khalifa Tower | eventator@email.com |
| ref | title | description | startDate | endDate | venue | email | host |
| event | My event | My another awesome event! | 2014-10-10 | 2014-10-12 | Burj Khalifa Tower | eventator@email.com | http://event.com |
| event2 | His event | His another awesome event! | 2014-11-15 | 2014-11-16 | Kuala-lumpur Tower | eventator@gmail.com | http://event2.com |
And following "EventTranslation":
| locale |
| ru_RU |
Expand All @@ -17,6 +18,11 @@ Background:
And following "SpeakerTranslation":
| locale |
| ru_RU |
And following "Speaker" events:
| speaker | event |
| phill | event |
| alex | event |
| alex | event2 |

Scenario: Admin should have access to the speakers management
Given I am sign in as admin
Expand Down
5 changes: 3 additions & 2 deletions features/backend/speech.feature
Expand Up @@ -5,8 +5,9 @@ Feature: Event speaker speech

Background:
Given following "Event":
| ref | title | description | startDate | endDate | venue | email |
| event | My event | My another awesome event! | 2014-10-10 | 2014-10-12 | Burj Khalifa Tower | eventator@email.com |
| ref | title | description | startDate | endDate | venue | email | host |
| event | My event | My another awesome event! | 2014-10-10 | 2014-10-12 | Burj Khalifa Tower | eventator@email.com | http://event.com |
| event2 | His event | His another awesome event! | 2014-11-15 | 2014-11-16 | Kuala-lumpur Tower | eventator@gmail.com | http://event2.com |
And following "EventTranslation":
| locale |
| ru_RU |
Expand Down
5 changes: 3 additions & 2 deletions features/backend/sponsor.feature
Expand Up @@ -5,8 +5,9 @@ Feature: Event sponsor

Background:
Given following "Event":
| ref | title | description | startDate | endDate | venue | email |
| event | My event | My another awesome event! | 2014-10-10 | 2014-10-12 | Burj Khalifa Tower | eventator@email.com |
| ref | title | description | startDate | endDate | venue | email | host |
| event | My event | My another awesome event! | 2014-10-10 | 2014-10-12 | Burj Khalifa Tower | eventator@email.com | http://event.com |
| event2 | His event | His another awesome event! | 2014-11-15 | 2014-11-16 | Kuala-lumpur Tower | eventator@gmail.com | http://event2.com |
And following "EventTranslation":
| locale |
| ru_RU |
Expand Down
2 changes: 1 addition & 1 deletion spec/Event/EventBundle/Form/Type/EventTypeSpec.php
Expand Up @@ -13,6 +13,6 @@ function it_is_initializable()

function it_has_valid_name()
{
$this->getName()->shouldReturn('settings');
$this->getName()->shouldReturn('event');
}
}
31 changes: 5 additions & 26 deletions src/Event/EventBundle/Controller/Backend/DashboardController.php
Expand Up @@ -6,15 +6,15 @@
use Event\EventBundle\Controller\Controller;
use Event\EventBundle\Form\Type\EventType;
use Event\EventBundle\Entity\Event;
use Event\EventBundle\Entity\EventTranslation;
use Event\EventBundle\Entity\Translation\EventTranslation;
use Event\EventBundle\Entity\Speaker;
use Event\EventBundle\Entity\SpeakerTranslation;
use Event\EventBundle\Entity\Translation\SpeakerTranslation;

class DashboardController extends Controller
{
public function indexAction()
{
// @todo: handle init on kernel listener
// @todo: create installer for initial setup
if ('test' != $this->container->getParameter('kernel.environment')) {
$this->initEvent();
}
Expand All @@ -24,30 +24,9 @@ public function indexAction()

public function settingAction(Request $request)
{
$event = $this->getRepository('EventEventBundle:Event')->getEvent();

if (!$event) {
$event = new Event();
}

$form = $this->createForm(new EventType(), $event);
if ($request->isMethod('POST') && $form->handleRequest($request)) {

if ($form->isValid()) {
// @todo: add settgins management

$em = $this->getManager();
$em->persist($event);
$em->flush();

$this->setSuccessFlash('Event settings updated.');

return $this->redirect($this->generateUrl('backend_setting'));
}
}

return $this->render('EventEventBundle:Backend/Dashboard:setting.html.twig', [
'form' => $form->createView()
]);
return $this->render('EventEventBundle:Backend/Dashboard:setting.html.twig', []);
}

public function localeTabsAction()
Expand Down
64 changes: 64 additions & 0 deletions src/Event/EventBundle/Controller/Backend/EventController.php
@@ -0,0 +1,64 @@
<?php

namespace Event\EventBundle\Controller\Backend;

use Symfony\Component\HttpFoundation\Request;
use Event\EventBundle\Controller\Controller;
use Event\EventBundle\Entity\Event;
use Event\EventBundle\Entity\Translation\EventTranslation;
use Event\EventBundle\Form\Type\EventType;

class EventController extends Controller
{
public function indexAction()
{
return $this->render('EventEventBundle:Backend/Event:index.html.twig', array(
'events' => $this->getRepository('EventEventBundle:Event')->findAll()
));
}

public function manageAction(Request $request, $id = null)
{
if ($id === null) {
$entity = new Event();
$entity = $this->initObjectLocales($entity, new EventTranslation());
} else {
$entity = $this->findOr404('EventEventBundle:Event', $id);
}

$form = $this->createForm(new EventType(), $entity);

if ($request->getMethod() === 'POST') {
$form->handleRequest($request);

if ($form->isValid()) {
$this->getManager()->persist($entity);
$this->getManager()->flush();

$this->setSuccessFlash(sprintf('Event %s updated.', $entity->getTitle()));

return $this->redirectToRoute('backend_event');
}
}

return $this->render('EventEventBundle:Backend/Event:manage.html.twig', [
'event' => $entity,
'form' => $form->createView()
]);
}

public function deleteAction($id)
{
$this->isGrantedAdmin();

$entity = $this->findOr404('EventEventBundle:Event', $id);
$this->getManager()->remove($entity);
$this->getManager()->flush();

$this->setSuccessFlash('Eevent deleted.');

return $this->redirectToRoute('backend_event');
}


}

0 comments on commit 864dad2

Please sign in to comment.