diff --git a/tola/management/commands/loadinitialdata.py b/tola/management/commands/loadinitialdata.py index bd212fb6a..cd0f3565a 100644 --- a/tola/management/commands/loadinitialdata.py +++ b/tola/management/commands/loadinitialdata.py @@ -1017,6 +1017,7 @@ def _create_site_profiles(self): latitude="33.500", longitude="36.300", created_by=self._tolauser_ninette.user, # 11 + organization=self._organization, )) self._site_profiles.append(factories.SiteProfile( @@ -1026,6 +1027,7 @@ def _create_site_profiles(self): latitude="36.2130824982", longitude="37.1569335937", created_by=self._tolauser_ninette.user, # 11 + organization=self._organization, )) self._site_profiles.append(factories.SiteProfile( @@ -1035,6 +1037,7 @@ def _create_site_profiles(self): latitude="35.1421960686", longitude="36.7504394531", created_by=self._tolauser_ninette.user, # 11 + organization=self._organization, )) self._site_profiles.append(factories.SiteProfile( @@ -1044,6 +1047,7 @@ def _create_site_profiles(self): latitude="34.8959", longitude="35.8867", created_by=self._tolauser_ninette.user, # 11 + organization=self._organization, )) self._site_profiles.append(factories.SiteProfile( @@ -1053,6 +1057,7 @@ def _create_site_profiles(self): latitude="34.7369225399", longitude="36.7284667969", created_by=self._tolauser_ninette.user, # 11 + organization=self._organization, )) self._site_profiles.append(factories.SiteProfile( @@ -1062,6 +1067,7 @@ def _create_site_profiles(self): latitude="50.9692657293000000", longitude="6.9889383750000000", created_by=self._tolauser_ninette.user, + organization=self._organization, )) self._site_profiles.append(factories.SiteProfile( @@ -1071,6 +1077,7 @@ def _create_site_profiles(self): latitude="49.4507464458000000", longitude="11.0319071250000000", created_by=self._tolauser_ninette.user, + organization=self._organization, )) def _create_stakeholders(self): diff --git a/tola/management/commands/tests/test_loadinitialdata.py b/tola/management/commands/tests/test_loadinitialdata.py index 43a3eb3ba..7caf36a8e 100644 --- a/tola/management/commands/tests/test_loadinitialdata.py +++ b/tola/management/commands/tests/test_loadinitialdata.py @@ -218,7 +218,7 @@ def test_restore_having_historical_dependent_data(self): organization = factories.Organization(name='Some org') country = factories.Country(country='Brazil', code='BR') factories.SiteProfile(organization=organization, country=country) - siteprofile_history_id = SiteProfile.history.get(country=country).id + siteprofile_history_id = SiteProfile.history.get(organization=organization).id args = ['--demo'] opts = {} diff --git a/workflow/migrations/0027_auto_20180810_0530.py b/workflow/migrations/0027_auto_20180810_0530.py deleted file mode 100644 index 190051afc..000000000 --- a/workflow/migrations/0027_auto_20180810_0530.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.3 on 2018-08-10 12:30 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('workflow', '0026_organization_phone'), - ] - - operations = [ - migrations.RemoveField( - model_name='historicalsiteprofile', - name='organization', - ), - migrations.RemoveField( - model_name='siteprofile', - name='organization', - ), - migrations.AddField( - model_name='organization', - name='site', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='workflow.SiteProfile'), - ), - ] diff --git a/workflow/migrations/0028_auto_20180814_0045.py b/workflow/migrations/0027_auto_20180814_0045.py similarity index 93% rename from workflow/migrations/0028_auto_20180814_0045.py rename to workflow/migrations/0027_auto_20180814_0045.py index 82ff5246b..bf24eebf3 100644 --- a/workflow/migrations/0028_auto_20180814_0045.py +++ b/workflow/migrations/0027_auto_20180814_0045.py @@ -9,7 +9,7 @@ class Migration(migrations.Migration): dependencies = [ - ('workflow', '0027_auto_20180810_0530'), + ('workflow', '0026_organization_phone'), ] operations = [ diff --git a/workflow/models.py b/workflow/models.py index 79690c949..aec31bcd1 100755 --- a/workflow/models.py +++ b/workflow/models.py @@ -153,7 +153,6 @@ class Organization(models.Model): currency_format = models.CharField("Currency Format", max_length=50, blank=True, default="Commas") allow_budget_decimal = models.BooleanField("Allow Budget in Decimal", default=True) phone = models.CharField(max_length=20, blank=True, null=True) - site = models.ForeignKey("SiteProfile", blank=True, null=True) class Meta: ordering = ('name',) @@ -949,6 +948,7 @@ class SiteProfile(models.Model): approval = models.ManyToManyField(ApprovalWorkflow, blank=True) create_date = models.DateTimeField(null=True, blank=True) edit_date = models.DateTimeField(null=True, blank=True) + organization = models.ForeignKey(Organization, null=True, blank=True) workflowlevel1 = models.ManyToManyField(WorkflowLevel1, blank=True) created_by = models.ForeignKey('auth.User', related_name='sites', null=True, blank=True) history = HistoricalRecords() diff --git a/workflow/tests/test_models.py b/workflow/tests/test_models.py index 937e2aff6..632820f0c 100644 --- a/workflow/tests/test_models.py +++ b/workflow/tests/test_models.py @@ -181,9 +181,3 @@ def test_save_phone(self): organization = factories.Organization(phone="+49 123 456 111") self.assertEqual(organization.phone, "+49 123 456 111") - def test_save_organization_with_siteprofile(self): - country = factories.Country(country='Germany') - siteprofile = factories.SiteProfile(name='Headquarter', - country=country) - organization = factories.Organization(site=siteprofile) - self.assertEqual(organization.site.name, 'Headquarter')