Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
schedule:
# Every 13th and 28th of the month at 07:42
- cron: '42 7 13,28 * *'
- cron: '42 7 13,28 * *'

jobs:
tests:
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Run Tests
env:
DJANGO_VERSION: ${{ matrix.django-version }}
run: "./dev_server.sh -d test"
run: './dev_server.sh -d test'

all-tests:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions dds_registration/fixtures/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
To install test data (for local testting), use:

```
python manage.py loaddata site-local test-users test-event test-options
python manage.py loaddata site-local test-users
```

To add test registration object:
To add test registration and payment objects:

```
python manage.py loaddata test-registration
python manage.py loaddata test-payment-1-created test-registration-1-submited
```

Admin and the first user creating with `test` password.
Expand Down
12 changes: 6 additions & 6 deletions dds_registration/fixtures/test-event.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# @changed 2024.03.28, 15:18
# @changed 2024.04.06, 19:55

- model: dds_registration.event
pk: 1
fields:
id: 1
code: 'first'
title: 'The first event'
description: 'First event description'
description: 'The first event description'
success_email: 'dmia@yandex.ru'
public: 1
registration_open: '2024-03-25'
registration_close: '2024-04-20'
registration_open: '2024-04-06'
registration_close: '2024-04-25'
max_participants: 5
payment_deadline_days: 30
payment_details: ''
refund_last_day: '2024-04-30'
6 changes: 3 additions & 3 deletions dds_registration/fixtures/test-options.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# @changed 2024.03.28, 15:18
# @changed 2024.04.06, 19:59

- model: dds_registration.registrationoption
pk: 1
fields:
id: 1
item: 'Registration'
price: 100
currency: 'USD'
currency: 'CHF'
event_id: 1

- model: dds_registration.registrationoption
pk: 2
fields:
id: 2
item: 'T-Shirt'
price: 10
price: 19
currency: 'USD'
event_id: 1
10 changes: 10 additions & 0 deletions dds_registration/fixtures/test-payment-1-created.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# @changed 2024.04.06, 20:05

- model: dds_registration.payment
pk: 1
fields:
id: 1
created: '2024-04-06'
updated: '2024-04-06'
status: 'CREATED'
data: '{"user": {"id": 2, "name": "John Lennon", "address": "251 Menlove Avenue, Liverpool, Merseyside L25 7SA, UK"}, "extra": "", "kind": "event", "method": "STRIPE", "event": {"id": 1, "title": "The first event"}, "registration": {"id": 1}, "option": {"id": 1, "item": "Registration"}, "price": 100.0, "currency": "CHF"}'
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# @changed 2024.03.28, 21:07
# @changed 2024.04.06, 20:01

- model: dds_registration.registration
pk: 1
fields:
id: 1
status: 'SUBMITTED'
created_at: '2024-03-28 20:00:00.000000'
updated_at: '2024-03-28 20:00:00.000000'
created_at: '2024-04-06 19:59:46.154852'
updated_at: '2024-04-06 19:59:46.167242'
event_id: 1
invoice_id: null
payment_id: 1
user_id: 2
option_id: 1
18 changes: 18 additions & 0 deletions dds_registration/migrations/0003_payment_method.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.3 on 2024-04-06 20:25

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dds_registration', '0002_remove_event_refund_window_days_and_more'),
]

operations = [
migrations.AddField(
model_name='payment',
name='method',
field=models.TextField(choices=[('STRIPE', 'Credit Card (Stripe - costs 2-4% more due to credit card fees)'), ('INVOICE', 'Bank Transfer (Invoice)')], default='INVOICE'),
),
]
7 changes: 4 additions & 3 deletions dds_registration/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ class Payment(Model):
]
DEFAULT_METHOD = "INVOICE"

method = models.TextField(choices=METHODS, default=DEFAULT_METHOD)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with this (hiding data in hard-to-access entities isn't a good coding approach), but ok: going to create helpers to extract them from there.


# # User name and address, initialized by user's ones, by default
# name = models.TextField(blank=False, default="")
# address = models.TextField(blank=False, default="")
Expand Down Expand Up @@ -344,13 +346,12 @@ class Event(Model):
code = models.TextField(unique=True, default=random_code) # Show as an input
title = models.TextField(unique=True, null=False, blank=False) # Show as an input
description = models.TextField(blank=False, null=False)
# `success_email`: Can't see a description for this field. Can't see its usage anywhere in the app. Why is it required? Which email(s) should be here?
success_email = models.TextField(blank=False, null=False)
public = models.BooleanField(default=True)
registration_open = models.DateField(auto_now_add=True, help_text="Date registration opens (inclusive)")
registration_close = models.DateField(help_text="Date registration closes (inclusive)")
refund_last_day = models.DateField(
null=True, help_text="Last day that a fee refund can be offered"
)
refund_last_day = models.DateField(null=True, help_text="Last day that a fee refund can be offered")
max_participants = models.PositiveIntegerField(
default=0,
help_text="Maximum number of participants (0 = no limit)",
Expand Down
1 change: 1 addition & 0 deletions dds_registration/views/event_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def event_registration(request: HttpRequest, event_code: str):
payment_method = request.POST["payment_method"]
payment = Payment(
status="CREATED",
method=payment_method,
data={
"user": {
"id": request.user.id,
Expand Down
3 changes: 2 additions & 1 deletion dds_registration/views/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def membership_application(request: HttpRequest):
form = MembershipForm(request.POST)

if form.is_valid():
payment_method = form.cleaned_data["payment_method"]
payment = Payment(
status="CREATED",
data={
Expand All @@ -41,7 +42,7 @@ def membership_application(request: HttpRequest):
"membership": {
"type": form.cleaned_data["membership_type"],
},
"method": form.cleaned_data["payment_method"],
"method": payment_method,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the idea behind this change? You create a variable to only use it once. I suggest reverting this change.

"price": MEMBERSHIP_DATA[form.cleaned_data["membership_type"]]["price"],
"currency": MEMBERSHIP_DATA[form.cleaned_data["membership_type"]]["currency"],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,3 @@
</div>
{% endfor %}
</fieldset>


2 changes: 1 addition & 1 deletion src/assets/events-list-table/events-list-table.django
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</td>
<td class="col-payment">
{% if payment %}
{{ payment.get_payment_method_display }}
{{ payment.get_method_display }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add a method to Payment if this needs to be displayed differently that it is stored. I want to keep all the info in data.

{% endif %}
</td>
<td class="col-paid">
Expand Down