Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kommune tabel + data #1121

Merged
merged 2 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions members/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
EmailTemplate,
Equipment,
Family,
Municipality,
Payment,
Person,
Union,
Expand All @@ -25,6 +26,7 @@
from .department_admin import DepartmentAdmin
from .equipment_admin import EquipmentAdmin
from .family_admin import FamilyAdmin
from .municipality_admin import MunicipalityAdmin
from .payment_admin import PaymentAdmin
from .person_admin import PersonAdmin
from .union_admin import UnionAdmin
Expand All @@ -43,6 +45,7 @@
admin.site.register(EmailTemplate)
admin.site.register(Equipment, EquipmentAdmin)
admin.site.register(Family, FamilyAdmin)
admin.site.register(Municipality, MunicipalityAdmin)
admin.site.register(Payment, PaymentAdmin)
admin.site.register(Person, PersonAdmin)
admin.site.register(Union, UnionAdmin)
Expand Down
5 changes: 5 additions & 0 deletions members/admin/municipality_admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.contrib import admin


class MunicipalityAdmin(admin.ModelAdmin):
list_display = ("municipality", "address", "zipcode", "city", "email")
45 changes: 45 additions & 0 deletions members/management/commands/import_municipalities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import csv
from django.core.management.base import BaseCommand
from members.models import Municipality

# run locally:
# docker compose run web ./manage.py import_municipalities members/management/commands/municipalities.csv


class Command(BaseCommand):
help = "Import municipalities data from a CSV file into the Municipality model"

def add_arguments(self, parser):
parser.add_argument(
"csv_file",
type=str,
help="Path to the CSV file containing municipalities data",
)

def handle(self, *args, **kwargs):
csv_file_path = kwargs["csv_file"]

try:
with open(csv_file_path, mode="r", encoding="utf-8") as file:
reader = csv.reader(file, delimiter=";")
for row in reader:
municipality, address, zipcode, city, email = row
Municipality.objects.create(
municipality=municipality,
address=address,
zipcode=zipcode,
city=city,
email=email,
)
self.stdout.write(f"Added municipality: {municipality}")

self.stdout.write(
self.style.SUCCESS("Successfully imported all municipalities")
)

