diff --git a/sapl/materia/views.py b/sapl/materia/views.py
index 65c1deb97..3cae28756 100644
--- a/sapl/materia/views.py
+++ b/sapl/materia/views.py
@@ -1761,15 +1761,22 @@ class DocumentoAcessorioCrud(MasterDetailCrud):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
+ u = self.request.user
is_autor = False
- if self.request.user.is_authenticated:
+ if u.is_authenticated:
materia = self.object.materia
for autoria in materia.autoria_set.all():
if autoria.autor.operadores.filter(
- id=self.request.user.id).exists():
+ id=u.id).exists():
is_autor = True
break
context['is_autor'] = is_autor
+ context['pode_assinar'] = is_autor or (
+ u.is_authenticated and (
+ u.is_superuser or
+ u.has_perm('materia.change_documentoacessorio')
+ )
+ )
return context
class ListView(MasterDetailCrud.ListView):
diff --git a/sapl/templates/materia/documentoacessorio_detail.html b/sapl/templates/materia/documentoacessorio_detail.html
index 12b9f77dc..c6b7fef47 100644
--- a/sapl/templates/materia/documentoacessorio_detail.html
+++ b/sapl/templates/materia/documentoacessorio_detail.html
@@ -16,7 +16,7 @@
{% trans "Ver PDF Assinado" %}
- {% elif is_autor %}
+ {% elif pode_assinar %}
@@ -76,7 +76,7 @@
{% block extra_js %}
{{ block.super }}
-{% if object.arquivo and not object.pdf_assinado and is_autor %}
+{% if object.arquivo and not object.pdf_assinado and pode_assinar %}
{% include "materia/assinatura_modal.html" %}