-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from Nettverksdagen/fix/participant_count
Fix/participant count
- Loading branch information
Showing
3 changed files
with
6 additions
and
9 deletions.
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 |
---|---|---|
|
@@ -47,14 +47,11 @@ def create(self, request): | |
program = Program.objects.get(id=data['event']) | ||
|
||
if (notRegistered): | ||
response = super().create(request) | ||
|
||
registered = program.participant_set.all().count() | ||
|
||
currentlyRegistered = program.participant_set.all().count() | ||
try: | ||
# If program is full, send waiting list email | ||
if (registered > program.maxRegistered): | ||
waitingListIndex = registered - program.maxRegistered | ||
if (currentlyRegistered >= program.maxRegistered): | ||
waitingListIndex = currentlyRegistered - program.maxRegistered + 1 | ||
send_mail('Nettverksdagene - Du står på venteliste', | ||
'Vi bekrefter herved at du står på venteliste til ' + program.header + '. Din plass på ventelisten er ' + str(waitingListIndex) + '. Dersom du skulle ønske å melde deg av, vennligst gjør det via nettverksdagene.no/program. Tusen takk for din interesse i Nettverksdagene!', | ||
'[email protected]', | ||
|
@@ -72,7 +69,7 @@ def create(self, request): | |
response = {'message': 'Could not send email'} | ||
return Response(response, status = status.HTTP_500_INTERNAL_SERVER_ERROR) | ||
|
||
return response | ||
return super().create(request) | ||
|
||
else: | ||
response = {'message': 'Invalid input. Is participant already registered?'} | ||
|
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