except FileNotFoundError:
self.stdout.write(
self.style.ERROR(
f"File {csv_file_path} not found. Please check the file path."
)
)
98 changes: 98 additions & 0 deletions members/management/commands/municipalities.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
Albertslund Kommune;Nordmarks Allé;2620;Albertslund;[email protected]
Allerød Kommune;Bjarkesvej;3450;Allerød;[email protected]
Assens Kommune;Rådhus Allé 5;5610;Assens;[email protected]
Ballerup Kommune;Hold-an Vej 7;2750;Ballerup;[email protected]
Billund Kommune;Jorden Rundt 1;7200;Grindsted;[email protected]
Bornholms Regionskommune;Ullasvej 23;3700;Rønne;[email protected]
Brøndby Kommune;Park Allé 160;2605;Brøndby;[email protected]
Brønderslev Kommune;Ny Rådhusplads 1;9700;Brønderslev;[email protected]
Dragør Kommune;Kirkevej 7;2791;Dragør;[email protected]
Egedal Kommune;Dronning Dagmars Vej 200;3660;Stenløse;[email protected]
Esbjerg Kommune;Torvegade 74;6700;Esbjerg;[email protected]
Fanø Kommune;Skolevej 5-7;6720;Fanø;[email protected]
Favrskov Kommune;Skovvej 20;8382;Hinnerup;[email protected]
Faxe Kommune;Frederiksgade 9;4690;Haslev;[email protected]
Fredensborg Kommune;Egevangen 3 B;2980;Kokkedal;[email protected]
Fredericia Kommune;Gothersgade 20;7000;Fredericia;[email protected]
Frederiksberg Kommune;Smallegade 1;2000;Frederiksberg;[email protected]
Frederikshavn Kommune;Rådhus Allé 100;9900;Frederikshavn;[email protected]
Frederikssund Kommune;Torvet 2;3600;Frederikssund;[email protected]
Furesø Kommune;Rådhustorvet 2;3520;Farum;[email protected]
Faaborg-Midtfyn Kommune;Tinghøj Allé 2;5750;Ringe;[email protected]
Gentofte Kommune;Bernstorffsvej 161;2920;Charlottenlund;[email protected]
Gladsaxe Kommune;Rådhus Allé 7;2860;Søborg;[email protected]
Glostrup Kommune;Rådhusparken 2;2600;Glostrup;[email protected]
Greve Kommune;Rådhusholmen 10;2670;Greve;[email protected]
Gribskov Kommune;Rådhusvej 3;3200;Helsinge;[email protected]
Guldborgsund Kommune;Parkvej 37;4800;Nykøbing Falster;[email protected]
Haderslev Kommune;Christian X's Vej 39;6100;Haderslev;[email protected]
Halsnæs Kommune;Rådhuspladsen 1;3300;Frederiksværk;[email protected]
Hedensted Kommune;Niels Espes Vej 8;8722;Hedensted;[email protected]
Helsingør Kommune;Stengade 59;3000;Helsingør;[email protected]
Herlev Kommune;Herlev Bygade 90;2730;Herlev;[email protected]
Herning Kommune;Torvet;7400;Herning;[email protected]
Hillerød Kommune;Trollesmindealle 27;3400;Hillerød;[email protected]
Hjørring Kommune;Nørregade 2;9800;Hjørring;[email protected]
Holbæk Kommune;Kanalstræde 2;4300;Holbæk;[email protected]
Holstebro Kommune;Kirkestræde 11;7500;Holstebro;[email protected]
Horsens Kommune;Rådhustorvet 4;8700;Horsens;[email protected]
Hvidovre Kommune;Hvidovrevej 278;2650;Hvidovre;[email protected]
Høje-Taastrup Kommune;Rådhusstræde 1;2630;Taastrup;[email protected]
Hørsholm Kommune;Slotsmarken 13;2970;Hørsholm;[email protected]
Ikast-Brande Kommune;Rådhusstrædet 6;7430;Ikast;[email protected]
Ishøj Kommune;Ishøj Store Torv 20;2635;Ishøj;[email protected]
Jammerbugt Kommune;Toftevej 43;9440;Aabybro;[email protected]
Kalundborg Kommune;Klosterparkvej 7;4400;Kalundborg;[email protected]
Kerteminde Kommune;Hans Schacksvej 4;5300;Kerteminde;[email protected]
Kolding Kommune;Akseltorv 1;6000;Kolding;[email protected]
Københavns Kommune;Rådhuset;1599;København V;[email protected]
Køge Kommune;Torvet 1;4600;Køge;[email protected]
Langeland Kommune;Fredensvej 1;5900;Rudkøbing;[email protected]
Lejre Kommune;Møllebjergvej 4;4330;Hvalsø;[email protected]
Lemvig Kommune;Rådhusgade 2;7620;Lemvig;[email protected]
Lolland Kommune;Jernbanegade 7;4930;Maribo;[email protected]
Lyngby-Taarbæk Kommune;Lyngby Torv;2800;Kongens Lyngby;[email protected]
Læsø Kommune;Doktorvejen 2;9940;Læsø;[email protected]
Mariagerfjord Kommune;Nordre Kajgade 1;9500;Hobro;[email protected]
Middelfart Kommune;Nytorv 9;5500;Middelfart;[email protected]
Morsø Kommune;Jernbanevej 7;7900;Nykøbing Mors;[email protected]
Norddjurs Kommune;Torvet 3;8500;Grenaa;[email protected]
Nordfyns Kommune;Østergade 23;5400;Bogense;[email protected]
Nyborg Kommune;Torvet 1;5800;Nyborg;[email protected]
Næstved Kommune;Rådmandshaven 20;4700;Næstved;[email protected]
Odder Kommune;Rådhusgade 3;8300;Odder;[email protected]
Odense Kommune;Flakhaven 2;5000;Odense C;[email protected]
Odsherred Kommune;Nyvej 22;4573;Højby;[email protected]
Randers Kommune;Laksetorvet;8900;Randers C;[email protected]
Rebild Kommune;Hobrovej 110;9530;Støvring;[email protected]
Ringkøbing-Skjern Kommune;Ved Fjorden 6;6950;Ringkøbing;[email protected]
Ringsted Kommune;Sct. Bendtsgade 1;4100;Ringsted;[email protected]
Roskilde Kommune;Rådhusbuen 1;4000;Roskilde;[email protected]
Rudersdal Kommune;Øverødvej 2;2840;Holte;[email protected]
Rødovre Kommune;Rødovre Parkvej 150;2610;Rødovre;[email protected]
Samsø Kommune;Søtofte 10;8305;Samsø;[email protected]
Silkeborg Kommune;Søvej 1;8600;Silkeborg;[email protected]
Skanderborg Kommune;Skanderborg Fælled 1;8660;Skanderborg;[email protected]
Skive Kommune;Torvegade 10;7800;Skive;[email protected]
Slagelse Kommune;Rådhuspladsen 11;4200;Slagelse;[email protected]
Solrød Kommune;Solrød Center 1;2680;Solrød Strand;[email protected]
Sorø Kommune;Rådhusvej 8;4180;Sorø;[email protected]
Stevns Kommune;Rådhuspladsen 4;4660;Store Heddinge;[email protected]
Struer Kommune;Østergade 11-15;7600;Struer;[email protected]
Svendborg Kommune;Ramsherred 5;5700;Svendborg;[email protected]
Syddjurs Kommune;Lundbergsvej 2;8400;Ebbeltoft;[email protected]
Sønderborg Kommune;Rådhustorvet 10;6400;Sønderborg;[email protected]
Thisted Kommune;Asylgade 30;7700;Thisted;[email protected]
Tønder Kommune;Kongevej 57;6270;Tønder;[email protected]
Tårnby Kommune;Amager Landevej 76;2770;Kastrup;[email protected]
Vallensbæk Kommune;Vallensbæk Stationstorv 100;2665;Vallensbæk Strand;[email protected]
Varde Kommune;Bytoften 2;6800;Varde;[email protected]
Vejen Kommune;Rådhuspassagen 3;6600;Vejen;[email protected]
Vejle Kommune;Skolegade 1;7100;Vejle;[email protected]
Vesthimmerlands Kommune;Vestre Boulevard 7;9600;Aars;[email protected]
Viborg Kommune;Prinsens Alle 5;8800;Viborg;[email protected]
Vordingborg Kommune;Valdemarsgade 43;4760;Vordingborg;[email protected]
Ærø Kommune;Statene 2;5970;Ærøskøbing;[email protected]
Aabenraa Kommune;Skelbækvej 2;6200;Aabenraa;[email protected]
Aalborg Kommune;Boulevarden 13;9000;Aalborg;[email protected]
Aarhus Kommune;Rådhuspladsen 2;8000;Aarhus C;[email protected]
40 changes: 40 additions & 0 deletions members/migrations/0057_municipality.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 4.2.16 on 2024-10-27 13:07

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("members", "0056_alter_activityinvite_activity"),
]

