diff --git a/temba/locations/models.py b/temba/locations/models.py index 2a82abdb14..a75f57565b 100644 --- a/temba/locations/models.py +++ b/temba/locations/models.py @@ -207,9 +207,6 @@ class Location(MPTTModel, models.Model): objects = NoGeometryManager() geometries = GeometryManager() - def __str__(self): - return self.name - class Meta: indexes = [models.Index(Upper("name"), name="locations_by_name")] diff --git a/temba/orgs/migrations/0165_org_location.py b/temba/orgs/migrations/0165_org_location.py new file mode 100644 index 0000000000..e08d1dd752 --- /dev/null +++ b/temba/orgs/migrations/0165_org_location.py @@ -0,0 +1,20 @@ +# Generated by Django 5.1.4 on 2025-01-09 09:39 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("locations", "0033_location_locationalias_location_locations_by_name_and_more"), + ("orgs", "0164_remove_viewers"), + ] + + operations = [ + migrations.AddField( + model_name="org", + name="location", + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to="locations.location"), + ), + ] diff --git a/temba/orgs/models.py b/temba/orgs/models.py index 7f18df6887..869b45a3a1 100644 --- a/temba/orgs/models.py +++ b/temba/orgs/models.py @@ -507,6 +507,7 @@ class Org(SmartModel): help_text=_("Default formatting and parsing of dates in flows and messages."), ) country = models.ForeignKey("locations.AdminBoundary", null=True, on_delete=models.PROTECT) + location = models.ForeignKey("locations.Location", null=True, on_delete=models.PROTECT) flow_languages = ArrayField(models.CharField(max_length=3), default=list, validators=[ArrayMinLengthValidator(1)]) input_collation = models.CharField(max_length=32, choices=COLLATION_CHOICES, default=COLLATION_DEFAULT) flow_smtp = models.CharField(null=True) # e.g. smtp://... diff --git a/temba/orgs/tests/test_migrations.py b/temba/orgs/tests/test_migrations.py deleted file mode 100644 index 4f93479d97..0000000000 --- a/temba/orgs/tests/test_migrations.py +++ /dev/null @@ -1,10 +0,0 @@ -from temba.tests import MigrationTest - - -class RemoveViewersTest(MigrationTest): - app = "orgs" - migrate_from = "0163_squashed" - migrate_to = "0164_remove_viewers" - - def test_migration(self): - self.assertEqual({self.admin, self.editor, self.agent}, set(self.org.get_users()))