Skip to content

Commit

Permalink
Merge branch 'master' into Features/finanskonto
Browse files Browse the repository at this point in the history
  • Loading branch information
mhewel committed Nov 11, 2024
2 parents 0b5a394 + b692914 commit e73e0f8
Show file tree
Hide file tree
Showing 27 changed files with 353 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ DATABASE_URL=postgres://postgres_user:postgres_password@database/database_name
POSTGRES_USER=postgres_user
POSTGRES_PASSWORD=postgres_password
POSTGRES_DB=database_name

DATA_UPLOAD_MAX_NUMBER_FIELDS = 10240
3 changes: 2 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ You are more than welcome to contribute to the system. This guide documents how
- The setup adheres to the [twelve-factor-app][12f] principles. To get a
local development configuration, copy the file `.env.example` to `.env`

- Run `docker compose up` to start your local system.
- Run `docker compose up` to start your local system.
(If on Apple Silicon machine, run `docker compose -f docker-compose.yml -f docker-compose.arm64.yml up --build`)

- Run `docker compose run web ./manage.py get_live_data` to download public
data and insert it into your local database.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ jobs:
run: docker compose run web flake8
- name: Test
run: docker compose run web ./manage.py test
- uses: actions/upload-artifact@v2.1.4
- uses: actions/upload-artifact@v4.4.0
if: always()
with:
name: selenium-screens
path: ./test-screens
- name: Create and upload UML diagram
run: mkdir -p UML && docker compose run web ./manage.py graph_models members -o UML/UML_diagram.png
- uses: actions/upload-artifact@v2.1.4
- uses: actions/upload-artifact@v4.4.0
with:
name: UML_diagram.png
path: UML
11 changes: 11 additions & 0 deletions docker-compose.arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# use this file as override, if on Arm64 architecture, e.g. Mac M1
# example commands:
# - docker compose -f docker-compose.yml -f docker-compose.arm64.yml up --build
# - docker compose -f docker-compose.yml -f docker-compose.arm64.yml run --build web ./manage.py test
services:
selenium:
image: seleniarm/standalone-chromium
networks:
- webnet
ports:
- "4444:4444"
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.3"

services:
web:
build: .
Expand Down
4 changes: 4 additions & 0 deletions forenings_medlemmer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
CRISPY_TEMPLATE_PACK = "bootstrap5"

DATA_UPLOAD_MAX_NUMBER_FIELDS = int(os.environ["DATA_UPLOAD_MAX_NUMBER_FIELDS"])

MIDDLEWARE = (
"django.middleware.security.SecurityMiddleware",
"corsheaders.middleware.CorsMiddleware",
Expand Down Expand Up @@ -229,6 +231,8 @@

SECURE_SSL_REDIRECT = env.bool("FORCE_HTTPS")
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
SECURE_BROWSER_XSS_FILTER = True
SECURE_CONTENT_TYPE_NOSNIFF = True


LOGIN_URL = "/account/login/"
Expand Down
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
18 changes: 17 additions & 1 deletion members/admin/activity_admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from django.contrib import admin, messages
from django.conf import settings
from django.core.exceptions import ValidationError
from django.urls import reverse
from django.utils.safestring import mark_safe
from django.utils.html import escape, format_html
Expand Down Expand Up @@ -250,6 +251,21 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs):
kwargs["queryset"] = Address.get_user_addresses(request.user)
return super().formfield_for_foreignkey(db_field, request, **kwargs)

def delete_queryset(self, request, queryset):
for activity in queryset:
print(activity)
self.delete_model(request, activity)

def delete_model(self, request, activity):
try:
activity.delete()
messages.success(request, f'Aktivitet "{activity.name}" slettet.')
except ValidationError as e:
messages.error(request, e.message)

except Exception as e:
messages.error(request, f"Fejl: {str(e)}")

fieldsets = [
(
"Afdeling",
Expand Down
6 changes: 4 additions & 2 deletions members/admin/admin_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ def invite_many_to_activity_action(modelAdmin, request, queryset):
if request.user.is_superuser or request.user.has_perm(
"members.view_all_departments"
):
department_list_query = Department.objects.all().order_by("name")
department_list_query = Department.objects.filter(
closed_dtm__isnull=True
).order_by("name")
else:
department_list_query = Department.objects.filter(
adminuserinformation__user=request.user
adminuserinformation__user=request.user, closed_dtm__isnull=True
).order_by("name")
department_list = [("-", "-")]
for department in department_list_query:
Expand Down
1 change: 1 addition & 0 deletions members/admin/department_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class DepartmentAdmin(admin.ModelAdmin):
"closed_dtm",
"has_waiting_list",
)
autocomplete_fields = ("union",)
raw_id_fields = ("union",)
search_fields = (
"name",
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")
1 change: 1 addition & 0 deletions members/admin/union_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class UnionAdmin(admin.ModelAdmin):
"founded_at",
"closed_at",
)
search_fields = ("name",)
filter_horizontal = ["board_members"]
raw_id_fields = ("chairman", "second_chair", "cashier", "secretary")

Expand Down
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]
23 changes: 23 additions & 0 deletions members/migrations/0056_alter_activityinvite_activity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.16 on 2024-10-27 09:18

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("members", "0055_rename_union_email_union_email"),
]

operations = [
migrations.AlterField(
model_name="activityinvite",
name="activity",
field=models.ForeignKey(
on_delete=django.db.models.deletion.DO_NOTHING,
to="members.activity",
verbose_name="Aktivitet",
),
),
]
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
Loading

0 comments on commit e73e0f8

Please sign in to comment.