Skip to content

Feature/team submission quota - #2701

Merged
Didayolo merged 5 commits into
developfrom
feature/team-submission-quota
Nov 5, 2026
Merged

Didayolo merged 5 commits into
developfrom
feature/team-submission-quota

Conversation

@ObadaS

@ObadaS ObadaS commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Original PR : #2683

Description

Adds an opt-in, per-phase team (organization) submission quota, requested by the organizers of EEG/EMG Challenge 2026. Today max_submissions / max_submissions_per_day apply per user, so a team of N members gets N× the sealed submissions.

New field Phase.max_submissions_scope:

  • participant (default): current behavior. Migration 0066 adds the field with this default, so existing competitions are unchanged.
  • organization: both limits are shared by all current members of each of the user's organizations.

Team usage. Every submission in the phase whose owner is a current member of the organization (Membership.ALL_GROUP, so pending invites don't count). This includes tagged and untagged submissions, so a member can't get around the team cap by submitting as themselves. The exclusion filters are the same as today: parent submissions only, no organizer re-submissions, no Failed.

Enforcement. A user is blocked when any of their teams has reached either limit. The message names the team: Team "<name>" has reached the maximum allowed submissions [for today] for this phase. The logic lives in Phase.can_user_make_submissions, so all three existing call sites pick it up unchanged: SubmissionCreationSerializer.validate, the can_make_submission endpoint and Submission.save(). Users without a team keep individual limits and the existing messages. The daily cap is the same UTC calendar day as the individual limit.

Edge cases (documented in Yaml-Structure.md):

  • Membership is evaluated at submit time. A member who joins brings their earlier submissions in the phase, and a member who leaves takes theirs away.
  • A user in several organizations counts toward each of them and is blocked as soon as any one is full.

Exposed in: both phase serializers, the v1/v2 YAML unpackers (optional key, default participant; invalid values fail serializer validation), the competition YAML export (PHASE_FIELDS), the phase editor (Advanced → "Max Submissions Scope") and the docs:

phases:
  - name: Final Phase
    max_submissions: 5
    max_submissions_scope: organization  # the 5 submissions are shared by each team

Badges. In organization-scoped phases, the submission-limit badges show team usage. For a user in several teams, they show the team closest to its limit.

Notes for reviewers

  • The editor field is a native <select>, to keep the diff minimal. I'm happy to switch it to a Semantic UI dropdown like the rest of the editor.
  • This PR comes from a fork, so if CircleCI doesn't trigger, feel free to mirror the branch into the main repo.
  • Known follow-up: the badge has no "team" label yet. A label would also need to handle users without a team.

Pre-existing inconsistencies noticed (not changed here)

  1. The participant-scope badge counters don't exclude resubmitted_from, but enforcement does, so the badge over-reports after an organizer re-submission.
  2. The badge counters duplicate the model's counting logic instead of reusing it.
  3. Submission.re_run() copies skip the limit check when created, but then count toward the owner's quota afterwards. Re-Submit copies are excluded instead.
  4. unpacker_test_data.py uses the key max_submissions_per_person, but the unpackers read max_submissions. The tests only pass because both defaults are 100.

Issues this PR resolves

No existing issue. Requested by the organizers of EEG/EMG Challenge 2026.

A checklist for hand testing

  • Phase editor → Advanced: "Max Submissions Scope" defaults to "Per participant". Phases imported from a bundle without the key are participant too.
  • Set a phase to "Per organization (team)" with max per person = 2, save, reopen: the value persists. GET /api/phases/<id>/ returns "max_submissions_scope": "organization".
  • Organization-scoped phase with a cap of 2, and a PARTICIPANT and a MEMBER of one org: one tagged and one untagged submission. Both badges show "2 out of 2", and a 3rd attempt is rejected with the team message.
  • Max per day = 1: after one team submission today, the other member gets the "for today" message.
  • A user who is only invited to the org is limited individually and doesn't use the team's quota.
  • A user in two orgs is blocked when either is full, and the message names that org.
  • Bundle with max_submissions_scope: organization imports correctly. An invalid value (e.g. team) fails the upload.
  • Export (Dump) includes max_submissions_scope in competition.yaml.

The unticked items are covered by unit tests except export.

Tests run on the docker compose stack with .env_circleci, as in CircleCI:

  • py.test src/: 455 passed, 2 skipped, 0 failed, including the 9 new tests
  • flake8 src/: clean
  • makemigrations --check --dry-run: no changes

New tests: competitions/tests/test_submissions.py::TeamMaxSubmissionsTests (shared total across tagged and untagged submissions, daily cap, default scope unchanged, no-team fallback, user in two teams, invited users, badge counts) and test_phase_max_submissions_scope_unpacking in test_v2_unpacker.py / test_v15_unpacker.py.

Checklist

  • Code review by me
  • Hand tested by me
  • I'm proud of my work
  • Code review by reviewer
  • Hand tested by reviewer
  • CircleCi tests are passing
  • Ready to merge

@ObadaS
ObadaS marked this pull request as ready for review November 3, 2026 10:06
@ObadaS
ObadaS requested a review from IdirLISN November 3, 2026 12:55
@ObadaS
ObadaS force-pushed the feature/team-submission-quota branch from 3b0a0f4 to cd1bed9 Compare November 3, 2026 12:58
@ObadaS

ObadaS commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

@IdirLISN
This seems to be working well, however there is a small problem that I can not fix.

Can you add a banner or something that informs participants that the quota is shared between team members ? Right now, it's not really clear and can add confusion for participants

@ObadaS
ObadaS force-pushed the feature/team-submission-quota branch from cd1bed9 to 4284765 Compare November 4, 2026 08:02
@Didayolo

Didayolo commented Nov 4, 2026

Copy link
Copy Markdown
Member

Not sure about this approach.

My opinion:

  • This should not be a phase setting, but a general competition setting ("Per participant" vs "Per team")
  • In "Per team" mode, only submissions "as organization" should be allowed. The current PR does not disallow to submit as a participant so the quota limitation is easy to avoid.
  • Indeed @ObadaS, there should be a visual element indicating if it's per participant or per team.

@ObadaS

ObadaS commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Not sure about this approach.

My opinion:

* This should not be a phase setting, but a general competition setting ("Per participant" vs "Per team")

* In "Per team" mode, only submissions "as organization" should be allowed. The current PR does not disallow to submit as a participant so the quota limitation is easy to avoid.

* Indeed @ObadaS, there should be a visual element indicating if it's per participant or per team.

1 - I disagree, having it be per phase can be interesting. You can have a phase that does not allow teams (therefor it's only individual quota) and a phase where teams are allowed. Especially now since we have parallel phases. Because of point 2, that would be impossible to do if the option was per competition instead of per phase

2 - I actually tried that, if you submit as a team OR individually, it will count for the quota of the whole team (which is why having an indicator that the option is active and that you are in a team is important)

@Didayolo

Didayolo commented Nov 5, 2026

Copy link
Copy Markdown
Member

2 - I actually tried that, if you submit as a team OR individually, it will count for the quota of the whole team (which is why having an indicator that the option is active and that you are in a team is important)

But is being part of an organization forced? Why join a team if it just reduce your quota?

@IdirLISN
IdirLISN force-pushed the feature/team-submission-quota branch from 4284765 to 64f9cb2 Compare November 5, 2026 09:10
@IdirLISN
IdirLISN force-pushed the feature/team-submission-quota branch from 8b0593b to b254213 Compare November 5, 2026 09:43
@Didayolo
Didayolo merged commit 24c3307 into develop Nov 5, 2026
3 checks passed
@Didayolo
Didayolo deleted the feature/team-submission-quota branch November 5, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants