SciPost Code Repository

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

Use subsidy instead of agreement in organization_list

parent 11477ab3
No related branches found
No related tags found
No related merge requests found
......@@ -25,14 +25,3 @@ SUBSIDY_STATUS = (
(SUBSIDY_INVOICED, 'invoiced'),
(SUBSIDY_RECEIVED, 'received'),
)
SUBSIDY_DURATION = (
(datetime.timedelta(days=365), '1 year'),
(datetime.timedelta(days=730), '2 years'),
(datetime.timedelta(days=1095), '3 years'),
(datetime.timedelta(days=1460), '4 years'),
(datetime.timedelta(days=1825), '5 years'),
(datetime.timedelta(days=3650), '10 years'),
(datetime.timedelta(days=36500), 'Indefinite (100 years)'),
)
......@@ -21,7 +21,7 @@ class SubsidyForm(forms.ModelForm):
class Meta:
model = Subsidy
fields = ['organization', 'subsidy_type', 'description',
'amount', 'status', 'date', 'duration']
'amount', 'status', 'date', 'date_until']
class WorkLogForm(forms.ModelForm):
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2018-10-08 12:05
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('finances', '0004_auto_20181007_2016'),
]
operations = [
migrations.RemoveField(
model_name='subsidy',
name='duration',
),
migrations.AddField(
model_name='subsidy',
name='date_until',
field=models.DateField(blank=True, null=True),
),
]
......@@ -10,7 +10,7 @@ from django.urls import reverse
from django.utils import timezone
from django.utils.html import format_html
from .constants import SUBSIDY_TYPES, SUBSIDY_STATUS, SUBSIDY_DURATION
from .constants import SUBSIDY_TYPES, SUBSIDY_STATUS
from .utils import id_to_slug
......@@ -26,6 +26,11 @@ class Subsidy(models.Model):
- a development grant for a specific purpose
- a Collaboration Agreement
- a donation
The date field represents the date at which the Subsidy was formally agreed,
or the agreement enters into force.
The date_until field is optional, and represents (where applicable) the date
after which the object of the Subsidy is officially terminated.
"""
organization = models.ForeignKey('organizations.Organization', on_delete=models.CASCADE)
subsidy_type = models.CharField(max_length=256, choices=SUBSIDY_TYPES)
......@@ -33,7 +38,7 @@ class Subsidy(models.Model):
amount = models.PositiveSmallIntegerField(help_text="in € (rounded)")
status = models.CharField(max_length=32, choices=SUBSIDY_STATUS)
date = models.DateField()
duration = models.DurationField(choices=SUBSIDY_DURATION, blank=True, null=True)
date_until = models.DateField(blank=True, null=True)
class Meta:
verbose_name_plural = 'subsidies'
......
......@@ -2,6 +2,8 @@ __copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
import datetime
from django.contrib.postgres.fields import JSONField
from django.db import models
from django.db.models import Sum
......@@ -129,6 +131,13 @@ class Organization(models.Model):
return False
return self.partner.agreements.now_active().exists()
@property
def has_current_subsidy(self):
"""
Check if this organization has a Subsidy with a still-running validity period.
"""
return self.subsidy_set.filter(date_until__gte=datetime.date.today()).exists()
def get_total_subsidies_obtained(self, n_years_part=None):
"""
Computes the total amount received by SciPost, in the form
......
......@@ -76,7 +76,7 @@ $(document).ready(function($) {
{% 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 %}
</th>
<th>Partner?</th>
<th>SciPost sponsor?</th>
</tr>
</thead>
<tbody>
......@@ -102,9 +102,9 @@ $(document).ready(function($) {
{% endif %}
</td>
<td>{{ org.cf_nr_associated_publications }}</td>
{% if org.has_current_agreement %}
{% if org.has_current_subsidy %}
<td class="bg-success">Yes</td>
{% elif org.partner.agreements %}
{% elif org.subsidy_set.all|length > 0 %}
<td class="bg-primary text-white">Due for renewal</td>
{% else %}
<td class="bg-warning">Not yet</td>
......
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