Skip to content

Commit

Permalink
Merge pull request #1127 from yilmazbekdemir/issue-434
Browse files Browse the repository at this point in the history
add address field to organization
  • Loading branch information
jefmoura committed Aug 10, 2018
2 parents 906c054 + 557a3bf commit 0d55803
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
7 changes: 0 additions & 7 deletions tola/management/commands/loadinitialdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,6 @@ 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(
Expand All @@ -1027,7 +1026,6 @@ 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(
Expand All @@ -1037,7 +1035,6 @@ 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(
Expand All @@ -1047,7 +1044,6 @@ 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(
Expand All @@ -1057,7 +1053,6 @@ 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(
Expand All @@ -1067,7 +1062,6 @@ 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(
Expand All @@ -1077,7 +1071,6 @@ def _create_site_profiles(self):
latitude="49.4507464458000000",
longitude="11.0319071250000000",
created_by=self._tolauser_ninette.user,
organization=self._organization,
))

def _create_stakeholders(self):
Expand Down
2 changes: 1 addition & 1 deletion tola/management/commands/tests/test_loadinitialdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(organization=organization).id
siteprofile_history_id = SiteProfile.history.get(country=country).id

args = ['--demo']
opts = {}
Expand Down
29 changes: 29 additions & 0 deletions workflow/migrations/0027_auto_20180810_0530.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- 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'),
),
]
2 changes: 1 addition & 1 deletion workflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ 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',)
Expand Down Expand Up @@ -941,7 +942,6 @@ 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()
Expand Down
6 changes: 6 additions & 0 deletions workflow/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,9 @@ 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')

0 comments on commit 0d55803

Please sign in to comment.