fix error in return path and fix date interval conversion

This commit is contained in:
Julien Fastré 2018-04-25 12:18:44 +02:00
parent b7dd309600
commit a58ae088ff
3 changed files with 16 additions and 18 deletions

View File

@ -18,8 +18,6 @@ use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\TaskBundle\Repository\SingleTaskRepository; use Chill\TaskBundle\Repository\SingleTaskRepository;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Chill\TaskBundle\Repository\SingleTaskRepository;
use Chill\MainBundle\Pagination\PaginatorFactory;
class SingleTaskController extends Controller class SingleTaskController extends Controller
{ {
@ -52,8 +50,8 @@ class SingleTaskController extends Controller
->setType('task_default') ->setType('task_default')
; ;
// $this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not ' $this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not '
// . 'allowed to create this task'); . 'allowed to create this task');
$form = $this->setCreateForm($task, new Role(TaskVoter::CREATE)); $form = $this->setCreateForm($task, new Role(TaskVoter::CREATE));
@ -68,7 +66,7 @@ class SingleTaskController extends Controller
$this->addFlash('success', "The task is created"); $this->addFlash('success', "The task is created");
return $this->redirectToRoute('chill_task_task_list', [ return $this->redirectToRoute('chill_task_task_list_by_person', [
'personId' => $task->getPerson()->getId() 'personId' => $task->getPerson()->getId()
]); ]);
@ -112,8 +110,8 @@ class SingleTaskController extends Controller
throw $this->createNotFoundException("Invalid person id"); throw $this->createNotFoundException("Invalid person id");
} }
} }
// $this->denyAccessUnlessGranted(TaskVoter::SEE, $task, 'You are not ' $this->denyAccessUnlessGranted(TaskVoter::SHOW, $task, 'You are not '
// . 'allowed to view this task'); . 'allowed to view this task');
if (!$task) { if (!$task) {
throw $this->createNotFoundException('Unable to find Task entity.'); throw $this->createNotFoundException('Unable to find Task entity.');
@ -152,8 +150,8 @@ class SingleTaskController extends Controller
throw $this->createNotFoundException("Invalid person id"); throw $this->createNotFoundException("Invalid person id");
} }
} }
// $this->denyAccessUnlessGranted(TaskVoter::UPDATE, $task, 'You are not ' $this->denyAccessUnlessGranted(TaskVoter::UPDATE, $task, 'You are not '
// . 'allowed to edit this task'); . 'allowed to edit this task');
if (!$task) { if (!$task) {
throw $this->createNotFoundException('Unable to find Task entity.'); throw $this->createNotFoundException('Unable to find Task entity.');
@ -172,7 +170,7 @@ class SingleTaskController extends Controller
$this->addFlash('success', "Success : task updated!"); $this->addFlash('success', "Success : task updated!");
return $this->redirectToRoute('chill_task_task_list', [ return $this->redirectToRoute('chill_task_task_list_by_person', [
'personId' => $task->getPerson()->getId() 'personId' => $task->getPerson()->getId()
]); ]);
@ -218,8 +216,8 @@ class SingleTaskController extends Controller
} }
// $this->denyAccessUnlessGranted(TaskVoter::DELETE, $task, 'You are not ' $this->denyAccessUnlessGranted(TaskVoter::DELETE, $task, 'You are not '
// . 'allowed to delete this task'); . 'allowed to delete this task');
if (!$task) { if (!$task) {
throw $this->createNotFoundException('Unable to find Task entity.'); throw $this->createNotFoundException('Unable to find Task entity.');
@ -252,7 +250,7 @@ class SingleTaskController extends Controller
->trans("The task has been successfully removed.")); ->trans("The task has been successfully removed."));
return $this->redirect($this->generateUrl( return $this->redirect($this->generateUrl(
'chill_task_task_list', array( 'chill_task_task_list_by_person', array(
'personId' => $personId 'personId' => $personId
))); )));
} }

View File

@ -44,13 +44,13 @@
<dt class="inline">{{ 'End date'|trans }}</dt> <dt class="inline">{{ 'End date'|trans }}</dt>
<dd>{{ task.endDate|localizeddate('long', 'none') }}</dd> <dd>{{ task.endDate|localizeddate('long', 'none') }}</dd>
<dt class="inline">{{ 'Warning interval'|trans }}</dt> <dt class="inline">{{ 'Warning date'|trans }}</dt>
<dd>{{ task.warningInterval|localizeddate('long', 'none') }}</dd> <dd>{{ task.warningDate|localizeddate('long', 'none') }}</dd>
</dl> </dl>
<ul class="record_actions"> <ul class="record_actions">
<li class="cancel"> <li class="cancel">
<a class="sc-button bt-cancel" href="{{ path('chill_task_task_list', { 'personId': person.id } ) }}"> <a class="sc-button bt-cancel" href="{{ path('chill_task_task_list_by_person', { 'personId': person.id } ) }}">
{{ 'Back to the list'|trans }} {{ 'Back to the list'|trans }}
</a> </a>
</li> </li>

View File

@ -57,12 +57,12 @@
<li> <li>
<a href="{{ path('chill_task_single_task_show', { 'id': task.id }) }}" class="sc-button bt-show "></a> <a href="{{ path('chill_task_single_task_show', { 'id': task.id }) }}" class="sc-button bt-show "></a>
</li> </li>
{% if not is_granted('CHILL_TASK_TASK_UPDATE', task) %} {% if is_granted('CHILL_TASK_TASK_UPDATE', task) %}
<li> <li>
<a href="{{ path('chill_task_single_task_edit', { 'id': task.id }) }}" class="sc-button bt-update "></a> <a href="{{ path('chill_task_single_task_edit', { 'id': task.id }) }}" class="sc-button bt-update "></a>
</li> </li>
{% endif %} {% endif %}
{% if not is_granted('CHILL_TASK_TASK_CREATE', task) %} {% if is_granted('CHILL_TASK_TASK_CREATE', task) %}
<li> <li>
<a href="{{ path('chill_task_single_task_delete', { 'id': task.id } ) }}" class="sc-button bt-delete "></a> <a href="{{ path('chill_task_single_task_delete', { 'id': task.id } ) }}" class="sc-button bt-delete "></a>
</li> </li>