WIP: Implement voter
This commit is contained in:
@@ -31,18 +31,23 @@ class ApplicationVoter extends Voter
|
|||||||
/** @var Application $application */
|
/** @var Application $application */
|
||||||
$application = $subject;
|
$application = $subject;
|
||||||
|
|
||||||
|
if ($user->hasRole('ROLE_TEAMER')) {
|
||||||
|
return match ($attribute) {
|
||||||
|
static::DELETE => $user->getTeamer() === $application->getTeamer() && Application::STATUS_REJECTED === $application->getStatus(),
|
||||||
|
static::VIEW => $user->getTeamer() === $application->getTeamer() && Application::STATUS_REJECTED !== $application->getStatus(),
|
||||||
|
default => false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if ($user->hasRole('ROLE_ADMINISTRATIVE')) {
|
if ($user->hasRole('ROLE_ADMINISTRATIVE')) {
|
||||||
return match ($attribute) {
|
return match ($attribute) {
|
||||||
static::VIEW, static::DELETE => true,
|
static::VIEW => true,
|
||||||
|
static::DELETE => Application::STATUS_REJECTED === $application->getStatus(),
|
||||||
static::DISPOSE, static::REJECT => Application::STATUS_REJECTED !== $application->getStatus(),
|
static::DISPOSE, static::REJECT => Application::STATUS_REJECTED !== $application->getStatus(),
|
||||||
default => false,
|
default => false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (static::VIEW === $attribute && $user->hasRole('ROLE_TEAMER')) {
|
|
||||||
return $user->getTeamer() === $application->getTeamer();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,9 +62,23 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="flex items-center space-x-1 justify-end">
|
<div class="flex items-center space-x-1 justify-end">
|
||||||
<a href="{{ path('app_teamer_assignment', { 'uuid': assignment.uuid, 'r': return_url() }) }}">
|
{% if is_granted('VIEW', application) %}
|
||||||
{{ icon('info', 'w-5 h-5') }}
|
<a href="{{ path('app_teamer_assignment', { 'uuid': assignment.uuid, 'r': return_url() }) }}">
|
||||||
</a>
|
{{ icon('info', 'w-5 h-5') }}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if is_granted('DELETE', application) %}
|
||||||
|
<button type="button"
|
||||||
|
title="Bewerbung löschen"
|
||||||
|
{{ stimulus_controller('modal-button', [], [], {'confirmation-modal': '#confirmation-modal'}) }}
|
||||||
|
{{ stimulus_action('modal-button', 'confirmation', null, {
|
||||||
|
'title': 'Bist du sicher?',
|
||||||
|
'content': 'Möchtest du die Bewerbing wirklich zurückziehen/löschen?',
|
||||||
|
'target-url': path('app_teamer_application_delete', { 'uuid': application.uuid })
|
||||||
|
}) }}>
|
||||||
|
{{ icon('delete', 'w-5 h-5 text-red-500') }}
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user