diff --git a/members/migrations/0059_remove_person_municipality.py b/members/migrations/0059_remove_person_municipality.py new file mode 100644 index 00000000..0856792e --- /dev/null +++ b/members/migrations/0059_remove_person_municipality.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.16 on 2024-11-11 21:18 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ( + "members", + "0058_alter_municipality_options_remove_municipality_email_and_more", + ), + ] + + operations = [ + migrations.RemoveField( + model_name="person", + name="municipality", + ), + ] diff --git a/members/migrations/0060_person_municipality.py b/members/migrations/0060_person_municipality.py new file mode 100644 index 00000000..14176e61 --- /dev/null +++ b/members/migrations/0060_person_municipality.py @@ -0,0 +1,25 @@ +# Generated by Django 4.2.16 on 2024-11-11 21:35 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ("members", "0059_remove_person_municipality"), + ] + + operations = [ + migrations.AddField( + model_name="person", + name="municipality", + field=models.ForeignKey( + blank=True, + default="", + null=True, + on_delete=django.db.models.deletion.RESTRICT, + to="members.municipality", + ), + ), + ] diff --git a/members/models/person.py b/members/models/person.py index 91415461..e3c2ad0d 100644 --- a/members/models/person.py +++ b/members/models/person.py @@ -1,6 +1,7 @@ from django.db import models from django.utils import timezone from django.conf import settings +from members.models.municipality import Municipality from members.utils.address import format_address from urllib.parse import quote_plus import requests @@ -60,7 +61,10 @@ class Meta: floor = models.CharField("Etage", max_length=10, blank=True) door = models.CharField("Dør", max_length=5, blank=True) dawa_id = models.CharField("DAWA id", max_length=200, blank=True) - municipality = models.CharField("Kommune", max_length=100, blank=True, null=True) + municipality = municipality = models.ForeignKey( + # allow blank values since we don't have addresses for all persons + Municipality, on_delete=models.RESTRICT, blank=True, null=True, default="" + ) longitude = models.DecimalField( "Længdegrad", blank=True, null=True, max_digits=9, decimal_places=6 )