From 801e85ea9b44de5d2d6290b39c130b641b0e2d8a Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Wed, 10 Oct 2018 19:20:58 +0200 Subject: [PATCH] Improve finances pages --- finances/models.py | 1 + finances/templates/finances/finances.html | 21 ++++++++++++--- finances/templates/finances/subsidy_list.html | 26 +++++++++++++++++-- finances/views.py | 12 +++++++++ .../organizations/organization_list.html | 12 +++++++-- scipost/templates/scipost/foundation.html | 4 +-- 6 files changed, 66 insertions(+), 10 deletions(-) diff --git a/finances/models.py b/finances/models.py index ecfa0ffca..f7755ead7 100644 --- a/finances/models.py +++ b/finances/models.py @@ -42,6 +42,7 @@ class Subsidy(models.Model): class Meta: verbose_name_plural = 'subsidies' + ordering = ['-date'] def __str__(self): return format_html('{}: €{} from {}, for {}', diff --git a/finances/templates/finances/finances.html b/finances/templates/finances/finances.html index 1a6698429..18a77af44 100644 --- a/finances/templates/finances/finances.html +++ b/finances/templates/finances/finances.html @@ -1,5 +1,6 @@ {% extends 'finances/base.html' %} +{% load staticfiles %} {% load bootstrap %} {% block breadcrumb_items %} @@ -12,13 +13,27 @@ {% block content %} <div class="row"> <div class="col-12"> - <h3 class="highlight">Finances</h3> + <h2>Finances</h2> + <h3 class="highlight">Subsidies</h3> <ul> <li><a href="{% url 'finances:subsidies' %}">View {% if perms.scipost.can_manage_subsidies %}(and manage) {% endif %}info on Subsidies obtained by SciPost</a></li> - {% if perms.scipost.can_view_timesheets %} + </ul> + + <h3 class="highlight" id="reports">Financial Reports</h3> + <ul> + <li><a href="{% static 'scipost/info/AnnualReports/AnnualReport_2015.pdf' %}">Annual Report 2015</a></li> + <li><a href="{% static 'scipost/info/AnnualReports/AnnualReport_2016.pdf' %}">Annual Report 2016</a></li> + <li><a href="{% static 'scipost/info/AnnualReports/AnnualReport_2017.pdf' %}">Annual Report 2017</a></li> + </ul> + + {% if perms.scipost.can_view_timesheets %} + <h3 class="highlight">Timesheets</h3> + <ul> <li><a href="{% url 'finances:timesheets' %}">Manage Timesheets</a></li> - {% endif %} </ul> + {% endif %} + </div> </div> + {% endblock content %} diff --git a/finances/templates/finances/subsidy_list.html b/finances/templates/finances/subsidy_list.html index 286716e4b..555f2491e 100644 --- a/finances/templates/finances/subsidy_list.html +++ b/finances/templates/finances/subsidy_list.html @@ -42,8 +42,30 @@ $(document).ready(function($) { <tr> <th>From Organization</th> <th>Type</th> - <th>Amount</th> - <th>Date</th> + <th>Amount + {% if request.GET.ordering != 'asc' %} + <a href="?order_by=amount&ordering=asc"><i class="fa fa-sort-asc"></i></a> + {% else %} + <a href="{% url 'finances:subsidies' %}"><i class="fa fa-sort-asc"></i></a> + {% endif %} + {% if request.GET.ordering != 'desc' %} + <a href="?order_by=amount&ordering=desc"><i class="fa fa-sort-desc"></i></a> + {% else %} + <a href="{% url 'finances:subsidies' %}"><i class="fa fa-sort-desc"></i></a> + {% endif %} + </th> + <th>Date + {% if request.GET.ordering != 'asc' %} + <a href="?order_by=date&ordering=asc"><i class="fa fa-sort-asc"></i></a> + {% else %} + <a href="{% url 'finances:subsidies' %}"><i class="fa fa-sort-asc"></i></a> + {% endif %} + {% if request.GET.ordering != 'desc' %} + <a href="?order_by=date&ordering=desc"><i class="fa fa-sort-desc"></i></a> + {% else %} + <a href="{% url 'finances:subsidies' %}"><i class="fa fa-sort-desc"></i></a> + {% endif %} + </th> </tr> </thead> <tbody> diff --git a/finances/views.py b/finances/views.py index 0344eb229..73d12841f 100644 --- a/finances/views.py +++ b/finances/views.py @@ -58,6 +58,18 @@ class SubsidyDeleteView(PermissionsMixin, DeleteView): class SubsidyListView(ListView): model = Subsidy + def get_queryset(self): + qs = super().get_queryset() + order_by = self.request.GET.get('order_by') + ordering = self.request.GET.get('ordering') + if order_by == 'amount': + qs = qs.order_by('amount') + elif order_by == 'date': + qs = qs.order_by('date') + if ordering == 'desc': + qs = qs.reverse() + return qs + class SubsidyDetailView(DetailView): model = Subsidy diff --git a/organizations/templates/organizations/organization_list.html b/organizations/templates/organizations/organization_list.html index 90645d712..3d854d784 100644 --- a/organizations/templates/organizations/organization_list.html +++ b/organizations/templates/organizations/organization_list.html @@ -73,8 +73,16 @@ $(document).ready(function($) { <th><a href="?order_by=country">Country</a></th> <th><a href="?order_by=name">Name</a> <small>[acronym]</small></th> <th>NAP <i class="fa fa-info-circle" data-toggle="tooltip" data-html="true" title="" data-original-title="Number of associated publications<br/>For details, click on the Organization and consult the Associated Publications tab"></i> - {% if request.GET.ordering != 'asc' %}</a> <a href="?order_by=nap&ordering=asc"><i class="fa fa-sort-asc"></i></a>{% endif %} -{% if request.GET.ordering != 'desc' %}<a href="?order_by=nap&ordering=desc"><i class="fa fa-sort-desc"></i></a>{% endif %} + {% if request.GET.ordering != 'asc' %} + <a href="?order_by=nap&ordering=asc"><i class="fa fa-sort-asc"></i></a> + {% else %} + <a href="{% url 'organizations:organizations' %}"><i class="fa fa-sort-asc"></i></a> + {% endif %} + {% if request.GET.ordering != 'desc' %} + <a href="?order_by=nap&ordering=desc"><i class="fa fa-sort-desc"></i></a> + {% else %} + <a href="{% url 'organizations:organizations' %}"><i class="fa fa-sort-desc"></i></a> + {% endif %} </th> <th>SciPost sponsor?</th> </tr> diff --git a/scipost/templates/scipost/foundation.html b/scipost/templates/scipost/foundation.html index d541dee89..3c4601097 100644 --- a/scipost/templates/scipost/foundation.html +++ b/scipost/templates/scipost/foundation.html @@ -101,9 +101,7 @@ <div class="card-body"> <h2 class="highlight">Financial Reports</h2> <ul> - <li><a href="{% static 'scipost/info/AnnualReports/AnnualReport_2015.pdf' %}">Annual Report 2015</a></li> - <li><a href="{% static 'scipost/info/AnnualReports/AnnualReport_2016.pdf' %}">Annual Report 2016</a></li> - <li><a href="{% static 'scipost/info/AnnualReports/AnnualReport_2017.pdf' %}">Annual Report 2017</a></li> + <li>See all on our <a href="{% url 'finances:finances' %}#reports">Finances page</a></li> </ul> </div> </div> -- GitLab