-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store event user actions to gain insights form it in the future (#3136)
- Loading branch information
1 parent
638ec65
commit 2e89e1e
Showing
4 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Generated by Django 3.2.23 on 2024-02-21 11:24 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("events", "0002_auto_20230215_2107"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="EventUserAction", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("timestamp", models.DateTimeField(auto_now_add=True)), | ||
( | ||
"type", | ||
models.CharField( | ||
choices=[ | ||
("register", "register"), | ||
("unregister", "unregister"), | ||
], | ||
max_length=15, | ||
), | ||
), | ||
( | ||
"event", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, to="events.event" | ||
), | ||
), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.db.models.signals import pre_delete, pre_save | ||
from django.dispatch import receiver | ||
|
||
from .models import Attendee, EventUserAction | ||
|
||
|
||
@receiver(signal=pre_save, sender=Attendee) | ||
def handle_payment_relation_status_change(sender, instance: Attendee, **kwargs): | ||
EventUserAction.objects.create( | ||
user=instance.user, event=instance.event.event, type="register" | ||
) | ||
|
||
|
||
@receiver(signal=pre_delete, sender=Attendee) | ||
def handle_payment_transaction_status_change(sender, instance: Attendee, **kwargs): | ||
EventUserAction.objects.create( | ||
user=instance.user, event=instance.event.event, type="unregister" | ||
) |