Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(registration)/filter participants #915

Merged
merged 21 commits into from
Oct 28, 2024
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b4aa592
filtering by year and study
yazanzarka1 Oct 1, 2024
5e4e30a
Merge branch 'dev' of https://github.com/TIHLDE/Lepton into feat(regi…
yazanzarka1 Oct 3, 2024
cf50316
linting fix
yazanzarka1 Oct 3, 2024
7bb2df6
added allergy filter
yazanzarka1 Oct 7, 2024
1ed7770
Merge branch 'feat(registration)/filter-participants' of https://gith…
yazanzarka1 Oct 7, 2024
149e29d
added filter by allergies and participants with allergy count to event.
yazanzarka1 Oct 7, 2024
858da7c
Lint fix
yazanzarka1 Oct 7, 2024
29633ff
Add new fixture for admin user
haruixu Oct 15, 2024
d6eb455
Start testing filtering + finished allergy filter test
haruixu Oct 15, 2024
3b4eae4
Merge branch 'dev' into feat(registration)/filter-participants
MadsNyl Oct 15, 2024
29e705f
Added integration test for participants filtering
yazanzarka1 Oct 16, 2024
d7c3bc3
lint fix
yazanzarka1 Oct 16, 2024
af6a1d2
removed unused import
yazanzarka1 Oct 16, 2024
ca23b2d
Update changelog
haruixu Oct 21, 2024
7f5aa58
merge with dev and more filters
yazanzarka1 Oct 25, 2024
f6ec0da
Merge branch 'feat(registration)/filter-participants' of https://gith…
yazanzarka1 Oct 25, 2024
c2af1a2
Fixed has_paid filter and added filter combination test
yazanzarka1 Oct 27, 2024
f4d5b60
ran linting script
yazanzarka1 Oct 27, 2024
be5c3b6
fixed has allergy count bug, and has_paid bug
yazanzarka1 Oct 28, 2024
4451900
post linting
yazanzarka1 Oct 28, 2024
63b1f2e
Merge branch 'dev' into feat(registration)/filter-participants
yazanzarka1 Oct 28, 2024
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
12 changes: 7 additions & 5 deletions app/content/serializers/event.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.db.models import Q
from rest_framework import serializers

from dry_rest_permissions.generics import DRYPermissionsField
Expand Down Expand Up @@ -265,7 +266,7 @@ class EventStatisticsSerializer(BaseModelSerializer):
studyyears = serializers.SerializerMethodField()
studies = serializers.SerializerMethodField()
has_allergy_count = serializers.SerializerMethodField()
has_paid_count = serializers.SerializerMethodField()
has_not_paid_count = serializers.SerializerMethodField()
allow_photo_count = serializers.SerializerMethodField()

class Meta:
Expand All @@ -277,7 +278,7 @@ class Meta:
"studyyears",
"studies",
"has_allergy_count",
"has_paid_count",
"has_not_paid_count",
"allow_photo_count",
)

Expand All @@ -287,6 +288,7 @@ def get_has_attended_count(self, obj, *args, **kwargs):
def get_has_allergy_count(self, obj, *args, **kwargs):
return (
obj.registrations.exclude(user__allergy__isnull=True)
.filter(is_on_wait=False)
.exclude(user__allergy__exact="")
.count()
)
Expand Down Expand Up @@ -320,10 +322,10 @@ def get_studies(self, obj, *args, **kwargs):
)

def get_allow_photo_count(self, obj, *args, **kwargs):
return obj.registrations.filter(allow_photo=False).count()
return obj.registrations.filter(allow_photo=False, is_on_wait=False).count()

def get_has_paid_count(self, obj, *args, **kwargs):
def get_has_not_paid_count(self, obj, *args, **kwargs):
if obj.is_paid_event:
orders = obj.orders.filter(status=OrderStatus.SALE, event=obj).count()
orders = obj.orders.filter(~Q(status=OrderStatus.SALE), event=obj).count()
return orders
return 0
Loading