Skip to content

Commit

Permalink
Person.municipality field is now foreign key
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmusselsmark committed Nov 11, 2024
1 parent ff2f6d1 commit 03c18ba
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
19 changes: 19 additions & 0 deletions members/migrations/0059_remove_person_municipality.py
Original file line number Diff line number Diff line change
@@ -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",
),
]
25 changes: 25 additions & 0 deletions members/migrations/0060_person_municipality.py
Original file line number Diff line number Diff line change
@@ -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",
),
),
]
6 changes: 5 additions & 1 deletion members/models/person.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
)
Expand Down

0 comments on commit 03c18ba

Please sign in to comment.