operations = [
migrations.CreateModel(
name="Municipality",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"municipality",
models.CharField(max_length=255, verbose_name="Kommune"),
),
("address", models.CharField(max_length=255, verbose_name="Adresse")),
("zipcode", models.CharField(max_length=10, verbose_name="Postnr")),
("city", models.CharField(max_length=100, verbose_name="By")),
("email", models.EmailField(max_length=254, verbose_name="E-mail")),
],
options={
"verbose_name": "Kommune",
"verbose_name_plural": "Kommuner",
"ordering": ["municipality"],
},
),
]
3 changes: 3 additions & 0 deletions members/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import members.models.equipment
import members.models.equipmentloan
import members.models.family
import members.models.municipality
import members.models.notification
import members.models.payment
import members.models.person
Expand All @@ -41,6 +42,7 @@
from .equipment import Equipment
from .equipmentloan import EquipmentLoan
from .family import Family
from .municipality import Municipality
from .notification import Notification
from .payment import Payment
from .person import Person
Expand Down Expand Up @@ -69,6 +71,7 @@
EquipmentLoan,
Family,
gatherDayliStatistics,
Municipality,
Notification,
Payment,
Person,
Expand Down
17 changes: 17 additions & 0 deletions members/models/municipality.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.db import models


class Municipality(models.Model):
municipality = models.CharField(max_length=255, verbose_name="Kommune")
address = models.CharField(max_length=255, verbose_name="Adresse")
zipcode = models.CharField(max_length=10, verbose_name="Postnr")
city = models.CharField(max_length=100, verbose_name="By")
email = models.EmailField(verbose_name="E-mail")

def __str__(self):
return f"{self.municipality}, {self.zipcode} {self.city}"

class Meta:
verbose_name = "Kommune"
verbose_name_plural = "Kommuner"
ordering = ["municipality"]
Loading