Skip to content

Commit

Permalink
update area model to be unique on gss and area type
Browse files Browse the repository at this point in the history
  • Loading branch information
struan committed Nov 7, 2023
1 parent 9e6edbf commit d9cdfd9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
22 changes: 22 additions & 0 deletions hub/migrations/0055_change_gss_uniqueness.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.5 on 2023-11-07 15:45

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("hub", "0054_fill_datatype_area_type"),
]

operations = [
migrations.AlterField(
model_name="area",
name="gss",
field=models.CharField(max_length=30),
),
migrations.AlterUniqueTogether(
name="area",
unique_together={("gss", "area_type")},
),
]
5 changes: 4 additions & 1 deletion hub/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ class Meta:

class Area(models.Model):
mapit_id = models.CharField(max_length=30)
gss = models.CharField(unique=True, max_length=30)
gss = models.CharField(max_length=30)
name = models.CharField(max_length=200)
area_type = models.ForeignKey(AreaType, on_delete=models.CASCADE)
geometry = models.TextField(blank=True, null=True)
Expand Down Expand Up @@ -541,6 +541,9 @@ def get_by_name(cls, name, area_type="WMC"):

return area

Check warning on line 542 in hub/models.py

View check run for this annotation

Codecov / codecov/patch

hub/models.py#L542

Added line #L542 was not covered by tests

class Meta:
unique_together = ["gss", "area_type"]


class AreaData(CommonData):
area = models.ForeignKey(Area, on_delete=models.CASCADE)
Expand Down

0 comments on commit d9cdfd9

Please sign in to comment.