Skip to content

Commit

Permalink
feat: check the fsm participant limit (on entering fsm)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmooHashem committed Nov 21, 2024
1 parent fe72b14 commit 3c1b7d7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/fsm/views/fsm_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ def get_serializer_context(self):
def enter_fsm(self, request, pk=None):
fsm = self.get_object()
user = request.user
is_mentor = user in fsm.mentors.all()

# Check if the fsm has a participant limit
if fsm.participant_limit > 0 and not is_mentor:
if user.is_anonymous:
raise PermissionDenied(
"You must be logged in to submit this form.")
else:
count = get_players(user, fsm).count()
if count >= fsm.participant_limit:
raise PermissionDenied(
"You have exceeded the submission limit for this form.")

if fsm.is_public:
if isinstance(user, AnonymousUser):
Expand Down

0 comments on commit 3c1b7d7

Please sign in to comment.