mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Activity: fixes in voter
* the role CREATE is now transformed to CREATE_ACCOMPANYING_COURSE or CREATE_PERSON when the subject is, respectively, a course or a person; * the button at the list of activities is now labeled "create" * the role FULL give access to both role acTIVITY_CREATE_ACCOMPANYING_COURSE and ACTIVITY_CREATE_PERSON, but not ACTIVITY_CREATE directly.
This commit is contained in:
parent
f9b33fdfb8
commit
05dda33a7a
@ -89,8 +89,12 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
||||
ActivityVoter::CREATE_ACCOMPANYING_COURSE => array(ActivityVoter::SEE_DETAILS),
|
||||
ActivityVoter::DELETE => array(ActivityVoter::SEE_DETAILS),
|
||||
ActivityVoter::SEE_DETAILS => array(ActivityVoter::SEE),
|
||||
ActivityVoter::FULL => [ActivityVoter::CREATE, ActivityVoter::DELETE,
|
||||
ActivityVoter::UPDATE],
|
||||
ActivityVoter::FULL => [
|
||||
ActivityVoter::CREATE_PERSON,
|
||||
ActivityVoter::CREATE_ACCOMPANYING_COURSE,
|
||||
ActivityVoter::DELETE,
|
||||
ActivityVoter::UPDATE
|
||||
],
|
||||
)
|
||||
));
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}" class="btn btn-create">
|
||||
{{ 'Add a new activity' | trans }}
|
||||
{{ 'Create'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -134,14 +134,22 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
} else {
|
||||
throw new \RuntimeException("could not determine context of activity");
|
||||
}
|
||||
}
|
||||
|
||||
if ($subject instanceof AccompanyingPeriod) {
|
||||
} elseif ($subject instanceof AccompanyingPeriod) {
|
||||
if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) {
|
||||
if (\in_array($attribute, [self::UPDATE, self::CREATE, self::DELETE])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// transform the attribute
|
||||
if (self::CREATE === $attribute) {
|
||||
$attribute = self::CREATE_ACCOMPANYING_COURSE;
|
||||
}
|
||||
} elseif ($subject instanceof Person) {
|
||||
// transform the attribute
|
||||
if (self::CREATE === $attribute) {
|
||||
$attribute = self::CREATE_PERSON;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->voterHelper->voteOnAttribute($attribute, $subject, $token);
|
||||
|
Loading…
x
Reference in New Issue
Block a user