From c00df8f2d545c34cf00065706af7b74476780e3c Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Fri, 22 Feb 2019 16:22:02 +0100 Subject: [PATCH] Add by-country listing to Organization list view --- .../organizations/organization_list.html | 18 +++++++++++++ organizations/views.py | 8 +++++- package.json | 25 ++++++++++--------- requirements.txt | 2 +- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/organizations/templates/organizations/organization_list.html b/organizations/templates/organizations/organization_list.html index f238fc47c..25dd34e50 100644 --- a/organizations/templates/organizations/organization_list.html +++ b/organizations/templates/organizations/organization_list.html @@ -5,6 +5,7 @@ {% load staticfiles %} {% load user_groups %} {% load organizations_extras %} +{% load countries %} {% is_scipost_admin request.user as is_scipost_admin %} @@ -16,6 +17,7 @@ $(document).ready(function($) { }); }); </script> +<link rel="stylesheet" href="{% static 'flags/sprite-hq.css' %}"> {% endblock headsup %} {% block breadcrumb_items %} @@ -66,6 +68,22 @@ $(document).ready(function($) { </div> </div> +<div class="row"> + <div class="col-3"> + <h3>Click on flag to view by Country</h3> + </div> + <div class="col-8"> + <ul> + {% for code in countrycodes %} + {% get_country code as country_obj %} + <li style="display: inline-block;"> + <a href="?country={{ code }}"><i class="{{ country_obj.flag_css }}" aria-label="{{ country_obj.code }}" data-toggle="tooltip" title="{{ country_obj.name }}"></i></a> + </li> + {% endfor %} + </ul> + </div> +</div> + <div class="row"> <div class="col-12"> <table class="table table-hover mb-5"> diff --git a/organizations/views.py b/organizations/views.py index e2412aa62..01b3942c5 100644 --- a/organizations/views.py +++ b/organizations/views.py @@ -69,14 +69,20 @@ class OrganizationListView(ListView): context['nr_funders_wo_organization'] = Funder.objects.filter(organization=None).count() context['nr_prospartners_wo_organization'] = ProspectivePartner.objects.filter( organization=None).count() - context['nr_partners_wo_organization'] = Partner.objects.filter(organization=None).count() + context['nr_partners_wo_organization'] = Partner.objects.filter( + organization=None).count() context['pubyears'] = range(int(timezone.now().strftime('%Y')), 2015, -1) + context['countrycodes'] = [code['country'] for code in list( + Organization.objects.all().distinct('country').values('country'))] return context def get_queryset(self): qs = super().get_queryset().exclude(orgtype=ORGTYPE_PRIVATE_BENEFACTOR) + country = self.request.GET.get('country') order_by = self.request.GET.get('order_by') ordering = self.request.GET.get('ordering') + if country: + qs = qs.filter(country=country) if order_by == 'country': qs = qs.order_by('country') elif order_by == 'name': diff --git a/package.json b/package.json index d1b19598b..49222490e 100644 --- a/package.json +++ b/package.json @@ -18,35 +18,36 @@ "author": "SciPost", "homepage": "https://www.scipost.org", "devDependencies": { - "ajv": "^5.2.2", + "ajv": "^5.5.2", "bootstrap": "^4.1.3", - "clean-webpack-plugin": "^0.1.15", - "css-loader": "^0.28.4", + "clean-webpack-plugin": "^0.1.19", + "css-loader": "^0.28.11", "enhanced-resolve": "^3.4.1", "exports-loader": "^0.6.4", - "extract-text-webpack-plugin": "^3.0.0", + "extract-text-webpack-plugin": "^3.0.2", "file-loader": "^0.11.2", "imports-loader": "^0.7.1", "jquery": "^3.3.1", "jquery-ui": "^1.12.1", "node-loader": "^0.6.0", - "node-sass": "^4.4.0", + "node-sass": "^4.11.0", "popper.js": "^1.14.3", "postcss-load-config": "^1.2.0", - "postcss-loader": "^2.0.6", + "postcss-loader": "^2.1.6", "resolve-url-loader": "^1.6.1", - "sass-loader": "^6.0.6", - "sass-resources-loader": "^1.3.0", - "style-loader": "^0.13.1", - "tapable": "^0.2.8", - "tether": "^1.4.0", + "sass-loader": "^6.0.7", + "sass-resources-loader": "^1.3.5", + "style-loader": "^0.13.2", + "tapable": "^0.2.9", + "tether": "^1.4.5", "url-loader": "^1.1.1", - "webpack": "^3.5.4", + "webpack": "^3.12.0", "webpack-bundle-tracker": "^0.3.0", "webpack-glob-entry": "^2.1.1" }, "dependencies": { "bootstrap-loader": "^2.2.0", + "nan": "git+https://github.com/nodejs/nan.git", "npm": "^6.4.1", "npm-install-peers": "^1.2.1", "schema-utils": "^0.3.0" diff --git a/requirements.txt b/requirements.txt index 124e5a6e5..1cb0595fb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ requests==2.18.3 # Django packages django_ajax_selects==1.6 -django-countries==4.6.1 +django-countries==5.3.3 django-debug-toolbar==1.8 django-extensions==1.7.6 django-filter==1.0.4 -- GitLab