Feat: Consider availability of dispositions in voter
This commit is contained in:
@@ -32,18 +32,23 @@ class ApplicationVoter extends Voter
|
|||||||
$application = $subject;
|
$application = $subject;
|
||||||
|
|
||||||
if ($user->hasRole('ROLE_ADMINISTRATIVE')) {
|
if ($user->hasRole('ROLE_ADMINISTRATIVE')) {
|
||||||
|
$assignment = $application->getAssignment();
|
||||||
return match ($attribute) {
|
return match ($attribute) {
|
||||||
static::VIEW => true,
|
static::VIEW => true,
|
||||||
static::DELETE => Application::STATUS_REJECTED === $application->getStatus(),
|
static::DELETE => Application::STATUS_REJECTED === $application->getStatus(),
|
||||||
static::DISPOSE, static::REJECT => Application::STATUS_REJECTED !== $application->getStatus(),
|
static::REJECT => Application::STATUS_REJECTED !== $application->getStatus(),
|
||||||
|
static::DISPOSE => Application::STATUS_REJECTED !== $application->getStatus()
|
||||||
|
&& $assignment->getAvailableDispositions() > $assignment->getDispositions()->count(),
|
||||||
default => false,
|
default => false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->hasRole('ROLE_TEAMER')) {
|
if ($user->hasRole('ROLE_TEAMER')) {
|
||||||
return match ($attribute) {
|
return match ($attribute) {
|
||||||
static::DELETE => $user->getTeamer() === $application->getTeamer() && Application::STATUS_REJECTED === $application->getStatus(),
|
static::DELETE => $user->getTeamer() === $application->getTeamer()
|
||||||
static::VIEW => $user->getTeamer() === $application->getTeamer() && Application::STATUS_REJECTED !== $application->getStatus(),
|
&& Application::STATUS_REJECTED === $application->getStatus(),
|
||||||
|
static::VIEW => $user->getTeamer() === $application->getTeamer()
|
||||||
|
&& Application::STATUS_REJECTED !== $application->getStatus(),
|
||||||
default => false,
|
default => false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user