fix: use precomputed permission flags in template

This commit is contained in:
Victor Andersson
2025-11-11 20:48:12 +01:00
parent 9fe70ac13b
commit 73ff0a9d45
2 changed files with 13 additions and 5 deletions

View File

@@ -111,11 +111,11 @@
<div class="rounded-2xl bg-slate-50 p-4">
<p class="text-sm font-semibold text-gray-700">{% trans "Behörigheter" %}</p>
<div class="mt-3 flex flex-wrap gap-2 text-xs">
<span class="rounded-full px-3 py-1 {% if user.is_staff %}bg-emerald-100 text-emerald-800{% else %}bg-slate-200 text-slate-600{% endif %}">{% trans "Admin/staff" %}</span>
<span class="rounded-full px-3 py-1 {% if user.has_perm('claims.view_claim') %}bg-blue-100 text-blue-800{% else %}bg-slate-200 text-slate-600{% endif %}">{% trans "Får se utlägg" %}</span>
<span class="rounded-full px-3 py-1 {% if user.has_perm('claims.change_claim') %}bg-indigo-100 text-indigo-800{% else %}bg-slate-200 text-slate-600{% endif %}">{% trans "Får besluta utlägg" %}</span>
<span class="rounded-full px-3 py-1 {% if user.has_perm('claims.edit_claim_details') %}bg-purple-100 text-purple-800{% else %}bg-slate-200 text-slate-600{% endif %}">{% trans "Får redigera utlägg" %}</span>
<span class="rounded-full px-3 py-1 {% if user.has_perm('claims.mark_claim_paid') %}bg-amber-100 text-amber-800{% else %}bg-slate-200 text-slate-600{% endif %}">{% trans "Får markera betalningar" %}</span>
<span class="rounded-full px-3 py-1 {% if row.permission_flags.is_staff %}bg-emerald-100 text-emerald-800{% else %}bg-slate-200 text-slate-600{% endif %}">{% trans "Admin/staff" %}</span>
<span class="rounded-full px-3 py-1 {% if row.permission_flags.view %}bg-blue-100 text-blue-800{% else %}bg-slate-200 text-slate-600{% endif %}">{% trans "Får se utlägg" %}</span>
<span class="rounded-full px-3 py-1 {% if row.permission_flags.change %}bg-indigo-100 text-indigo-800{% else %}bg-slate-200 text-slate-600{% endif %}">{% trans "Får besluta utlägg" %}</span>
<span class="rounded-full px-3 py-1 {% if row.permission_flags.edit %}bg-purple-100 text-purple-800{% else %}bg-slate-200 text-slate-600{% endif %}">{% trans "Får redigera utlägg" %}</span>
<span class="rounded-full px-3 py-1 {% if row.permission_flags.pay %}bg-amber-100 text-amber-800{% else %}bg-slate-200 text-slate-600{% endif %}">{% trans "Får markera betalningar" %}</span>
</div>
<button type="button"
data-open-permission-edit="{{ user.id }}"