Skip to content

Commit

Permalink
Merge pull request #2331 from laws-africa/provision-editing-perms-links
Browse files Browse the repository at this point in the history
Provision editing permissions, links
  • Loading branch information
goose-life authored Jan 23, 2025
2 parents 3d6e08a + 8155d1c commit 5a7bf0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions indigo_app/templates/indigo_api/document/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ <h5 class="main-header-title">
</div>
</li>
{% endverbatim %}
{% if provision_eid %}
<li class="breadcrumb-item"><a href="{% url 'choose_document_provision' document.pk %}">{{ provision_eid }}</a></li>
{% if provision_eid or perms.indigo_api.publish_document %}
<li class="breadcrumb-item"><i class="fas fa-list published"></i> <a href="{% url 'choose_document_provision' document.pk %}">{% trans "Provision editor" %}</a></li>
{% endif %}
</script>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ <h6 class="timeline-date">{{ entry.date|date:"Y-m-d" }}</h6>
{% endfor %}
<div class="documents mt-3">
{% for document in entry.expressions %}
<div><i class="fas fa-circle fa-fw {% if document.draft %}draft{% else %}published{% endif %}"></i> <a href="{% url 'document' doc_id=document.id %}">{{ document.title }}</a> · {{ document.language }}</div>
<div>
{% block document %}
<i class="fas fa-circle fa-fw {% if document.draft %}draft{% else %}published{% endif %}"></i> <a href="{% url 'document' doc_id=document.id %}">{{ document.title }}</a> · {{ document.language }}
{% if perms.indigo_api.publish_document %}
<a href="{% url 'choose_document_provision' doc_id=document.id %}" class="ms-3"><i class="fas fa-list me-1"></i> {% trans "Provision editor" %}</a>
{% endif %}
{% endblock %}
</div>
{% endfor %}
{% for task in entry.tasks %}
<div class="h6 mt-3">
Expand Down
8 changes: 2 additions & 6 deletions indigo_app/views/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class ChooseDocumentProvisionView(AbstractAuthedIndigoView, DetailView):
context_object_name = 'document'
pk_url_kwarg = 'doc_id'
template_name = 'indigo_api/document/_provisions.html'
permission_required = ('indigo_api.publish_document',)

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
Expand All @@ -119,13 +120,11 @@ def descend_toc_dict(items):
elem['href'] = reverse('document_provision', kwargs={'doc_id': int(self.kwargs['doc_id']), 'eid': elem['id']})
return json.dumps(toc)

def has_permission(self):
return self.request.user.is_superuser


class DocumentProvisionDetailView(DocumentDetailView):
eid = None
provision_xml = None
permission_required = ('indigo_api.publish_document',)

def get(self, request, *args, **kwargs):
document = self.get_object()
Expand All @@ -145,9 +144,6 @@ def get_context_data(self, **kwargs):
def get_document_content_json(self, document):
return json.dumps(etree.tostring(self.provision_xml, encoding='unicode'))

def has_permission(self):
return self.request.user.is_superuser


class DocumentPopupView(AbstractAuthedIndigoView, DetailView):
model = Document
Expand Down

0 comments on commit 5a7bf0f

Please sign in to comment.