Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clone event #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions features/backend/events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ Background:
| event | My event | My another awesome event! | 2016-03-01 10:00 | 2016-03-01 18:00 | Burj Khalifa Tower | [email protected] | http://localhost:8000 |
| event2 | My other event | My other awesome event! | 2016-03-01 10:00 | 2016-03-01 18:00 | Burj Khalifa Tower | [email protected] | http://eventator.loc:8080 |
| event3 | His event | His another awesome event! | 2016-04-01 10:00 | 2016-04-01 18:00 | Kuala-lumpur Tower | [email protected] | http://event.com |
| event4 | Local event | My local awesome event! | 2016-04-01 10:00 | 2016-04-01 18:00 | Kuala-lumpur Tower | [email protected] | http://eventator.loc |
And following "EventTranslation":
| event | locale |
| event | ru_RU |
| event | de_DE |
| event2 | ru_RU |
| event2 | de_DE |
| event3 | ru_RU |
| event4 | ru_RU |
And following "Organizer":
| ref | title | description | isActive | events |
| organizer | My organizer | My another awesome organizer! | 1 | event,event2,event3 |
| organizer2 | His organizer | His another awesome organizer! | 1 | event2,event3 |
| ref | title | description | isActive | events |
| organizer | My organizer | My another awesome organizer! | 1 | event,event2,event3 |
| organizer2 | His organizer | His another awesome organizer! | 1 | event2,event3,event4 |
And following "OrganizerTranslation":
| organizer | locale |
| organizer | ru_RU |
Expand Down Expand Up @@ -105,7 +107,7 @@ Background:
And following "Sponsor":
| ref | company | description | homepage | type | isActive | events |
| sponsor | Reseach Supplier | NASA research center | http://nasa.gov.us | 1 | 1 | event,event2,event3 |
| sponsor2 | KnpLabs | Happy awesome developer | http://knplabs.com | 2 | 1 | event |
| sponsor2 | KnpLabs | Happy awesome developer | http://knplabs.com | 2 | 1 | event,event4 |
And following "SponsorTranslation":
| sponsor | locale |
| sponsor | de_DE |
Expand Down Expand Up @@ -145,7 +147,26 @@ Scenario: Admin should have able to add event
And I press "Add"
Then I wait for a form
Then I should see "Event Test event added."
Then I should see the row containing "4;Test event;UA;May 1, 2016 10:00;May 1, 2016 18:00"
Then I should see the row containing "5;Test event;UA;May 1, 2016 10:00;May 1, 2016 18:00"

@javascript
Scenario: Admin should be able to clone event
Given I am sign in as admin
When I click "Events"
Then I wait for a form
Then I should see "Add Event"
And I should see the row containing "1;My event;March 1, 2016 10:00;March 1, 2016 18:00"
When I click "expand-1" on the row containing "1;My event;March 1, 2016 10:00;March 1, 2016 18:00"
When I click "Clone" on the row containing "1;My event;March 1, 2016 10:00;March 1, 2016 18:00"
Then I wait for a form
Then I should see "Event settings"
And I fill in "Host" with "http://testevent.loc"
And I fill in "Title" with "Cloned event"
And I check "Is active"
And I press "Add"
Then I wait for a form
Then I should see "Event Cloned event added."
Then I should see the row containing "5;Cloned event;UA;May 1, 2016 10:00;May 1, 2016 18:00"

@javascript
Scenario: Admin should have able to update event settings
Expand Down
5 changes: 4 additions & 1 deletion src/Event/EventBundle/Controller/Backend/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ public function indexAction()
));
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CS if ( space

$entity->setId(null)->setIsActive(false)->setHost(null);
}
}

$form = $this->createForm(EventType::class, $entity);
Expand Down
12 changes: 12 additions & 0 deletions src/Event/EventBundle/Entity/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,18 @@ public function getId()
return $this->id;
}

/**
* Set id
*
* @param int $id
* @return integer
*/
public function setId($id)
{
$this->id = $id;
return $this;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CS, add new nl above the return

}

/**
* Set host
*
Expand Down
5 changes: 5 additions & 0 deletions src/Event/EventBundle/Resources/config/routing/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ backend_event_edit:
defaults: { _controller: EventEventBundle:Backend/Event:manage, id: null }
requirements: { id: \d+ }

backend_event_clone:
path: /event/clone/{id}
defaults: { _controller: EventEventBundle:Backend/Event:manage, id: null, clone: 1 }
requirements: { id: \d+, clone: \d+ }

backend_event_delete:
path: /event/delete/{id}
defaults: { _controller: EventEventBundle:Backend/Event:delete }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
<td>
<div class="btn-group">
<a class="btn btn-small" href="{{ url('backend_event_edit', {'id': event.id}) }}"><i class="icon-user"></i> Edit</a>
<a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a>
<a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#" id="expand-{{ event.id }}"><span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{{ url('backend_event_clone', {'id': event.id, 'clone': 1}) }}"><i class="icon-folder-open"></i> Clone</a></li>
<li><a href="{{ url('backend_event_delete', {'id': event.id}) }}"><i class="icon-trash"></i> Delete</a></li>
</ul>
</div>
Expand Down