prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Add serializers for creating challenge using zip file.
  
  
  </issue>
  <code>
  [start of apps/challenges/serializers.py]
  1 from rest_framework import serializers
  2 
  3 from hosts.serializers import ChallengeHostTeamSerializer
  4 
  5 from .models import (
  6                      Challenge,
  7                      ChallengePhase,
  8                      ChallengePhaseSplit,
  9                      DatasetSplit,)
  10 
  11 
  12 class ChallengeSerializer(serializers.ModelSerializer):
  13 
  14     is_active = serializers.ReadOnlyField()
  15 
  16     def __init__(self, *args, **kwargs):
  17         super(ChallengeSerializer, self).__init__(*args, **kwargs)
  18         context = kwargs.get('context')
  19         if context and context.get('request').method != 'GET':
  20             challenge_host_team = context.get('challenge_host_team')
  21             kwargs['data']['creator'] = challenge_host_team.pk
  22         else:
  23             self.fields['creator'] = ChallengeHostTeamSerializer()
  24 
  25     class Meta:
  26         model = Challenge
  27         fields = ('id', 'title', 'short_description', 'description', 'terms_and_conditions',
  28                   'submission_guidelines', 'evaluation_details',
  29                   'image', 'start_date', 'end_date', 'creator',
  30                   'published', 'enable_forum', 'anonymous_leaderboard', 'is_active',)
  31 
  32 
  33 class ChallengePhaseSerializer(serializers.ModelSerializer):
  34 
  35     is_active = serializers.ReadOnlyField()
  36 
  37     def __init__(self, *args, **kwargs):
  38         super(ChallengePhaseSerializer, self).__init__(*args, **kwargs)
  39         context = kwargs.get('context')
  40         if context:
  41             challenge = context.get('challenge')
  42             kwargs['data']['challenge'] = challenge.pk
  43 
  44     class Meta:
  45         model = ChallengePhase
  46         fields = ('id', 'name', 'description', 'leaderboard_public', 'start_date',
  47                   'end_date', 'challenge', 'max_submissions_per_day', 'max_submissions',
  48                   'is_public', 'is_active', 'codename')
  49 
  50 
  51 class DatasetSplitSerializer(serializers.ModelSerializer):
  52 
  53     class Meta:
  54         model = DatasetSplit
  55         fields = '__all__'
  56 
  57 
  58 class ChallengePhaseSplitSerializer(serializers.ModelSerializer):
  59     """Serialize the ChallengePhaseSplits Model"""
  60 
  61     dataset_split_name = serializers.SerializerMethodField()
  62     challenge_phase_name = serializers.SerializerMethodField()
  63 
  64     class Meta:
  65         model = ChallengePhaseSplit
  66         fields = '__all__'
  67         fields = ('id', 'dataset_split', 'challenge_phase', 'challenge_phase_name', 'dataset_split_name', 'visibility')
  68 
  69     def get_dataset_split_name(self, obj):
  70         return obj.dataset_split.name
  71 
  72     def get_challenge_phase_name(self, obj):
  73         return obj.challenge_phase.name
  74
  [end of apps/challenges/serializers.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/apps/challenges/serializers.py b/apps/challenges/serializers.py
  --- a/apps/challenges/serializers.py
  +++ b/apps/challenges/serializers.py
  @@ -2,11 +2,12 @@
   
   from hosts.serializers import ChallengeHostTeamSerializer
   
  -from .models import (
  -                     Challenge,
  +from .models import (Challenge,
  +                     ChallengeConfiguration,
                        ChallengePhase,
                        ChallengePhaseSplit,
  -                     DatasetSplit,)
  +                     DatasetSplit,
  +                     Leaderboard,)
   
   
   class ChallengeSerializer(serializers.ModelSerializer):
  @@ -63,7 +64,6 @@
   
       class Meta:
           model = ChallengePhaseSplit
  -        fields = '__all__'
           fields = ('id', 'dataset_split', 'challenge_phase', 'challenge_phase_name', 'dataset_split_name', 'visibility')
   
       def get_dataset_split_name(self, obj):
  @@ -71,3 +71,48 @@
   
       def get_challenge_phase_name(self, obj):
           return obj.challenge_phase.name
  +
  +
  +class ChallengeConfigSerializer(serializers.ModelSerializer):
  +    """
  +    Serialize the ChallengeConfiguration Model.
  +    """
  +    def __init__(self, *args, **kwargs):
  +        super(ChallengeConfigSerializer, self).__init__(*args, **kwargs)
  +        context = kwargs.get('context')
  +        if context:
  +            user = context.get('user')
  +            kwargs['data']['user'] = user.pk
  +
  +    class Meta:
  +        model = ChallengeConfiguration
  +        fields = ('zip_configuration', 'user',)
  +
  +
  +class LeaderboardSerializer(serializers.ModelSerializer):
  +    """
  +    Serialize the Leaderboard Model.
  +    """
  +    class Meta:
  +        model = Leaderboard
  +        fields = '__all__'
  +
  +
  +class ZipChallengeSerializer(ChallengeSerializer):
  +    """
  +    Serializer used for creating challenge through zip file.
  +    """
  +    class Meta:
  +        model = Challenge
  +        fields = ('id', 'title', 'short_description', 'description', 'terms_and_conditions',
  +                  'submission_guidelines', 'start_date', 'end_date', 'creator',
  +                  'published', 'enable_forum', 'anonymous_leaderboard', 'is_active',)
  +
  +
  +class ZipChallengePhaseSplitSerializer(serializers.ModelSerializer):
  +    """
  +    Serializer used for creating challenge phase split through zip file.
  +    """
  +    class Meta:
  +        model = ChallengePhaseSplit
  +        fields = '__all__'
  
verification_info: {"golden_diff": "diff --git a/apps/challenges/serializers.py b/apps/challenges/serializers.py\n--- a/apps/challenges/serializers.py\n+++ b/apps/challenges/serializers.py\n@@ -2,11 +2,12 @@\n \n from hosts.serializers import ChallengeHostTeamSerializer\n \n-from .models import (\n-                     Challenge,\n+from .models import (Challenge,\n+                     ChallengeConfiguration,\n                      ChallengePhase,\n                      ChallengePhaseSplit,\n-                     DatasetSplit,)\n+                     DatasetSplit,\n+                     Leaderboard,)\n \n \n class ChallengeSerializer(serializers.ModelSerializer):\n@@ -63,7 +64,6 @@\n \n     class Meta:\n         model = ChallengePhaseSplit\n-        fields = '__all__'\n         fields = ('id', 'dataset_split', 'challenge_phase', 'challenge_phase_name', 'dataset_split_name', 'visibility')\n \n     def get_dataset_split_name(self, obj):\n@@ -71,3 +71,48 @@\n \n     def get_challenge_phase_name(self, obj):\n         return obj.challenge_phase.name\n+\n+\n+class ChallengeConfigSerializer(serializers.ModelSerializer):\n+    \"\"\"\n+    Serialize the ChallengeConfiguration Model.\n+    \"\"\"\n+    def __init__(self, *args, **kwargs):\n+        super(ChallengeConfigSerializer, self).__init__(*args, **kwargs)\n+        context = kwargs.get('context')\n+        if context:\n+            user = context.get('user')\n+            kwargs['data']['user'] = user.pk\n+\n+    class Meta:\n+        model = ChallengeConfiguration\n+        fields = ('zip_configuration', 'user',)\n+\n+\n+class LeaderboardSerializer(serializers.ModelSerializer):\n+    \"\"\"\n+    Serialize the Leaderboard Model.\n+    \"\"\"\n+    class Meta:\n+        model = Leaderboard\n+        fields = '__all__'\n+\n+\n+class ZipChallengeSerializer(ChallengeSerializer):\n+    \"\"\"\n+    Serializer used for creating challenge through zip file.\n+    \"\"\"\n+    class Meta:\n+        model = Challenge\n+        fields = ('id', 'title', 'short_description', 'description', 'terms_and_conditions',\n+                  'submission_guidelines', 'start_date', 'end_date', 'creator',\n+                  'published', 'enable_forum', 'anonymous_leaderboard', 'is_active',)\n+\n+\n+class ZipChallengePhaseSplitSerializer(serializers.ModelSerializer):\n+    \"\"\"\n+    Serializer used for creating challenge phase split through zip file.\n+    \"\"\"\n+    class Meta:\n+        model = ChallengePhaseSplit\n+        fields = '__all__'\n", "issue": "Add serializers for creating challenge using zip file.\n\n", "before_files": [{"content": "from rest_framework import serializers\n\nfrom hosts.serializers import ChallengeHostTeamSerializer\n\nfrom .models import (\n                     Challenge,\n                     ChallengePhase,\n                     ChallengePhaseSplit,\n                     DatasetSplit,)\n\n\nclass ChallengeSerializer(serializers.ModelSerializer):\n\n    is_active = serializers.ReadOnlyField()\n\n    def __init__(self, *args, **kwargs):\n        super(ChallengeSerializer, self).__init__(*args, **kwargs)\n        context = kwargs.get('context')\n        if context and context.get('request').method != 'GET':\n            challenge_host_team = context.get('challenge_host_team')\n            kwargs['data']['creator'] = challenge_host_team.pk\n        else:\n            self.fields['creator'] = ChallengeHostTeamSerializer()\n\n    class Meta:\n        model = Challenge\n        fields = ('id', 'title', 'short_description', 'description', 'terms_and_conditions',\n                  'submission_guidelines', 'evaluation_details',\n                  'image', 'start_date', 'end_date', 'creator',\n                  'published', 'enable_forum', 'anonymous_leaderboard', 'is_active',)\n\n\nclass ChallengePhaseSerializer(serializers.ModelSerializer):\n\n    is_active = serializers.ReadOnlyField()\n\n    def __init__(self, *args, **kwargs):\n        super(ChallengePhaseSerializer, self).__init__(*args, **kwargs)\n        context = kwargs.get('context')\n        if context:\n            challenge = context.get('challenge')\n            kwargs['data']['challenge'] = challenge.pk\n\n    class Meta:\n        model = ChallengePhase\n        fields = ('id', 'name', 'description', 'leaderboard_public', 'start_date',\n                  'end_date', 'challenge', 'max_submissions_per_day', 'max_submissions',\n                  'is_public', 'is_active', 'codename')\n\n\nclass DatasetSplitSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = DatasetSplit\n        fields = '__all__'\n\n\nclass ChallengePhaseSplitSerializer(serializers.ModelSerializer):\n    \"\"\"Serialize the ChallengePhaseSplits Model\"\"\"\n\n    dataset_split_name = serializers.SerializerMethodField()\n    challenge_phase_name = serializers.SerializerMethodField()\n\n    class Meta:\n        model = ChallengePhaseSplit\n        fields = '__all__'\n        fields = ('id', 'dataset_split', 'challenge_phase', 'challenge_phase_name', 'dataset_split_name', 'visibility')\n\n    def get_dataset_split_name(self, obj):\n        return obj.dataset_split.name\n\n    def get_challenge_phase_name(self, obj):\n        return obj.challenge_phase.name\n", "path": "apps/challenges/serializers.py"}]}