SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 801e85ea authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Improve finances pages

parent b342ba25
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,7 @@ class Subsidy(models.Model):
class Meta:
verbose_name_plural = 'subsidies'
ordering = ['-date']
def __str__(self):
return format_html('{}: €{} from {}, for {}',
......
{% 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 %}
......@@ -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>
......
......@@ -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
......
......@@ -73,8 +73,16 @@ $(document).ready(function($) {
<th><a href="?order_by=country">Country</a></th>
<th><a href="?order_by=name">Name</a>&nbsp;&nbsp;<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>
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment