diff --git a/petitions/migrations/0004_auto_20180922_1357.py b/petitions/migrations/0004_auto_20180922_1357.py new file mode 100644 index 0000000000000000000000000000000000000000..ce83b0307c402f4cb63a37af9602a5ef527b4e0e --- /dev/null +++ b/petitions/migrations/0004_auto_20180922_1357.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2018-09-22 11:57 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('petitions', '0003_petitionsignatory_organization'), + ] + + operations = [ + migrations.RenameField( + model_name='petitionsignatory', + old_name='organization', + new_name='organization_tbd', + ), + ] diff --git a/petitions/migrations/0005_petitionsignatory_organization.py b/petitions/migrations/0005_petitionsignatory_organization.py new file mode 100644 index 0000000000000000000000000000000000000000..9e0e8e2624a02b28affed168a060ac236ea9f70b --- /dev/null +++ b/petitions/migrations/0005_petitionsignatory_organization.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2018-09-22 11:58 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('organizations', '0002_populate_from_partners_org'), + ('petitions', '0004_auto_20180922_1357'), + ] + + operations = [ + migrations.AddField( + model_name='petitionsignatory', + name='org', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='petition_signatories', to='organizations.Organization'), + ), + ] diff --git a/petitions/migrations/0006_repopulate_petsign_orgs.py b/petitions/migrations/0006_repopulate_petsign_orgs.py new file mode 100644 index 0000000000000000000000000000000000000000..a82629b898a2f3298fd77c2f5e9f20c9cf8f70e9 --- /dev/null +++ b/petitions/migrations/0006_repopulate_petsign_orgs.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2018-09-22 12:05 +from __future__ import unicode_literals + +from django.db import migrations + + +def repopulate_organization_field(apps, schema_editor): + PetitionSignatory = apps.get_model('petitions', 'PetitionSignatory') + Organization = apps.get_model('organizations', 'Organization') + PartnersOrganization = apps.get_model('partners', 'Organization') + + for petsign in PetitionSignatory.objects.all(): + if petsign.organization_tbd: + org = Organization.objects.get(name=petsign.organization_tbd.name) + petsign.org = org + petsign.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('petitions', '0005_petitionsignatory_organization'), + ] + + operations = [ + migrations.RunPython(repopulate_organization_field, + reverse_code=migrations.RunPython.noop), + ] diff --git a/petitions/migrations/0007_remove_petitionsignatory_organization_tbd.py b/petitions/migrations/0007_remove_petitionsignatory_organization_tbd.py new file mode 100644 index 0000000000000000000000000000000000000000..729a0fd107e6fd738a8a565141b1bc0f9558d195 --- /dev/null +++ b/petitions/migrations/0007_remove_petitionsignatory_organization_tbd.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2018-09-22 12:30 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('petitions', '0006_repopulate_petsign_orgs'), + ] + + operations = [ + migrations.RemoveField( + model_name='petitionsignatory', + name='organization_tbd', + ), + ] diff --git a/petitions/migrations/0008_auto_20180922_1432.py b/petitions/migrations/0008_auto_20180922_1432.py new file mode 100644 index 0000000000000000000000000000000000000000..bdce3bf60e7c08f379b9031b372c9b2cf90fa7d5 --- /dev/null +++ b/petitions/migrations/0008_auto_20180922_1432.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2018-09-22 12:32 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('petitions', '0007_remove_petitionsignatory_organization_tbd'), + ] + + operations = [ + migrations.RenameField( + model_name='petitionsignatory', + old_name='org', + new_name='organization', + ), + ] diff --git a/petitions/models.py b/petitions/models.py index 02385fb91597437b7c215d3e514e8cdb4bc0cd98..bcd50ed24d94038ca48f0720117702ce9b4a1192 100644 --- a/petitions/models.py +++ b/petitions/models.py @@ -39,7 +39,7 @@ class PetitionSignatory(models.Model): email = models.EmailField() country_of_employment = CountryField() affiliation = models.CharField(max_length=300, verbose_name='affiliation') - organization = models.ForeignKey('partners.Organization', blank=True, null=True, + organization = models.ForeignKey('organizations.Organization', blank=True, null=True, on_delete=models.SET_NULL) signed_on = models.DateTimeField(auto_now_add=True) verification_key = models.CharField(max_length=40, blank=True)