Repository: Cloud-CV/EvalAI

Issue:
Add fields in ChallengePhaseSerializer
Please add fields `max_submissions_per_day` and `max_submissions` in the `Challenge Phase Serializer`. It is needed for the issue #704 .


Discussion:
@RishabhJain2018 do you want to work on this issue? 
@deshraj yeah sure.

Resolving patch:
diff --git a/apps/challenges/serializers.py b/apps/challenges/serializers.py
--- a/apps/challenges/serializers.py
+++ b/apps/challenges/serializers.py
@@ -44,7 +44,8 @@ def __init__(self, *args, **kwargs):
     class Meta:
         model = ChallengePhase
         fields = ('id', 'name', 'description', 'leaderboard_public', 'start_date',
-                  'end_date', 'challenge', 'is_public', 'is_active', 'codename')
+                  'end_date', 'challenge', 'max_submissions_per_day', 'max_submissions',
+                  'is_public', 'is_active', 'codename')
 
 
 class DatasetSplitSerializer(serializers.ModelSerializer):


Test patch:
diff --git a/tests/unit/challenges/test_models.py b/tests/unit/challenges/test_models.py
--- a/tests/unit/challenges/test_models.py
+++ b/tests/unit/challenges/test_models.py
@@ -115,7 +115,9 @@ def setUp(self):
                 end_date=timezone.now() + timedelta(days=1),
                 challenge=self.challenge,
                 test_annotation=SimpleUploadedFile('test_sample_file.txt',
-                                                   'Dummy file content', content_type='text/plain')
+                                                   'Dummy file content', content_type='text/plain'),
+                max_submissions_per_day=100000,
+                max_submissions=100000,
             )
 
     def tearDown(self):
diff --git a/tests/unit/challenges/test_views.py b/tests/unit/challenges/test_views.py
--- a/tests/unit/challenges/test_views.py
+++ b/tests/unit/challenges/test_views.py
@@ -908,7 +908,9 @@ def setUp(self):
                 end_date=timezone.now() + timedelta(days=1),
                 challenge=self.challenge,
                 test_annotation=SimpleUploadedFile('test_sample_file.txt',
-                                                   'Dummy file content', content_type='text/plain')
+                                                   'Dummy file content', content_type='text/plain'),
+                max_submissions_per_day=100000,
+                max_submissions=100000,
             )
 
     def tearDown(self):
@@ -935,6 +937,8 @@ def test_get_challenge_phase(self):
                 "is_public": self.challenge_phase.is_public,
                 "is_active": True,
                 "codename": "Phase Code Name",
+                "max_submissions_per_day": self.challenge_phase.max_submissions_per_day,
+                "max_submissions": self.challenge_phase.max_submissions,
             }
         ]
 
@@ -1014,6 +1018,8 @@ def test_get_particular_challenge_phase(self):
             "is_public": self.challenge_phase.is_public,
             "is_active": True,
             "codename": "Phase Code Name",
+            "max_submissions_per_day": self.challenge_phase.max_submissions_per_day,
+            "max_submissions": self.challenge_phase.max_submissions,
         }
         response = self.client.get(self.url, {})
         self.assertEqual(response.data, expected)
@@ -1073,6 +1079,8 @@ def test_particular_challenge_phase_partial_update(self):
             "is_public": self.challenge_phase.is_public,
             "is_active": True,
             "codename": "Phase Code Name",
+            "max_submissions_per_day": self.challenge_phase.max_submissions_per_day,
+            "max_submissions": self.challenge_phase.max_submissions,
         }
         response = self.client.patch(self.url, self.partial_update_data)
         self.assertEqual(response.data, expected)