-
-
Notifications
You must be signed in to change notification settings - Fork 983
fix: clear submission type marker after submission #5147
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
base: master
Are you sure you want to change the base?
Changes from all commits
5cf34fe
a815981
38e99c1
6255971
4ad415e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,19 @@ class ChallengeSerializer(serializers.ModelSerializer): | |
| def get_domain_name(self, obj): | ||
| return obj.get_domain_display() | ||
|
|
||
| def validate(self, attrs): | ||
| start_date = attrs.get( | ||
| "start_date", getattr(self.instance, "start_date", None) | ||
| ) | ||
| end_date = attrs.get( | ||
| "end_date", getattr(self.instance, "end_date", None) | ||
| ) | ||
| if start_date and end_date and start_date >= end_date: | ||
| raise serializers.ValidationError( | ||
| "Challenge start date must be before end date." | ||
| ) | ||
| return attrs | ||
|
|
||
| def validate_worker_python_version(self, value): | ||
| if value in (None, ""): | ||
| return DEFAULT_WORKER_PYTHON_VERSION | ||
|
|
@@ -147,6 +160,45 @@ class ChallengePhaseSerializer(serializers.ModelSerializer): | |
|
|
||
| is_active = serializers.ReadOnlyField() | ||
|
|
||
| def validate(self, attrs): | ||
| start_date = attrs.get( | ||
| "start_date", getattr(self.instance, "start_date", None) | ||
| ) | ||
| end_date = attrs.get( | ||
| "end_date", getattr(self.instance, "end_date", None) | ||
| ) | ||
| challenge = attrs.get( | ||
| "challenge", getattr(self.instance, "challenge", None) | ||
| ) | ||
| if challenge: | ||
| csd = challenge.start_date | ||
| ced = challenge.end_date | ||
| if start_date and csd and start_date < csd: | ||
| raise serializers.ValidationError( | ||
| "Phase start date must be on or after " | ||
| "challenge start date." | ||
| ) | ||
| if start_date and ced and start_date >= ced: | ||
| raise serializers.ValidationError( | ||
| "Phase start date must be before " | ||
| "challenge end date." | ||
| ) | ||
| if end_date and csd and end_date <= csd: | ||
| raise serializers.ValidationError( | ||
| "Phase end date must be after " | ||
| "challenge start date." | ||
| ) | ||
| if end_date and ced and end_date > ced: | ||
| raise serializers.ValidationError( | ||
| "Phase end date must be on or before " | ||
| "challenge end date." | ||
| ) | ||
| if start_date and end_date and start_date >= end_date: | ||
| raise serializers.ValidationError( | ||
| "Phase start date must be before end date." | ||
| ) | ||
| return attrs | ||
|
|
||
|
Comment on lines
+163
to
+201
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift
Both methods implement the exact same four challenge-boundary checks plus the self Also applies to: 496-534 🤖 Prompt for AI Agents |
||
| def __init__(self, *args, **kwargs): | ||
| super(ChallengePhaseSerializer, self).__init__(*args, **kwargs) | ||
| context = kwargs.get("context") | ||
|
|
@@ -441,6 +493,45 @@ class ChallengePhaseCreateSerializer(serializers.ModelSerializer): | |
|
|
||
| is_active = serializers.ReadOnlyField() | ||
|
|
||
| def validate(self, attrs): | ||
| start_date = attrs.get( | ||
| "start_date", getattr(self.instance, "start_date", None) | ||
| ) | ||
| end_date = attrs.get( | ||
| "end_date", getattr(self.instance, "end_date", None) | ||
| ) | ||
| challenge = attrs.get( | ||
| "challenge", getattr(self.instance, "challenge", None) | ||
| ) | ||
| if challenge: | ||
| csd = challenge.start_date | ||
| ced = challenge.end_date | ||
| if start_date and csd and start_date < csd: | ||
| raise serializers.ValidationError( | ||
| "Phase start date must be on or after " | ||
| "challenge start date." | ||
| ) | ||
| if start_date and ced and start_date >= ced: | ||
| raise serializers.ValidationError( | ||
| "Phase start date must be before " | ||
| "challenge end date." | ||
| ) | ||
| if end_date and csd and end_date <= csd: | ||
| raise serializers.ValidationError( | ||
| "Phase end date must be after " | ||
| "challenge start date." | ||
| ) | ||
| if end_date and ced and end_date > ced: | ||
| raise serializers.ValidationError( | ||
| "Phase end date must be on or before " | ||
| "challenge end date." | ||
| ) | ||
| if start_date and end_date and start_date >= end_date: | ||
| raise serializers.ValidationError( | ||
| "Phase start date must be before end date." | ||
| ) | ||
| return attrs | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| super(ChallengePhaseCreateSerializer, self).__init__(*args, **kwargs) | ||
| context = kwargs.get("context") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: Cloud-CV/EvalAI
Length of output: 13692
🏁 Script executed:
Repository: Cloud-CV/EvalAI
Length of output: 13913
🏁 Script executed:
Repository: Cloud-CV/EvalAI
Length of output: 13203
Move challenge date validation out of
save()Challenge.save()andChallengePhase.save()raisedjango.core.exceptions.ValidationErrordirectly, so callers that bypass serializer validation can surface an unhandled 500. The same date checks are already duplicated inChallengeSerializer,ChallengePhaseSerializer, andChallengePhaseCreateSerializer, so this logic is split across five places and will drift.🤖 Prompt for AI Agents