prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  L'API ne retourne pas toujours les mêmes infos pour un membre
  > Un autre truc, quand on met un jour un membre on peut spécifier deux champs qui ne sont pas fournit par le get classique : `hover_or_click` et `show_sign`. Est ce normal ?
  
  Source:[Kje](http://zestedesavoir.com/forums/sujet/1365/zep-17-elaboration-de-lapi-des-membres/?page=18#p45095)
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `zds/member/api/serializers.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 
  3 from rest_framework import serializers
  4 
  5 from zds.member.commons import ProfileUsernameValidator, ProfileEmailValidator, \
  6     ProfileCreate
  7 from zds.member.models import Profile
  8 
  9 
  10 class ProfileListSerializer(serializers.ModelSerializer):
  11     """
  12     Serializers of a user object.
  13     """
  14 
  15     username = serializers.CharField(source='user.username')
  16     is_active = serializers.BooleanField(source='user.is_active')
  17     date_joined = serializers.DateTimeField(source='user.date_joined')
  18 
  19     class Meta:
  20         model = Profile
  21         fields = ('pk', 'username', 'is_active', 'date_joined')
  22 
  23 
  24 class ProfileCreateSerializer(serializers.ModelSerializer, ProfileCreate, ProfileUsernameValidator,
  25                               ProfileEmailValidator):
  26     """
  27     Serializers of a user object to create one.
  28     """
  29 
  30     username = serializers.CharField(source='user.username')
  31     email = serializers.EmailField(source='user.email')
  32     password = serializers.CharField(source='user.password')
  33 
  34     class Meta:
  35         model = Profile
  36         fields = ('pk', 'username', 'email', 'password')
  37         write_only_fields = ('password')
  38 
  39     def create(self, validated_data):
  40         profile = self.create_profile(validated_data.get('user'))
  41         self.save_profile(profile)
  42         return profile
  43 
  44     def throw_error(self, key=None, message=None):
  45         raise serializers.ValidationError(message)
  46 
  47 
  48 class ProfileDetailSerializer(serializers.ModelSerializer):
  49     """
  50     Serializers of a profile object.
  51     """
  52 
  53     username = serializers.CharField(source='user.username')
  54     email = serializers.EmailField(source='user.email')
  55     is_active = serializers.BooleanField(source='user.is_active')
  56     date_joined = serializers.DateTimeField(source='user.date_joined')
  57 
  58     class Meta:
  59         model = Profile
  60         fields = ('pk', 'username', 'show_email', 'email', 'is_active',
  61                   'site', 'avatar_url', 'biography', 'sign', 'email_for_answer',
  62                   'last_visit', 'date_joined')
  63 
  64     def __init__(self, *args, **kwargs):
  65         """
  66         Create the serializer with or without email field, depending on the show_email argument.
  67         """
  68         show_email = kwargs.pop('show_email', False)
  69         is_authenticated = kwargs.pop('is_authenticated', False)
  70 
  71         super(ProfileDetailSerializer, self).__init__(*args, **kwargs)
  72 
  73         if not show_email or not is_authenticated:
  74             # Drop email field.
  75             self.fields.pop('email')
  76 
  77 
  78 class ProfileValidatorSerializer(serializers.ModelSerializer, ProfileUsernameValidator, ProfileEmailValidator):
  79     """
  80     Serializers of a profile object used to update a member.
  81     """
  82 
  83     username = serializers.CharField(source='user.username', required=False, allow_blank=True)
  84     email = serializers.EmailField(source='user.email', required=False, allow_blank=True)
  85 
  86     class Meta:
  87         model = Profile
  88         fields = ('pk', 'username', 'email', 'site', 'avatar_url', 'biography',
  89                   'sign', 'show_email', 'show_sign', 'hover_or_click',
  90                   'email_for_answer')
  91 
  92     def update(self, instance, validated_data):
  93         """
  94         Update and return an existing `Profile` instance, given the validated data.
  95         """
  96         instance.user.username = validated_data.get('user').get('username',
  97                                                                 instance.user.username) or instance.user.username
  98         instance.user.email = validated_data.get('user').get('email', instance.user.email) or instance.user.email
  99         instance.site = validated_data.get('site', instance.site) or instance.site
  100         instance.avatar_url = validated_data.get('avatar_url', instance.avatar_url) or instance.avatar_url
  101         instance.biography = validated_data.get('biography', instance.biography) or instance.biography
  102         instance.sign = validated_data.get('sign', instance.sign) or instance.sign
  103         instance.show_email = validated_data.get('show_email', instance.show_email) or instance.show_email
  104         instance.show_sign = validated_data.get('show_sign', instance.show_sign) or instance.show_sign
  105         instance.hover_or_click = validated_data.get('hover_or_click',
  106                                                      instance.hover_or_click) or instance.hover_or_click
  107         instance.email_for_answer = validated_data.get('email_for_answer',
  108                                                        instance.email_for_answer) or instance.email_for_answer
  109         instance.user.save()
  110         instance.save()
  111         return instance
  112 
  113     def throw_error(self, key=None, message=None):
  114         raise serializers.ValidationError(message)
  115 
  116 
  117 class ProfileSanctionSerializer(serializers.ModelSerializer):
  118     """
  119     Serializers of a profile object to set the user in reading only access.
  120     """
  121 
  122     username = serializers.ReadOnlyField(source='user.username')
  123     email = serializers.ReadOnlyField(source='user.email')
  124 
  125     class Meta:
  126         model = Profile
  127         fields = ('pk', 'username', 'email', 'can_write', 'end_ban_write', 'can_read', 'end_ban_read')
  128         read_only_fields = ('can_write', 'end_ban_write', 'can_read', 'end_ban_read')
  129
  ```
  --- 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/zds/member/api/serializers.py b/zds/member/api/serializers.py
  --- a/zds/member/api/serializers.py
  +++ b/zds/member/api/serializers.py
  @@ -57,9 +57,9 @@
   
       class Meta:
           model = Profile
  -        fields = ('pk', 'username', 'show_email', 'email', 'is_active',
  -                  'site', 'avatar_url', 'biography', 'sign', 'email_for_answer',
  -                  'last_visit', 'date_joined')
  +        fields = ('pk', 'username', 'email', 'is_active', 'date_joined',
  +                  'site', 'avatar_url', 'biography', 'sign', 'show_email',
  +                  'show_sign', 'hover_or_click', 'email_for_answer', 'last_visit')
   
       def __init__(self, *args, **kwargs):
           """
  @@ -82,12 +82,15 @@
   
       username = serializers.CharField(source='user.username', required=False, allow_blank=True)
       email = serializers.EmailField(source='user.email', required=False, allow_blank=True)
  +    is_active = serializers.BooleanField(source='user.is_active', required=False)
  +    date_joined = serializers.DateTimeField(source='user.date_joined', required=False)
   
       class Meta:
           model = Profile
  -        fields = ('pk', 'username', 'email', 'site', 'avatar_url', 'biography',
  -                  'sign', 'show_email', 'show_sign', 'hover_or_click',
  -                  'email_for_answer')
  +        fields = ('pk', 'username', 'email', 'is_active', 'date_joined',
  +                  'site', 'avatar_url', 'biography', 'sign', 'show_email',
  +                  'show_sign', 'hover_or_click', 'email_for_answer', 'last_visit')
  +        read_only_fields = ('is_active', 'date_joined', 'last_visit',)
   
       def update(self, instance, validated_data):
           """
  
verification_info: {"golden_diff": "diff --git a/zds/member/api/serializers.py b/zds/member/api/serializers.py\n--- a/zds/member/api/serializers.py\n+++ b/zds/member/api/serializers.py\n@@ -57,9 +57,9 @@\n \n     class Meta:\n         model = Profile\n-        fields = ('pk', 'username', 'show_email', 'email', 'is_active',\n-                  'site', 'avatar_url', 'biography', 'sign', 'email_for_answer',\n-                  'last_visit', 'date_joined')\n+        fields = ('pk', 'username', 'email', 'is_active', 'date_joined',\n+                  'site', 'avatar_url', 'biography', 'sign', 'show_email',\n+                  'show_sign', 'hover_or_click', 'email_for_answer', 'last_visit')\n \n     def __init__(self, *args, **kwargs):\n         \"\"\"\n@@ -82,12 +82,15 @@\n \n     username = serializers.CharField(source='user.username', required=False, allow_blank=True)\n     email = serializers.EmailField(source='user.email', required=False, allow_blank=True)\n+    is_active = serializers.BooleanField(source='user.is_active', required=False)\n+    date_joined = serializers.DateTimeField(source='user.date_joined', required=False)\n \n     class Meta:\n         model = Profile\n-        fields = ('pk', 'username', 'email', 'site', 'avatar_url', 'biography',\n-                  'sign', 'show_email', 'show_sign', 'hover_or_click',\n-                  'email_for_answer')\n+        fields = ('pk', 'username', 'email', 'is_active', 'date_joined',\n+                  'site', 'avatar_url', 'biography', 'sign', 'show_email',\n+                  'show_sign', 'hover_or_click', 'email_for_answer', 'last_visit')\n+        read_only_fields = ('is_active', 'date_joined', 'last_visit',)\n \n     def update(self, instance, validated_data):\n         \"\"\"\n", "issue": "L'API ne retourne pas toujours les m\u00eames infos pour un membre\n> Un autre truc, quand on met un jour un membre on peut sp\u00e9cifier deux champs qui ne sont pas fournit par le get classique : `hover_or_click` et `show_sign`. Est ce normal ?\n\nSource:[Kje](http://zestedesavoir.com/forums/sujet/1365/zep-17-elaboration-de-lapi-des-membres/?page=18#p45095)\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\nfrom rest_framework import serializers\n\nfrom zds.member.commons import ProfileUsernameValidator, ProfileEmailValidator, \\\n    ProfileCreate\nfrom zds.member.models import Profile\n\n\nclass ProfileListSerializer(serializers.ModelSerializer):\n    \"\"\"\n    Serializers of a user object.\n    \"\"\"\n\n    username = serializers.CharField(source='user.username')\n    is_active = serializers.BooleanField(source='user.is_active')\n    date_joined = serializers.DateTimeField(source='user.date_joined')\n\n    class Meta:\n        model = Profile\n        fields = ('pk', 'username', 'is_active', 'date_joined')\n\n\nclass ProfileCreateSerializer(serializers.ModelSerializer, ProfileCreate, ProfileUsernameValidator,\n                              ProfileEmailValidator):\n    \"\"\"\n    Serializers of a user object to create one.\n    \"\"\"\n\n    username = serializers.CharField(source='user.username')\n    email = serializers.EmailField(source='user.email')\n    password = serializers.CharField(source='user.password')\n\n    class Meta:\n        model = Profile\n        fields = ('pk', 'username', 'email', 'password')\n        write_only_fields = ('password')\n\n    def create(self, validated_data):\n        profile = self.create_profile(validated_data.get('user'))\n        self.save_profile(profile)\n        return profile\n\n    def throw_error(self, key=None, message=None):\n        raise serializers.ValidationError(message)\n\n\nclass ProfileDetailSerializer(serializers.ModelSerializer):\n    \"\"\"\n    Serializers of a profile object.\n    \"\"\"\n\n    username = serializers.CharField(source='user.username')\n    email = serializers.EmailField(source='user.email')\n    is_active = serializers.BooleanField(source='user.is_active')\n    date_joined = serializers.DateTimeField(source='user.date_joined')\n\n    class Meta:\n        model = Profile\n        fields = ('pk', 'username', 'show_email', 'email', 'is_active',\n                  'site', 'avatar_url', 'biography', 'sign', 'email_for_answer',\n                  'last_visit', 'date_joined')\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"\n        Create the serializer with or without email field, depending on the show_email argument.\n        \"\"\"\n        show_email = kwargs.pop('show_email', False)\n        is_authenticated = kwargs.pop('is_authenticated', False)\n\n        super(ProfileDetailSerializer, self).__init__(*args, **kwargs)\n\n        if not show_email or not is_authenticated:\n            # Drop email field.\n            self.fields.pop('email')\n\n\nclass ProfileValidatorSerializer(serializers.ModelSerializer, ProfileUsernameValidator, ProfileEmailValidator):\n    \"\"\"\n    Serializers of a profile object used to update a member.\n    \"\"\"\n\n    username = serializers.CharField(source='user.username', required=False, allow_blank=True)\n    email = serializers.EmailField(source='user.email', required=False, allow_blank=True)\n\n    class Meta:\n        model = Profile\n        fields = ('pk', 'username', 'email', 'site', 'avatar_url', 'biography',\n                  'sign', 'show_email', 'show_sign', 'hover_or_click',\n                  'email_for_answer')\n\n    def update(self, instance, validated_data):\n        \"\"\"\n        Update and return an existing `Profile` instance, given the validated data.\n        \"\"\"\n        instance.user.username = validated_data.get('user').get('username',\n                                                                instance.user.username) or instance.user.username\n        instance.user.email = validated_data.get('user').get('email', instance.user.email) or instance.user.email\n        instance.site = validated_data.get('site', instance.site) or instance.site\n        instance.avatar_url = validated_data.get('avatar_url', instance.avatar_url) or instance.avatar_url\n        instance.biography = validated_data.get('biography', instance.biography) or instance.biography\n        instance.sign = validated_data.get('sign', instance.sign) or instance.sign\n        instance.show_email = validated_data.get('show_email', instance.show_email) or instance.show_email\n        instance.show_sign = validated_data.get('show_sign', instance.show_sign) or instance.show_sign\n        instance.hover_or_click = validated_data.get('hover_or_click',\n                                                     instance.hover_or_click) or instance.hover_or_click\n        instance.email_for_answer = validated_data.get('email_for_answer',\n                                                       instance.email_for_answer) or instance.email_for_answer\n        instance.user.save()\n        instance.save()\n        return instance\n\n    def throw_error(self, key=None, message=None):\n        raise serializers.ValidationError(message)\n\n\nclass ProfileSanctionSerializer(serializers.ModelSerializer):\n    \"\"\"\n    Serializers of a profile object to set the user in reading only access.\n    \"\"\"\n\n    username = serializers.ReadOnlyField(source='user.username')\n    email = serializers.ReadOnlyField(source='user.email')\n\n    class Meta:\n        model = Profile\n        fields = ('pk', 'username', 'email', 'can_write', 'end_ban_write', 'can_read', 'end_ban_read')\n        read_only_fields = ('can_write', 'end_ban_write', 'can_read', 'end_ban_read')\n", "path": "zds/member/api/serializers.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\nfrom rest_framework import serializers\n\nfrom zds.member.commons import ProfileUsernameValidator, ProfileEmailValidator, \\\n    ProfileCreate\nfrom zds.member.models import Profile\n\n\nclass ProfileListSerializer(serializers.ModelSerializer):\n    \"\"\"\n    Serializers of a user object.\n    \"\"\"\n\n    username = serializers.CharField(source='user.username')\n    is_active = serializers.BooleanField(source='user.is_active')\n    date_joined = serializers.DateTimeField(source='user.date_joined')\n\n    class Meta:\n        model = Profile\n        fields = ('pk', 'username', 'is_active', 'date_joined')\n\n\nclass ProfileCreateSerializer(serializers.ModelSerializer, ProfileCreate, ProfileUsernameValidator,\n                              ProfileEmailValidator):\n    \"\"\"\n    Serializers of a user object to create one.\n    \"\"\"\n\n    username = serializers.CharField(source='user.username')\n    email = serializers.EmailField(source='user.email')\n    password = serializers.CharField(source='user.password')\n\n    class Meta:\n        model = Profile\n        fields = ('pk', 'username', 'email', 'password')\n        write_only_fields = ('password')\n\n    def create(self, validated_data):\n        profile = self.create_profile(validated_data.get('user'))\n        self.save_profile(profile)\n        return profile\n\n    def throw_error(self, key=None, message=None):\n        raise serializers.ValidationError(message)\n\n\nclass ProfileDetailSerializer(serializers.ModelSerializer):\n    \"\"\"\n    Serializers of a profile object.\n    \"\"\"\n\n    username = serializers.CharField(source='user.username')\n    email = serializers.EmailField(source='user.email')\n    is_active = serializers.BooleanField(source='user.is_active')\n    date_joined = serializers.DateTimeField(source='user.date_joined')\n\n    class Meta:\n        model = Profile\n        fields = ('pk', 'username', 'email', 'is_active', 'date_joined',\n                  'site', 'avatar_url', 'biography', 'sign', 'show_email',\n                  'show_sign', 'hover_or_click', 'email_for_answer', 'last_visit')\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"\n        Create the serializer with or without email field, depending on the show_email argument.\n        \"\"\"\n        show_email = kwargs.pop('show_email', False)\n        is_authenticated = kwargs.pop('is_authenticated', False)\n\n        super(ProfileDetailSerializer, self).__init__(*args, **kwargs)\n\n        if not show_email or not is_authenticated:\n            # Drop email field.\n            self.fields.pop('email')\n\n\nclass ProfileValidatorSerializer(serializers.ModelSerializer, ProfileUsernameValidator, ProfileEmailValidator):\n    \"\"\"\n    Serializers of a profile object used to update a member.\n    \"\"\"\n\n    username = serializers.CharField(source='user.username', required=False, allow_blank=True)\n    email = serializers.EmailField(source='user.email', required=False, allow_blank=True)\n    is_active = serializers.BooleanField(source='user.is_active', required=False)\n    date_joined = serializers.DateTimeField(source='user.date_joined', required=False)\n\n    class Meta:\n        model = Profile\n        fields = ('pk', 'username', 'email', 'is_active', 'date_joined',\n                  'site', 'avatar_url', 'biography', 'sign', 'show_email',\n                  'show_sign', 'hover_or_click', 'email_for_answer', 'last_visit')\n        read_only_fields = ('is_active', 'date_joined', 'last_visit',)\n\n    def update(self, instance, validated_data):\n        \"\"\"\n        Update and return an existing `Profile` instance, given the validated data.\n        \"\"\"\n        instance.user.username = validated_data.get('user').get('username',\n                                                                instance.user.username) or instance.user.username\n        instance.user.email = validated_data.get('user').get('email', instance.user.email) or instance.user.email\n        instance.site = validated_data.get('site', instance.site) or instance.site\n        instance.avatar_url = validated_data.get('avatar_url', instance.avatar_url) or instance.avatar_url\n        instance.biography = validated_data.get('biography', instance.biography) or instance.biography\n        instance.sign = validated_data.get('sign', instance.sign) or instance.sign\n        instance.show_email = validated_data.get('show_email', instance.show_email) or instance.show_email\n        instance.show_sign = validated_data.get('show_sign', instance.show_sign) or instance.show_sign\n        instance.hover_or_click = validated_data.get('hover_or_click',\n                                                     instance.hover_or_click) or instance.hover_or_click\n        instance.email_for_answer = validated_data.get('email_for_answer',\n                                                       instance.email_for_answer) or instance.email_for_answer\n        instance.user.save()\n        instance.save()\n        return instance\n\n    def throw_error(self, key=None, message=None):\n        raise serializers.ValidationError(message)\n\n\nclass ProfileSanctionSerializer(serializers.ModelSerializer):\n    \"\"\"\n    Serializers of a profile object to set the user in reading only access.\n    \"\"\"\n\n    username = serializers.ReadOnlyField(source='user.username')\n    email = serializers.ReadOnlyField(source='user.email')\n\n    class Meta:\n        model = Profile\n        fields = ('pk', 'username', 'email', 'can_write', 'end_ban_write', 'can_read', 'end_ban_read')\n        read_only_fields = ('can_write', 'end_ban_write', 'can_read', 'end_ban_read')\n", "path": "zds/member/api/serializers.py"}]}