Skip to content

Commit

Permalink
Refactor organizations' documents
Browse files Browse the repository at this point in the history
- add extra flags for the organization page
- change the document template
- reorganize the organization_documents template
  • Loading branch information
tudoramariei committed Oct 28, 2024
1 parent 3775d2d commit 7f6faf8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 33 deletions.
8 changes: 5 additions & 3 deletions backend/hub/templates/hub/partials/document.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<p>
{% if is_secret and can_view_secret_files or not is_secret %}
<p>
<span class="icon">
{% if is_secret %}
<i class="fas fa-lock"></i>
{% else %}
<i class="fas fa-file"></i>
{% endif %}
</span>
<a href="{{ document_url }}" title={{ document_name }}>{{ document_name }}</a>
</p>
<a href="{{ document_url }}" title={{ document_name }}>{{ document_name }}</a>
</p>
{% endif %}
60 changes: 30 additions & 30 deletions backend/hub/templates/hub/partials/organization_documents.html
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
{% load i18n %}

<div class="detail-desc-title">
<span class="ngo-colorblock"></span>
{% trans "Organization Documents" %}
</div>
{% if should_display_organization_documents %}

{% if can_view_all_information %}
<div class="detail-desc-title">
<span class="ngo-colorblock"></span>
{% trans "Organization Documents" %}
</div>

{% if ngo.last_balance_sheet %}
{% trans "First page of the last balance sheet" as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.last_balance_sheet.url document_name=doc_name is_secret=True %}
{% include "hub/partials/document.html" with document_url=ngo.last_balance_sheet.url document_name=doc_name can_view_secret_files=can_view_all_information is_secret=True %}
{% endif %}

{% if ngo.statute %}
{% trans "NGO Statute" as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.statute.url document_name=doc_name is_secret=True %}
{% include "hub/partials/document.html" with document_url=ngo.statute.url document_name=doc_name can_view_secret_files=can_view_all_information is_secret=True %}
{% endif %}

{% if ngo.fiscal_certificate_anaf %}
{% trans "Fiscal certificate ANAF" as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.fiscal_certificate_anaf.url document_name=doc_name is_secret=True %}
{% include "hub/partials/document.html" with document_url=ngo.fiscal_certificate_anaf.url document_name=doc_name can_view_secret_files=can_view_all_information is_secret=True %}
{% endif %}

{% if ngo.fiscal_certificate_local %}
{% trans "Fiscal certificate local" as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.fiscal_certificate_local.url document_name=doc_name is_secret=True %}
{% include "hub/partials/document.html" with document_url=ngo.fiscal_certificate_local.url document_name=doc_name can_view_secret_files=can_view_all_information is_secret=True %}
{% endif %}

{% endif %}

{% if ngo.report_2023 %}
{% trans "Yearly report 2023" as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.report_2023.url document_name=doc_name %}
{% endif %}
{% if ngo.report_2023 %}
{% trans "Yearly report 2023" as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.report_2023.url document_name=doc_name can_view_secret_files=can_view_all_information is_secret=False %}
{% endif %}

{% if ngo.report_2022 %}
{% trans "Yearly report 2022" as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.report_2022.url document_name=doc_name %}
{% endif %}
{% if ngo.report_2022 %}
{% trans "Yearly report 2022" as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.report_2022.url document_name=doc_name can_view_secret_files=can_view_all_information is_secret=False %}
{% endif %}

{% if ngo.report_2021 %}
{% trans "Yearly report 2021" as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.report_2021.url document_name=doc_name %}
{% endif %}
{% if ngo.report_2021 %}
{% trans "Yearly report 2021" as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.report_2021.url document_name=doc_name can_view_secret_files=can_view_all_information is_secret=False %}
{% endif %}

{% if ngo.statement_discrimination %}
{% trans "Non-discrimination statement " as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.statement_discrimination.url document_name=doc_name %}
{% endif %}
{% if ngo.statement_discrimination %}
{% trans "Non-discrimination statement " as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.statement_discrimination.url document_name=doc_name can_view_secret_files=can_view_all_information is_secret=False %}
{% endif %}

{% if ngo.statement_political %}
{% trans "Non-political statement " as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.statement_political.url document_name=doc_name %}
{% if ngo.statement_political %}
{% trans "Non-political statement " as doc_name %}
{% include "hub/partials/document.html" with document_url=ngo.statement_political.url document_name=doc_name can_view_secret_files=can_view_all_information is_secret=True %}
{% endif %}

{% endif %}
20 changes: 20 additions & 0 deletions backend/hub/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,35 @@ def get_queryset(self):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
user: UserModel = self.request.user
organization: Organization = self.object

context["can_view_all_information"] = False
context["should_display_organization_documents"] = False

if user.is_anonymous:
return context

if user.groups.filter(name__in=[STAFF_GROUP, SUPPORT_GROUP, COMMITTEE_GROUP]).exists():
context["can_view_all_information"] = True

if (
organization.report_2023
or organization.report_2022
or organization.report_2021
or organization.statement_discrimination
or (
context["can_view_all_information"]
and (
organization.last_balance_sheet
or organization.statute
or organization.fiscal_certificate_anaf
or organization.fiscal_certificate_local
or organization.statement_political
)
)
):
context["should_display_organization_documents"] = True

return context


Expand Down

0 comments on commit 7f6faf8

Please sign in to comment.