Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions app/api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def get_event_options(request: Request, id: str, token: AccessTokenPayload = Dep
# Get user data and return
userData = user_event['participants'][0]
return {'food': userData['food'], 'transportation': userData['transportation'],
'dietaryRestrictions': userData['dietaryRestrictions']}
'dietaryRestrictions': userData['dietaryRestrictions'], 'gdprConsent': userData.get('gdprConsent')}


@router.put('/{id}/update-options', dependencies=[Depends(validate_uuid)])
Expand Down Expand Up @@ -389,6 +389,7 @@ def join_event(request: Request, id: str, payload: JoinEventPayload, token: Acce
'food': payload.food,
'transportation': payload.transportation,
'dietaryRestrictions': payload.dietaryRestrictions,
'gdprConsent': payload.gdprConsent,
'submitDate': datetime.now(),
'confirmed': False,
'attended': False
Expand Down Expand Up @@ -938,7 +939,8 @@ async def exportEvent(background_tasks: BackgroundTasks, request: Request, id: s
event_data = [{'Total participants': len(event['participants']),
'Total to eat': len([p for p in event['participants'] if p['food'] == True]),
'Total to transportation': len(
[p for p in event['participants'] if p['transportation'] == True])}]
[p for p in event['participants'] if p['transportation'] == True]),
'Total GDPR consent': len([p for p in event['participants'] if p.get('gdprConsent') == True])}]

# Create dataframe
df_title = pd.DataFrame(event_header)
Expand Down
2 changes: 2 additions & 0 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class Participant(BaseModel):
food: bool
transportation: bool
dietaryRestrictions: str
gdprConsent: Optional[bool] = None
submitDate: datetime
penalty: int
# indicate if participant has recieved an confirmation mail
Expand Down Expand Up @@ -242,6 +243,7 @@ class JoinEventPayload(BaseModel):
food: Optional[bool] = None
transportation: Optional[bool] = None
dietaryRestrictions: Optional[str] = None
gdprConsent: Optional[bool] = None


class PenaltyInput(BaseModel):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_endpoints/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
joinEventPayload = {
"transportation": False,
"food": True,
"dietaryRestrictions": "Eggs"
"dietaryRestrictions": "Eggs",
"gdprConsent": True
}


Expand Down
2 changes: 2 additions & 0 deletions utils/seeding.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ def seed_events(db, seed_path):
member['transportation'] = random.choice(bool_list)
member['dietaryRestrictions'] = random.choices(
dietaryRestriction_list, weights=[0.9, 0.05, 0.03, 0.02])[0]
member['gdprConsent'] = random.choices(
bool_list, weights=[0.95, 0.05])[0]

member['submitDate'] = datetime.now(
) + timedelta(hours=random.choices(
Expand Down