Skip to content

Commit

Permalink
Merge pull request #849 from lakridserne/feature/776_refactor_members…
Browse files Browse the repository at this point in the history
…_table

Introducer feltet person på aktivitetstilmeldingen, så vi ved hvem der er tilmeldt - erstatter member
  • Loading branch information
lakridserne authored Feb 26, 2023
2 parents 019a2a9 + c8ece06 commit 40e72a7
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.core.management.base import BaseCommand
from members.models.activityparticipant import ActivityParticipant


class Command(BaseCommand):
help = "Populates the person field on the activity participants table, so we can remove member in the future"

def handle(self, *args, **options):
for actpar in ActivityParticipant.objects.all():
actpar.person = actpar.member.person
actpar.save()
24 changes: 24 additions & 0 deletions members/migrations/0037_activityparticipant_person.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.1.6 on 2023-02-26 13:37

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


class Migration(migrations.Migration):

dependencies = [
("members", "0036_rename_founded_union_founded_at_union_closed_at"),
]

operations = [
migrations.AddField(
model_name="activityparticipant",
name="person",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="members.person",
verbose_name="Person",
),
),
]
13 changes: 13 additions & 0 deletions members/migrations/0038_merge_20230226_1633.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by Django 4.1.6 on 2023-02-26 15:33

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("members", "0037_activityparticipant_person"),
("members", "0037_alter_waitinglist_options"),
]

operations = []
3 changes: 3 additions & 0 deletions members/models/activityparticipant.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class Meta:
member = models.ForeignKey(
"Member", on_delete=models.CASCADE, verbose_name="Medlem"
)
person = models.ForeignKey(
"Person", on_delete=models.CASCADE, verbose_name="Person", null=True
)
note = models.TextField("Besked / Note til arrangement", blank=True)
PHOTO_OK = "OK"
PHOTO_NOTOK = "NO"
Expand Down
14 changes: 7 additions & 7 deletions members/views/ActivitySignup.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ def ActivitySignup(request, activity_id, person_id=None):

if not (activity.min_age <= person.age_years() <= activity.max_age):
return HttpResponse(
"Barnet skal være mellem "
+ str(activity.min_age)
+ " og "
+ str(activity.max_age)
+ " år gammel for at deltage. (Er fødselsdatoen udfyldt korrekt ?)"
f"Barnet skal være mellem {activity.min_age} og {activity.max_age} år gammel for at deltage. (Er fødselsdatoen udfyldt korrekt ?)"
)

if (
Expand Down Expand Up @@ -157,8 +153,12 @@ def ActivitySignup(request, activity_id, person_id=None):
member.save()

# Make ActivityParticipant
# Note: The members field is now deprecated and is expected to be removed in a future release
participant = ActivityParticipant(
member=member, activity=activity, note=signup_form.cleaned_data["note"]
member=member,
person=person,
activity=activity,
note=signup_form.cleaned_data["note"],
)

# If conditions not accepted, make error
Expand All @@ -178,7 +178,7 @@ def ActivitySignup(request, activity_id, person_id=None):
)

# Make payment if activity costs
if activity.price_in_dkk is not None and activity.price_in_dkk != 0:
if activity.price_in_dkk is not None and activity.price_in_dkk > 0:
# using creditcard ?
if signup_form.cleaned_data["payment_option"] == Payment.CREDITCARD:
payment = Payment(
Expand Down

0 comments on commit 40e72a7

Please sign in to comment.