Skip to content

Commit

Permalink
Base price for non members added (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
robindymer authored Aug 23, 2023
1 parent bcb8533 commit a752200
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/branding/migrations/0006_alter_footersettings_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.17 on 2023-08-23 12:55

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('branding', '0005_fix_empty_footer'),
]

operations = [
migrations.AlterModelOptions(
name='footersettings',
options={'verbose_name': 'footer_en'},
),
]
18 changes: 18 additions & 0 deletions src/events/migrations/0008_event_base_price_nonmember.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.17 on 2023-08-23 12:55

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('events', '0007_ticket_total_payment'),
]

operations = [
migrations.AddField(
model_name='event',
name='base_price_nonmember',
field=models.IntegerField(default=0, help_text='Base ticket price for non-members.', verbose_name='Ticket price for non-members'),
),
]
11 changes: 10 additions & 1 deletion src/events/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class Event(models.Model):
default=0
)

base_price_nonmember = models.IntegerField(
help_text=_('Base ticket price for non-members.'),
verbose_name=_('Ticket price for non-members'),
default=0
)

price_per_participant = models.IntegerField(
help_text=_(
'Price per participant, independent of their order. '
Expand Down Expand Up @@ -167,7 +173,10 @@ def __str__(self) -> str:
FieldPanel('num_participants_per_ticket'),
]),
FieldPanel('first_come_first_serve'),
FieldPanel('base_price'),
FieldRowPanel([
FieldPanel('base_price'),
FieldPanel('base_price_nonmember'),
]),
FieldRowPanel([
FieldPanel('price_per_participant'),
FieldPanel('price_per_participant_nonmember'),
Expand Down
6 changes: 5 additions & 1 deletion src/events/views/ticket_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from events.models import Event, Ticket, Participant
from events.forms import ParticipantForm
from django.contrib.auth.decorators import login_required
from utils.melos_client import MelosClient


@login_required
Expand Down Expand Up @@ -75,7 +76,10 @@ def my_ticket(request, event_pk):

# Set this as the first user has to be the owner.
formset[0].fields['person_nr'].disabled = True
cost = event.base_price + \
owner_is_member = MelosClient.is_member(ticket.owner.person_nr)
base_price = event.base_price if owner_is_member \
else event.base_price_nonmember
cost = base_price + \
sum([participant.calculate_order_cost()
for participant in queryset])
context['ticket'] = ticket
Expand Down

0 comments on commit a752200

Please sign in to comment.