feat: assignment call off
This commit is contained in:
@@ -17,6 +17,7 @@ class AssignmentVoter extends Voter
|
||||
public const EDIT = 'EDIT';
|
||||
public const APPLY = 'APPLY';
|
||||
public const PUBLISH = 'PUBLISH';
|
||||
public const CALL_OFF = 'CALL_OFF';
|
||||
|
||||
public function __construct(
|
||||
private readonly Security $security,
|
||||
@@ -30,7 +31,7 @@ class AssignmentVoter extends Voter
|
||||
return false;
|
||||
}
|
||||
|
||||
return in_array($attribute, [static::VIEW, static::EDIT, static::APPLY, static::PUBLISH]);
|
||||
return in_array($attribute, [static::VIEW, static::EDIT, static::APPLY, static::PUBLISH, static::CALL_OFF]);
|
||||
}
|
||||
|
||||
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
|
||||
@@ -54,8 +55,19 @@ class AssignmentVoter extends Voter
|
||||
&& $this->security->isGranted('ROLE_ADMINISTRATIVE');
|
||||
}
|
||||
|
||||
// Only allow applications to published assignments
|
||||
if (Assignment::STATUS_DRAFT === $assignment->getStatus()) {
|
||||
// Only users with administrative role may call off assignments
|
||||
if (static::CALL_OFF === $attribute) {
|
||||
return Assignment::STATUS_CALLED_OFF !== $assignment->getStatus()
|
||||
&& $this->security->isGranted('ROLE_ADMINISTRATIVE');
|
||||
}
|
||||
|
||||
// Only allow applications to published, not deleted and not called off assignments
|
||||
if (
|
||||
true === in_array($assignment->getStatus(), [
|
||||
Assignment::STATUS_DRAFT,
|
||||
Assignment::STATUS_DELETED,
|
||||
Assignment::STATUS_CALLED_OFF,
|
||||
])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user