From 8371e2ab876ea23e5d0267120dc70784e3d13e1b Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Thu, 14 Feb 2019 02:25:29 +0100 Subject: [PATCH] Change options on finances.Subsidy --- finances/constants.py | 13 ++++++--- .../migrations/0009_auto_20190214_0202.py | 20 ++++++++++++++ .../migrations/0010_updatesubsidytypes.py | 27 +++++++++++++++++++ .../migrations/0011_auto_20190214_0224.py | 20 ++++++++++++++ finances/models.py | 2 +- 5 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 finances/migrations/0009_auto_20190214_0202.py create mode 100644 finances/migrations/0010_updatesubsidytypes.py create mode 100644 finances/migrations/0011_auto_20190214_0224.py diff --git a/finances/constants.py b/finances/constants.py index b700a6f04..5c2d63d1a 100644 --- a/finances/constants.py +++ b/finances/constants.py @@ -5,14 +5,19 @@ __license__ = "AGPL v3" import datetime -SUBSIDY_TYPE_GRANT = 'grant' -SUBSIDY_TYPE_PARTNERAGREEMENT = 'partneragreement' +SUBSIDY_TYPE_SPONSORSHIPAGREEMENT = 'sponsorshipagreement' +SUBSIDY_TYPE_INCIDENTALGRANT = 'incidentalgrant' +SUBSIDY_TYPE_DEVELOPMENTGRANT = 'developmentgrant' SUBSIDY_TYPE_COLLABORATION = 'collaborationagreement' +SUBSIDY_TYPE_DONATION = 'donation' + SUBSIDY_TYPES = ( - (SUBSIDY_TYPE_GRANT, 'Grant'), - (SUBSIDY_TYPE_PARTNERAGREEMENT, 'Partner Agreement'), + (SUBSIDY_TYPE_SPONSORSHIPAGREEMENT, 'Sponsorship Agreement'), + (SUBSIDY_TYPE_INCIDENTALGRANT, 'Incidental Grant'), + (SUBSIDY_TYPE_DEVELOPMENTGRANT, 'Development Grant'), (SUBSIDY_TYPE_COLLABORATION, 'Collaboration Agreement'), + (SUBSIDY_TYPE_DONATION, 'Donation'), ) diff --git a/finances/migrations/0009_auto_20190214_0202.py b/finances/migrations/0009_auto_20190214_0202.py new file mode 100644 index 000000000..753137c47 --- /dev/null +++ b/finances/migrations/0009_auto_20190214_0202.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2019-02-14 01:02 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('finances', '0008_subsidy_amount_publicly_shown'), + ] + + operations = [ + migrations.AlterField( + model_name='subsidy', + name='subsidy_type', + field=models.CharField(choices=[('sponsorshipagreement', 'Sponsorship Agreement'), ('incidentalgrant', 'Incidental Grant'), ('developmentgrant', 'Development Grant'), ('collaborationagreement', 'Collaboration Agreement'), ('donation', 'Donation'), ('grant', 'Grant'), ('partneragreement', 'Partner Agreement')], max_length=256), + ), + ] diff --git a/finances/migrations/0010_updatesubsidytypes.py b/finances/migrations/0010_updatesubsidytypes.py new file mode 100644 index 000000000..6088e5d3b --- /dev/null +++ b/finances/migrations/0010_updatesubsidytypes.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2019-02-14 01:04 +from __future__ import unicode_literals + +from django.db import migrations + +from finances.constants import SUBSIDY_TYPE_SPONSORSHIPAGREEMENT, SUBSIDY_TYPE_INCIDENTALGRANT + +def update_subsidy_types(apps, schema_editor): + Subsidy = apps.get_model('finances', 'Subsidy') + + Subsidy.objects.filter(subsidy_type='grant').update( + subsidy_type=SUBSIDY_TYPE_INCIDENTALGRANT) + Subsidy.objects.filter(subsidy_type='partneragreement').update( + subsidy_type=SUBSIDY_TYPE_SPONSORSHIPAGREEMENT) + + +class Migration(migrations.Migration): + + dependencies = [ + ('finances', '0009_auto_20190214_0202'), + ] + + operations = [ + migrations.RunPython(update_subsidy_types, + reverse_code=migrations.RunPython.noop), + ] diff --git a/finances/migrations/0011_auto_20190214_0224.py b/finances/migrations/0011_auto_20190214_0224.py new file mode 100644 index 000000000..bdbb8e1cd --- /dev/null +++ b/finances/migrations/0011_auto_20190214_0224.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2019-02-14 01:24 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('finances', '0010_updatesubsidytypes'), + ] + + operations = [ + migrations.AlterField( + model_name='subsidy', + name='subsidy_type', + field=models.CharField(choices=[('sponsorshipagreement', 'Sponsorship Agreement'), ('incidentalgrant', 'Incidental Grant'), ('developmentgrant', 'Development Grant'), ('collaborationagreement', 'Collaboration Agreement'), ('donation', 'Donation')], max_length=256), + ), + ] diff --git a/finances/models.py b/finances/models.py index 7cc8f0707..4c2a85bc1 100644 --- a/finances/models.py +++ b/finances/models.py @@ -21,7 +21,7 @@ class Subsidy(models.Model): to a corresponding Subsidy instance. This can for example be: - - a Partners agreement + - a Sponsorship agreement - an incidental grant - a development grant for a specific purpose - a Collaboration Agreement -- GitLab