diff --git a/backend/hub/context_processors.py b/backend/hub/context_processors.py
index 5ef26ed3..ec71235c 100644
--- a/backend/hub/context_processors.py
+++ b/backend/hub/context_processors.py
@@ -31,7 +31,9 @@ def hub_settings(_: WSGIRequest) -> Dict[str, Any]:
"CANDIDATE_VOTING_ENABLED": flags.get(FLAG_CHOICES.enable_candidate_voting, False),
"CANDIDATE_CONFIRMATION_ENABLED": flags.get(FLAG_CHOICES.enable_candidate_confirmation, False),
"RESULTS_ENABLED": flags.get(FLAG_CHOICES.enable_results_display, False),
- "GLOBAL_SUPPORT_ENABLED": flags.get(FLAG_CHOICES.global_support_round, False),
"ORG_APPROVAL_ENABLED": flags.get(FLAG_CHOICES.enable_org_approval, False),
"ORG_REGISTRATION_ENABLED": flags.get(FLAG_CHOICES.enable_org_registration, False),
+ # Settings flags
+ "GLOBAL_SUPPORT_ENABLED": flags.get(FLAG_CHOICES.global_support_round, False),
+ "VOTING_DOMAIN_ENABLED": flags.get(FLAG_CHOICES.enable_voting_domain, False),
}
diff --git a/backend/hub/templates/hub/ngo/components/ngo_listing_detail.html b/backend/hub/templates/hub/ngo/components/ngo_listing_detail.html
new file mode 100644
index 00000000..31590ccc
--- /dev/null
+++ b/backend/hub/templates/hub/ngo/components/ngo_listing_detail.html
@@ -0,0 +1,32 @@
+{% load static %}
+
+
+
+
+
+
+
+
+
+
+
+
{{ ngo.name }}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/backend/hub/templates/hub/ngo/components/ngos_listing.html b/backend/hub/templates/hub/ngo/components/ngos_listing.html
new file mode 100644
index 00000000..122fefbc
--- /dev/null
+++ b/backend/hub/templates/hub/ngo/components/ngos_listing.html
@@ -0,0 +1,5 @@
+{% for ngo in page_obj %}
+
+ {% include "hub/ngo/components/ngo_listing_detail.html" %}
+
+{% endfor %}
diff --git a/backend/hub/templates/hub/ngo/components/ngos_listing_by_voting_domain.html b/backend/hub/templates/hub/ngo/components/ngos_listing_by_voting_domain.html
new file mode 100644
index 00000000..8db7c911
--- /dev/null
+++ b/backend/hub/templates/hub/ngo/components/ngos_listing_by_voting_domain.html
@@ -0,0 +1,17 @@
+
+
+
+{% for section_details in page_obj %}
+
+
+ {{ section_details.domain.name }} ({{ section_details.organizations|length }})
+
+
+ {% for ngo in section_details.organizations %}
+
+ {% include "hub/ngo/components/ngo_listing_detail.html" %}
+
+ {% endfor %}
+
+{% endfor %}
+
diff --git a/backend/hub/templates/hub/ngo/detail.html b/backend/hub/templates/hub/ngo/detail.html
index 7fdd8eb0..622d15c0 100644
--- a/backend/hub/templates/hub/ngo/detail.html
+++ b/backend/hub/templates/hub/ngo/detail.html
@@ -44,6 +44,11 @@
{{ ngo.name }}
+ {% if "approve_organization" in user_permissions or "view_data_organization" in user_permissions and ngo.voting_domain %}
+
+ Domeniu: {{ ngo.voting_domain }}
+ {% endif %}
+
{% if "approve_organization" in user_permissions or "view_data_organization" in user_permissions %}
Stare aplicație: {% trans ngo.status.capitalize %}
diff --git a/backend/hub/templates/hub/ngo/list.html b/backend/hub/templates/hub/ngo/list.html
index 754c7405..04af3875 100644
--- a/backend/hub/templates/hub/ngo/list.html
+++ b/backend/hub/templates/hub/ngo/list.html
@@ -32,141 +32,17 @@
{% trans "Registered organizations" %} ({{ counters.ngos_accepted }})
- {% comment %}
-
- {% endcomment %}
-
{% if page_obj %}
- {% for ngo in page_obj %}
-
-
-
-
-
-
-
-
-
-
-
-
{{ ngo.name }}
-
-
-
- {% comment %}
-
{% trans 'Founders' %}: {{ ngo.founders }}
-
-
- {% endcomment %}
-
-
-
-
-
-
-
- {% endfor %}
+
+ {% if VOTING_DOMAIN_ENABLED %}
+ {% include "hub/ngo/components/ngos_listing_by_voting_domain.html" %}
+ {% else %}
+ {% include "hub/ngo/components/ngos_listing.html" %}
+ {% endif %}
+
{% include "hub/shared/pagination.html" with page_obj=page_obj domain=current_domain %}
diff --git a/backend/hub/views.py b/backend/hub/views.py
index 8338c0f3..7f9a99c7 100644
--- a/backend/hub/views.py
+++ b/backend/hub/views.py
@@ -1,6 +1,6 @@
import logging
from datetime import datetime
-from typing import Dict, Optional
+from typing import Dict, List, Optional, Union
from urllib.parse import unquote
from django.conf import settings
@@ -192,6 +192,28 @@ class OrganizationListView(SearchMixin):
paginate_by = 9
template_name = "hub/ngo/list.html"
+ def group_organizations_by_domain(self, queryset) -> List[Dict[str, Union[Domain, List[Organization]]]]:
+ organizations_by_domain: Dict[Domain, List[Organization]] = {}
+
+ for organization in queryset:
+ domain_name: Domain = organization.voting_domain
+ if domain_name not in organizations_by_domain:
+ organizations_by_domain[domain_name] = []
+
+ organizations_by_domain[domain_name].append(organization)
+
+ # dictionary to list of dictionaries
+ organizations_by_domain_list = [
+ {
+ "domain": domain,
+ "organizations": sorted(organizations, key=lambda org: org.name),
+ }
+ for domain, organizations in organizations_by_domain.items()
+ ]
+ organizations_by_domain_list = sorted(organizations_by_domain_list, key=lambda x: x["domain"].pk)
+
+ return organizations_by_domain_list
+
def get(self, request, *args, **kwargs):
response = super().get(request, *args, **kwargs)
@@ -204,9 +226,14 @@ def get_qs(self):
return Organization.objects.filter(status=Organization.STATUS.accepted)
def get_queryset(self):
- qs = self.search(self.get_qs())
+ queryset = self.search(self.get_qs())
filters = {name: self.request.GET[name] for name in self.allow_filters if self.request.GET.get(name)}
- return qs.filter(**filters)
+ queryset_filtered = queryset.filter(**filters)
+
+ if FeatureFlag.flag_enabled(SETTINGS_CHOICES.enable_voting_domain):
+ return self.group_organizations_by_domain(queryset_filtered)
+
+ return queryset_filtered
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)