Skip to content

Commit

Permalink
Clear org country field
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Jan 10, 2025
1 parent f7b5953 commit 1ada712
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
20 changes: 20 additions & 0 deletions temba/orgs/migrations/0166_clear_org_country_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 5.1.4 on 2025-01-09 17:51

from django.db import migrations


def clear_org_country_field(apps, schema_editor):
Org = apps.get_model("orgs", "Org")

orgs = Org.objects.all().exclude(country=None)
if orgs:
orgs.update(country=None)

Check warning on line 11 in temba/orgs/migrations/0166_clear_org_country_field.py

View check run for this annotation

Codecov / codecov/patch

temba/orgs/migrations/0166_clear_org_country_field.py#L11

Added line #L11 was not covered by tests


class Migration(migrations.Migration):

dependencies = [
("orgs", "0165_org_location"),
]

operations = [migrations.RunPython(clear_org_country_field, migrations.RunPython.noop)]
4 changes: 3 additions & 1 deletion temba/orgs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ class Org(SmartModel):
default=DATE_FORMAT_DAY_FIRST,
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)
Expand Down Expand Up @@ -537,6 +536,9 @@ class Org(SmartModel):
released_on = models.DateTimeField(null=True)
deleted_on = models.DateTimeField(null=True)

# Deprecated
country = models.ForeignKey("locations.AdminBoundary", null=True, on_delete=models.PROTECT)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

Expand Down

0 comments on commit 1ada712

Please sign in to comment.