activity: edit an activity: choose the context based on the activity, not the url parameters

This commit is contained in:
juminet 2021-11-29 13:56:12 +00:00 committed by Julien Fastré
parent 3b725a8a12
commit 975fbfbdee
3 changed files with 16 additions and 14 deletions

View File

@ -105,18 +105,19 @@ final class ActivityController extends AbstractController
[$person, $accompanyingPeriod] = $this->getEntity($request);
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
$view = 'ChillActivityBundle:Activity:confirm_deleteAccompanyingCourse.html.twig';
} elseif ($person instanceof Person) {
$view = 'ChillActivityBundle:Activity:confirm_deletePerson.html.twig';
}
$activity = $this->activityRepository->find($id);
if (!$activity) {
throw $this->createNotFoundException('Unable to find Activity entity.');
}
if ($activity->getAccompanyingPeriod() instanceof AccompanyingPeriod) {
$view = 'ChillActivityBundle:Activity:confirm_deleteAccompanyingCourse.html.twig';
$accompanyingPeriod = $activity->getAccompanyingPeriod();
} else {
$view = 'ChillActivityBundle:Activity:confirm_deletePerson.html.twig';
}
// TODO
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity);
@ -176,18 +177,18 @@ final class ActivityController extends AbstractController
[$person, $accompanyingPeriod] = $this->getEntity($request);
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
$view = 'ChillActivityBundle:Activity:editAccompanyingCourse.html.twig';
} elseif ($person instanceof Person) {
$view = 'ChillActivityBundle:Activity:editPerson.html.twig';
}
$entity = $this->activityRepository->find($id);
if (null === $entity) {
throw $this->createNotFoundException('Unable to find Activity entity.');
}
if ($entity->getAccompanyingPeriod() instanceof AccompanyingPeriod) {
$view = 'ChillActivityBundle:Activity:editAccompanyingCourse.html.twig';
$accompanyingPeriod = $entity->getAccompanyingPeriod();
} else {
$view = 'ChillActivityBundle:Activity:editPerson.html.twig';
}
// TODO
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity);

View File

@ -27,7 +27,7 @@
<dt class="inline">{{ 'Social issues'|trans }}</dt>
<dd>
{% if entity.socialIssues|length == 0 %}
<p class="chill-no-data-statement">{{ 'Any social issues'|trans }}</p>
<p class="chill-no-data-statement">{{ 'No social issues associated'|trans }}</p>
{% else %}
{% for si in entity.socialIssues %}{{ si|chill_entity_render_box }}{% endfor %}
{% endif %}
@ -38,7 +38,7 @@
<dt class="inline">{{ 'Social actions'|trans }}</dt>
<dd>
{% if entity.socialActions|length == 0 %}
<p class="chill-no-data-statement">{{ 'Any social actions'|trans }}</p>
<p class="chill-no-data-statement">{{ 'No social actions associated'|trans }}</p>
{% else %}
{% for sa in entity.socialActions %}{{ sa|chill_entity_render_box }}{% endfor %}
{% endif %}

View File

@ -43,6 +43,7 @@ Sent: Envoyer
Received: Recevoir
by: 'Par '
location: Lieu
Reasons: Sujets
#forms