prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Disable the Challenge Phase buttons which are inactive while making submissions
  ## Observed Behaviour
  Currently, if a challenge phase is inactive then also a participant can select the phase to make submissions. 
  
  See screenshot for example:
  <img width="1440" alt="screen shot 2017-08-08 at 7 21 16 pm" src="https://user-images.githubusercontent.com/2945708/29098709-ca4c67a8-7c6e-11e7-8729-73122eb9982e.png">
  
  ## Expected Behaviour
  
  The challenge phases that are not active now should be ideally disabled and the user shouldn't be allowed to select those challenge phases. 
  Disable the Challenge Phase buttons which are inactive while making submissions
  ## Observed Behaviour
  Currently, if a challenge phase is inactive then also a participant can select the phase to make submissions. 
  
  See screenshot for example:
  <img width="1440" alt="screen shot 2017-08-08 at 7 21 16 pm" src="https://user-images.githubusercontent.com/2945708/29098709-ca4c67a8-7c6e-11e7-8729-73122eb9982e.png">
  
  ## Expected Behaviour
  
  The challenge phases that are not active now should be ideally disabled and the user shouldn't be allowed to select those challenge phases. 
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `apps/participants/serializers.py`
  Content:
  ```
  1 from django.contrib.auth.models import User
  2 
  3 from rest_framework import serializers
  4 
  5 from challenges.serializers import ChallengeSerializer
  6 from .models import (Participant, ParticipantTeam)
  7 
  8 
  9 class ParticipantTeamSerializer(serializers.ModelSerializer):
  10     """Serializer class to map Participants to Teams."""
  11     created_by = serializers.SlugRelatedField(slug_field='username', queryset=User.objects.all())
  12 
  13     def __init__(self, *args, **kwargs):
  14         super(ParticipantTeamSerializer, self).__init__(*args, **kwargs)
  15         context = kwargs.get('context')
  16         if context:
  17             request = context.get('request')
  18             kwargs['data']['created_by'] = request.user.username
  19 
  20     class Meta:
  21         model = ParticipantTeam
  22         fields = ('id', 'team_name', 'created_by')
  23 
  24 
  25 class InviteParticipantToTeamSerializer(serializers.Serializer):
  26     """Serializer class for inviting Participant to Team."""
  27     email = serializers.EmailField()
  28 
  29     def __init__(self, *args, **kwargs):
  30         super(InviteParticipantToTeamSerializer, self).__init__(*args, **kwargs)
  31         context = kwargs.get('context')
  32         if context:
  33             self.participant_team = context.get('participant_team')
  34             self.user = context.get('request').user
  35 
  36     def validate_email(self, value):
  37         if value == self.user.email:
  38             raise serializers.ValidationError('A participant cannot invite himself')
  39         try:
  40             User.objects.get(email=value)
  41         except User.DoesNotExist:
  42             raise serializers.ValidationError('User does not exist')
  43         return value
  44 
  45     def save(self):
  46         email = self.validated_data.get('email')
  47         return Participant.objects.get_or_create(user=User.objects.get(email=email),
  48                                                  status=Participant.ACCEPTED,
  49                                                  team=self.participant_team)
  50 
  51 
  52 class ParticipantSerializer(serializers.ModelSerializer):
  53     """Serializer class for Participants."""
  54     member_name = serializers.SerializerMethodField()
  55     member_id = serializers.SerializerMethodField()
  56 
  57     class Meta:
  58         model = Participant
  59         fields = ('member_name', 'status', 'member_id')
  60 
  61     def get_member_name(self, obj):
  62         return obj.user.username
  63 
  64     def get_member_id(self, obj):
  65         return obj.user.id
  66 
  67 
  68 class ParticipantTeamDetailSerializer(serializers.ModelSerializer):
  69     """Serializer for Participant Teams and Participant Combined."""
  70     members = serializers.SerializerMethodField()
  71     created_by = serializers.SlugRelatedField(slug_field='username', queryset=User.objects.all())
  72 
  73     class Meta:
  74         model = ParticipantTeam
  75         fields = ('id', 'team_name', 'created_by', 'members')
  76 
  77     def get_members(self, obj):
  78         participants = Participant.objects.filter(team__pk=obj.id)
  79         serializer = ParticipantSerializer(participants, many=True)
  80         return serializer.data
  81 
  82 
  83 class ChallengeParticipantTeam(object):
  84     """Serializer to map Challenge and Participant Teams."""
  85     def __init__(self, challenge, participant_team):
  86         self.challenge = challenge
  87         self.participant_team = participant_team
  88 
  89 
  90 class ChallengeParticipantTeamSerializer(serializers.Serializer):
  91     """Serializer to initialize Challenge and Participant's Team"""
  92     challenge = ChallengeSerializer()
  93     participant_team = ParticipantTeamSerializer()
  94 
  95 
  96 class ChallengeParticipantTeamList(object):
  97     """Class to create a list of Challenge and Participant Teams."""
  98     def __init__(self, challenge_participant_team_list):
  99         self.challenge_participant_team_list = challenge_participant_team_list
  100 
  101 
  102 class ChallengeParticipantTeamListSerializer(serializers.Serializer):
  103     """Serializer to map a challenge's participant team lists."""
  104     challenge_participant_team_list = ChallengeParticipantTeamSerializer(many=True)
  105 
  106 
  107 class ParticipantTeamCount(object):
  108     def __init__(self, participant_team_count):
  109         self.participant_team_count = participant_team_count
  110 
  111 
  112 class ParticipantTeamCountSerializer(serializers.Serializer):
  113     participant_team_count = serializers.IntegerField()
  114 
  115 
  116 class ParticipantCount(object):
  117     def __init__(self, participant_count):
  118         self.participant_count = participant_count
  119 
  120 
  121 class ParticipantCountSerializer(serializers.Serializer):
  122     participant_count = serializers.IntegerField()
  123
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/apps/participants/serializers.py b/apps/participants/serializers.py
  --- a/apps/participants/serializers.py
  +++ b/apps/participants/serializers.py
  @@ -1,4 +1,5 @@
   from django.contrib.auth.models import User
  +from django.utils import timezone
   
   from rest_framework import serializers
   
  @@ -102,6 +103,10 @@
   class ChallengeParticipantTeamListSerializer(serializers.Serializer):
       """Serializer to map a challenge's participant team lists."""
       challenge_participant_team_list = ChallengeParticipantTeamSerializer(many=True)
  +    datetime_now = serializers.SerializerMethodField()
  +
  +    def get_datetime_now(self, obj):
  +        return timezone.now()
   
   
   class ParticipantTeamCount(object):
  
verification_info: {"golden_diff": "diff --git a/apps/participants/serializers.py b/apps/participants/serializers.py\n--- a/apps/participants/serializers.py\n+++ b/apps/participants/serializers.py\n@@ -1,4 +1,5 @@\n from django.contrib.auth.models import User\n+from django.utils import timezone\n \n from rest_framework import serializers\n \n@@ -102,6 +103,10 @@\n class ChallengeParticipantTeamListSerializer(serializers.Serializer):\n     \"\"\"Serializer to map a challenge's participant team lists.\"\"\"\n     challenge_participant_team_list = ChallengeParticipantTeamSerializer(many=True)\n+    datetime_now = serializers.SerializerMethodField()\n+\n+    def get_datetime_now(self, obj):\n+        return timezone.now()\n \n \n class ParticipantTeamCount(object):\n", "issue": "Disable the Challenge Phase buttons which are inactive while making submissions\n## Observed Behaviour\r\nCurrently, if a challenge phase is inactive then also a participant can select the phase to make submissions. \r\n\r\nSee screenshot for example:\r\n<img width=\"1440\" alt=\"screen shot 2017-08-08 at 7 21 16 pm\" src=\"https://user-images.githubusercontent.com/2945708/29098709-ca4c67a8-7c6e-11e7-8729-73122eb9982e.png\">\r\n\r\n## Expected Behaviour\r\n\r\nThe challenge phases that are not active now should be ideally disabled and the user shouldn't be allowed to select those challenge phases. \nDisable the Challenge Phase buttons which are inactive while making submissions\n## Observed Behaviour\r\nCurrently, if a challenge phase is inactive then also a participant can select the phase to make submissions. \r\n\r\nSee screenshot for example:\r\n<img width=\"1440\" alt=\"screen shot 2017-08-08 at 7 21 16 pm\" src=\"https://user-images.githubusercontent.com/2945708/29098709-ca4c67a8-7c6e-11e7-8729-73122eb9982e.png\">\r\n\r\n## Expected Behaviour\r\n\r\nThe challenge phases that are not active now should be ideally disabled and the user shouldn't be allowed to select those challenge phases. \n", "before_files": [{"content": "from django.contrib.auth.models import User\n\nfrom rest_framework import serializers\n\nfrom challenges.serializers import ChallengeSerializer\nfrom .models import (Participant, ParticipantTeam)\n\n\nclass ParticipantTeamSerializer(serializers.ModelSerializer):\n    \"\"\"Serializer class to map Participants to Teams.\"\"\"\n    created_by = serializers.SlugRelatedField(slug_field='username', queryset=User.objects.all())\n\n    def __init__(self, *args, **kwargs):\n        super(ParticipantTeamSerializer, self).__init__(*args, **kwargs)\n        context = kwargs.get('context')\n        if context:\n            request = context.get('request')\n            kwargs['data']['created_by'] = request.user.username\n\n    class Meta:\n        model = ParticipantTeam\n        fields = ('id', 'team_name', 'created_by')\n\n\nclass InviteParticipantToTeamSerializer(serializers.Serializer):\n    \"\"\"Serializer class for inviting Participant to Team.\"\"\"\n    email = serializers.EmailField()\n\n    def __init__(self, *args, **kwargs):\n        super(InviteParticipantToTeamSerializer, self).__init__(*args, **kwargs)\n        context = kwargs.get('context')\n        if context:\n            self.participant_team = context.get('participant_team')\n            self.user = context.get('request').user\n\n    def validate_email(self, value):\n        if value == self.user.email:\n            raise serializers.ValidationError('A participant cannot invite himself')\n        try:\n            User.objects.get(email=value)\n        except User.DoesNotExist:\n            raise serializers.ValidationError('User does not exist')\n        return value\n\n    def save(self):\n        email = self.validated_data.get('email')\n        return Participant.objects.get_or_create(user=User.objects.get(email=email),\n                                                 status=Participant.ACCEPTED,\n                                                 team=self.participant_team)\n\n\nclass ParticipantSerializer(serializers.ModelSerializer):\n    \"\"\"Serializer class for Participants.\"\"\"\n    member_name = serializers.SerializerMethodField()\n    member_id = serializers.SerializerMethodField()\n\n    class Meta:\n        model = Participant\n        fields = ('member_name', 'status', 'member_id')\n\n    def get_member_name(self, obj):\n        return obj.user.username\n\n    def get_member_id(self, obj):\n        return obj.user.id\n\n\nclass ParticipantTeamDetailSerializer(serializers.ModelSerializer):\n    \"\"\"Serializer for Participant Teams and Participant Combined.\"\"\"\n    members = serializers.SerializerMethodField()\n    created_by = serializers.SlugRelatedField(slug_field='username', queryset=User.objects.all())\n\n    class Meta:\n        model = ParticipantTeam\n        fields = ('id', 'team_name', 'created_by', 'members')\n\n    def get_members(self, obj):\n        participants = Participant.objects.filter(team__pk=obj.id)\n        serializer = ParticipantSerializer(participants, many=True)\n        return serializer.data\n\n\nclass ChallengeParticipantTeam(object):\n    \"\"\"Serializer to map Challenge and Participant Teams.\"\"\"\n    def __init__(self, challenge, participant_team):\n        self.challenge = challenge\n        self.participant_team = participant_team\n\n\nclass ChallengeParticipantTeamSerializer(serializers.Serializer):\n    \"\"\"Serializer to initialize Challenge and Participant's Team\"\"\"\n    challenge = ChallengeSerializer()\n    participant_team = ParticipantTeamSerializer()\n\n\nclass ChallengeParticipantTeamList(object):\n    \"\"\"Class to create a list of Challenge and Participant Teams.\"\"\"\n    def __init__(self, challenge_participant_team_list):\n        self.challenge_participant_team_list = challenge_participant_team_list\n\n\nclass ChallengeParticipantTeamListSerializer(serializers.Serializer):\n    \"\"\"Serializer to map a challenge's participant team lists.\"\"\"\n    challenge_participant_team_list = ChallengeParticipantTeamSerializer(many=True)\n\n\nclass ParticipantTeamCount(object):\n    def __init__(self, participant_team_count):\n        self.participant_team_count = participant_team_count\n\n\nclass ParticipantTeamCountSerializer(serializers.Serializer):\n    participant_team_count = serializers.IntegerField()\n\n\nclass ParticipantCount(object):\n    def __init__(self, participant_count):\n        self.participant_count = participant_count\n\n\nclass ParticipantCountSerializer(serializers.Serializer):\n    participant_count = serializers.IntegerField()\n", "path": "apps/participants/serializers.py"}], "after_files": [{"content": "from django.contrib.auth.models import User\nfrom django.utils import timezone\n\nfrom rest_framework import serializers\n\nfrom challenges.serializers import ChallengeSerializer\nfrom .models import (Participant, ParticipantTeam)\n\n\nclass ParticipantTeamSerializer(serializers.ModelSerializer):\n    \"\"\"Serializer class to map Participants to Teams.\"\"\"\n    created_by = serializers.SlugRelatedField(slug_field='username', queryset=User.objects.all())\n\n    def __init__(self, *args, **kwargs):\n        super(ParticipantTeamSerializer, self).__init__(*args, **kwargs)\n        context = kwargs.get('context')\n        if context:\n            request = context.get('request')\n            kwargs['data']['created_by'] = request.user.username\n\n    class Meta:\n        model = ParticipantTeam\n        fields = ('id', 'team_name', 'created_by')\n\n\nclass InviteParticipantToTeamSerializer(serializers.Serializer):\n    \"\"\"Serializer class for inviting Participant to Team.\"\"\"\n    email = serializers.EmailField()\n\n    def __init__(self, *args, **kwargs):\n        super(InviteParticipantToTeamSerializer, self).__init__(*args, **kwargs)\n        context = kwargs.get('context')\n        if context:\n            self.participant_team = context.get('participant_team')\n            self.user = context.get('request').user\n\n    def validate_email(self, value):\n        if value == self.user.email:\n            raise serializers.ValidationError('A participant cannot invite himself')\n        try:\n            User.objects.get(email=value)\n        except User.DoesNotExist:\n            raise serializers.ValidationError('User does not exist')\n        return value\n\n    def save(self):\n        email = self.validated_data.get('email')\n        return Participant.objects.get_or_create(user=User.objects.get(email=email),\n                                                 status=Participant.ACCEPTED,\n                                                 team=self.participant_team)\n\n\nclass ParticipantSerializer(serializers.ModelSerializer):\n    \"\"\"Serializer class for Participants.\"\"\"\n    member_name = serializers.SerializerMethodField()\n    member_id = serializers.SerializerMethodField()\n\n    class Meta:\n        model = Participant\n        fields = ('member_name', 'status', 'member_id')\n\n    def get_member_name(self, obj):\n        return obj.user.username\n\n    def get_member_id(self, obj):\n        return obj.user.id\n\n\nclass ParticipantTeamDetailSerializer(serializers.ModelSerializer):\n    \"\"\"Serializer for Participant Teams and Participant Combined.\"\"\"\n    members = serializers.SerializerMethodField()\n    created_by = serializers.SlugRelatedField(slug_field='username', queryset=User.objects.all())\n\n    class Meta:\n        model = ParticipantTeam\n        fields = ('id', 'team_name', 'created_by', 'members')\n\n    def get_members(self, obj):\n        participants = Participant.objects.filter(team__pk=obj.id)\n        serializer = ParticipantSerializer(participants, many=True)\n        return serializer.data\n\n\nclass ChallengeParticipantTeam(object):\n    \"\"\"Serializer to map Challenge and Participant Teams.\"\"\"\n    def __init__(self, challenge, participant_team):\n        self.challenge = challenge\n        self.participant_team = participant_team\n\n\nclass ChallengeParticipantTeamSerializer(serializers.Serializer):\n    \"\"\"Serializer to initialize Challenge and Participant's Team\"\"\"\n    challenge = ChallengeSerializer()\n    participant_team = ParticipantTeamSerializer()\n\n\nclass ChallengeParticipantTeamList(object):\n    \"\"\"Class to create a list of Challenge and Participant Teams.\"\"\"\n    def __init__(self, challenge_participant_team_list):\n        self.challenge_participant_team_list = challenge_participant_team_list\n\n\nclass ChallengeParticipantTeamListSerializer(serializers.Serializer):\n    \"\"\"Serializer to map a challenge's participant team lists.\"\"\"\n    challenge_participant_team_list = ChallengeParticipantTeamSerializer(many=True)\n    datetime_now = serializers.SerializerMethodField()\n\n    def get_datetime_now(self, obj):\n        return timezone.now()\n\n\nclass ParticipantTeamCount(object):\n    def __init__(self, participant_team_count):\n        self.participant_team_count = participant_team_count\n\n\nclass ParticipantTeamCountSerializer(serializers.Serializer):\n    participant_team_count = serializers.IntegerField()\n\n\nclass ParticipantCount(object):\n    def __init__(self, participant_count):\n        self.participant_count = participant_count\n\n\nclass ParticipantCountSerializer(serializers.Serializer):\n    participant_count = serializers.IntegerField()\n", "path": "apps/participants/serializers.py"}]}