prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Un utilisateur peut s'écrire à lui même
  Testé en préprod.
  
  Scénario : 
  - Je vais dans l'interface des messages
  - Dans les destinaites, je renseigne la chaine suivante (contenu entre guillemets) " , ".
  - Le MP m'est envoyé à moi tout seul.
  
  
  --- 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/mp/forms.py`
  Content:
  ```
  1 # coding: utf-8
  2 
  3 from crispy_forms.helper import FormHelper
  4 from crispy_forms.layout import Layout, Field, Hidden
  5 from django import forms
  6 from django.contrib.auth.models import User
  7 from django.core.urlresolvers import reverse
  8 
  9 from zds.mp.models import PrivateTopic
  10 from zds.utils.forms import CommonLayoutEditor
  11 from django.utils.translation import ugettext_lazy as _
  12 
  13 
  14 class PrivateTopicForm(forms.Form):
  15     participants = forms.CharField(
  16         label=_('Participants'),
  17         widget=forms.TextInput(
  18             attrs={
  19                 'placeholder': _(u'Les participants doivent '
  20                                  u'être séparés par une virgule.'),
  21                 'required': 'required',
  22                 'data-autocomplete': '{ "type": "multiple" }'}))
  23 
  24     title = forms.CharField(
  25         label=_('Titre'),
  26         max_length=PrivateTopic._meta.get_field('title').max_length,
  27         widget=forms.TextInput(
  28             attrs={
  29                 'required': 'required'
  30             }
  31         )
  32     )
  33 
  34     subtitle = forms.CharField(
  35         label=_('Sous-titre'),
  36         max_length=PrivateTopic._meta.get_field('subtitle').max_length,
  37         required=False
  38     )
  39 
  40     text = forms.CharField(
  41         label='Texte',
  42         required=False,
  43         widget=forms.Textarea(
  44             attrs={
  45                 'placeholder': _('Votre message au format Markdown.'),
  46                 'required': 'required'
  47             }
  48         )
  49     )
  50 
  51     def __init__(self, username, *args, **kwargs):
  52         super(PrivateTopicForm, self).__init__(*args, **kwargs)
  53         self.helper = FormHelper()
  54         self.helper.form_class = 'content-wrapper'
  55         self.helper.form_method = 'post'
  56         self.username = username
  57 
  58         self.helper.layout = Layout(
  59             Field('participants', autocomplete='off'),
  60             Field('title', autocomplete='off'),
  61             Field('subtitle', autocomplete='off'),
  62             CommonLayoutEditor(),
  63         )
  64 
  65     def clean(self):
  66         cleaned_data = super(PrivateTopicForm, self).clean()
  67 
  68         participants = cleaned_data.get('participants')
  69         title = cleaned_data.get('title')
  70         text = cleaned_data.get('text')
  71 
  72         if participants is not None and participants.strip() == '':
  73             self._errors['participants'] = self.error_class(
  74                 [_(u'Le champ participants ne peut être vide')])
  75 
  76         if participants is not None and participants.strip() != '':
  77             receivers = participants.strip().split(',')
  78             for receiver in receivers:
  79                 if User.objects.filter(username__exact=receiver.strip()).count() == 0 and receiver.strip() != '':
  80                     self._errors['participants'] = self.error_class(
  81                         [_(u'Un des participants saisi est introuvable')])
  82                 elif receiver.strip().lower() == self.username.lower():
  83                     self._errors['participants'] = self.error_class(
  84                         [_(u'Vous ne pouvez pas vous écrire à vous-même !')])
  85 
  86         if title is not None and title.strip() == '':
  87             self._errors['title'] = self.error_class(
  88                 [_(u'Le champ titre ne peut être vide')])
  89 
  90         if text is not None and text.strip() == '':
  91             self._errors['text'] = self.error_class(
  92                 [_(u'Le champ text ne peut être vide')])
  93 
  94         return cleaned_data
  95 
  96 
  97 class PrivatePostForm(forms.Form):
  98     text = forms.CharField(
  99         label='',
  100         widget=forms.Textarea(
  101             attrs={
  102                 'placeholder': _('Votre message au format Markdown.'),
  103                 'required': 'required'
  104             }
  105         )
  106     )
  107 
  108     def __init__(self, topic, user, *args, **kwargs):
  109         super(PrivatePostForm, self).__init__(*args, **kwargs)
  110         self.helper = FormHelper()
  111         self.helper.form_action = reverse(
  112             'zds.mp.views.answer') + '?sujet=' + str(topic.pk)
  113         self.helper.form_method = 'post'
  114 
  115         self.helper.layout = Layout(
  116             CommonLayoutEditor(),
  117             Hidden('last_post', '{{ last_post_pk }}'),
  118         )
  119 
  120         if topic.alone():
  121             self.helper['text'].wrap(
  122                 Field,
  123                 placeholder=_(u'Vous êtes seul dans cette conversation, '
  124                               u'vous ne pouvez plus y écrire.'),
  125                 disabled=True)
  126 
  127     def clean(self):
  128         cleaned_data = super(PrivatePostForm, self).clean()
  129 
  130         text = cleaned_data.get('text')
  131 
  132         if text is not None and text.strip() == '':
  133             self._errors['text'] = self.error_class(
  134                 [_(u'Le champ text ne peut être vide')])
  135 
  136         return cleaned_data
  137
  ```
  --- 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/mp/forms.py b/zds/mp/forms.py
  --- a/zds/mp/forms.py
  +++ b/zds/mp/forms.py
  @@ -76,7 +76,8 @@
           if participants is not None and participants.strip() != '':
               receivers = participants.strip().split(',')
               for receiver in receivers:
  -                if User.objects.filter(username__exact=receiver.strip()).count() == 0 and receiver.strip() != '':
  +                if User.objects.filter(username__exact=receiver.strip()).count() == 0 and receiver.strip() != '' \
  +                        or receiver.strip() == '':
                       self._errors['participants'] = self.error_class(
                           [_(u'Un des participants saisi est introuvable')])
                   elif receiver.strip().lower() == self.username.lower():
  
verification_info: {"golden_diff": "diff --git a/zds/mp/forms.py b/zds/mp/forms.py\n--- a/zds/mp/forms.py\n+++ b/zds/mp/forms.py\n@@ -76,7 +76,8 @@\n         if participants is not None and participants.strip() != '':\n             receivers = participants.strip().split(',')\n             for receiver in receivers:\n-                if User.objects.filter(username__exact=receiver.strip()).count() == 0 and receiver.strip() != '':\n+                if User.objects.filter(username__exact=receiver.strip()).count() == 0 and receiver.strip() != '' \\\n+                        or receiver.strip() == '':\n                     self._errors['participants'] = self.error_class(\n                         [_(u'Un des participants saisi est introuvable')])\n                 elif receiver.strip().lower() == self.username.lower():\n", "issue": "Un utilisateur peut s'\u00e9crire \u00e0 lui m\u00eame\nTest\u00e9 en pr\u00e9prod.\n\nSc\u00e9nario : \n- Je vais dans l'interface des messages\n- Dans les destinaites, je renseigne la chaine suivante (contenu entre guillemets) \" , \".\n- Le MP m'est envoy\u00e9 \u00e0 moi tout seul.\n\n", "before_files": [{"content": "# coding: utf-8\n\nfrom crispy_forms.helper import FormHelper\nfrom crispy_forms.layout import Layout, Field, Hidden\nfrom django import forms\nfrom django.contrib.auth.models import User\nfrom django.core.urlresolvers import reverse\n\nfrom zds.mp.models import PrivateTopic\nfrom zds.utils.forms import CommonLayoutEditor\nfrom django.utils.translation import ugettext_lazy as _\n\n\nclass PrivateTopicForm(forms.Form):\n    participants = forms.CharField(\n        label=_('Participants'),\n        widget=forms.TextInput(\n            attrs={\n                'placeholder': _(u'Les participants doivent '\n                                 u'\u00eatre s\u00e9par\u00e9s par une virgule.'),\n                'required': 'required',\n                'data-autocomplete': '{ \"type\": \"multiple\" }'}))\n\n    title = forms.CharField(\n        label=_('Titre'),\n        max_length=PrivateTopic._meta.get_field('title').max_length,\n        widget=forms.TextInput(\n            attrs={\n                'required': 'required'\n            }\n        )\n    )\n\n    subtitle = forms.CharField(\n        label=_('Sous-titre'),\n        max_length=PrivateTopic._meta.get_field('subtitle').max_length,\n        required=False\n    )\n\n    text = forms.CharField(\n        label='Texte',\n        required=False,\n        widget=forms.Textarea(\n            attrs={\n                'placeholder': _('Votre message au format Markdown.'),\n                'required': 'required'\n            }\n        )\n    )\n\n    def __init__(self, username, *args, **kwargs):\n        super(PrivateTopicForm, self).__init__(*args, **kwargs)\n        self.helper = FormHelper()\n        self.helper.form_class = 'content-wrapper'\n        self.helper.form_method = 'post'\n        self.username = username\n\n        self.helper.layout = Layout(\n            Field('participants', autocomplete='off'),\n            Field('title', autocomplete='off'),\n            Field('subtitle', autocomplete='off'),\n            CommonLayoutEditor(),\n        )\n\n    def clean(self):\n        cleaned_data = super(PrivateTopicForm, self).clean()\n\n        participants = cleaned_data.get('participants')\n        title = cleaned_data.get('title')\n        text = cleaned_data.get('text')\n\n        if participants is not None and participants.strip() == '':\n            self._errors['participants'] = self.error_class(\n                [_(u'Le champ participants ne peut \u00eatre vide')])\n\n        if participants is not None and participants.strip() != '':\n            receivers = participants.strip().split(',')\n            for receiver in receivers:\n                if User.objects.filter(username__exact=receiver.strip()).count() == 0 and receiver.strip() != '':\n                    self._errors['participants'] = self.error_class(\n                        [_(u'Un des participants saisi est introuvable')])\n                elif receiver.strip().lower() == self.username.lower():\n                    self._errors['participants'] = self.error_class(\n                        [_(u'Vous ne pouvez pas vous \u00e9crire \u00e0 vous-m\u00eame !')])\n\n        if title is not None and title.strip() == '':\n            self._errors['title'] = self.error_class(\n                [_(u'Le champ titre ne peut \u00eatre vide')])\n\n        if text is not None and text.strip() == '':\n            self._errors['text'] = self.error_class(\n                [_(u'Le champ text ne peut \u00eatre vide')])\n\n        return cleaned_data\n\n\nclass PrivatePostForm(forms.Form):\n    text = forms.CharField(\n        label='',\n        widget=forms.Textarea(\n            attrs={\n                'placeholder': _('Votre message au format Markdown.'),\n                'required': 'required'\n            }\n        )\n    )\n\n    def __init__(self, topic, user, *args, **kwargs):\n        super(PrivatePostForm, self).__init__(*args, **kwargs)\n        self.helper = FormHelper()\n        self.helper.form_action = reverse(\n            'zds.mp.views.answer') + '?sujet=' + str(topic.pk)\n        self.helper.form_method = 'post'\n\n        self.helper.layout = Layout(\n            CommonLayoutEditor(),\n            Hidden('last_post', '{{ last_post_pk }}'),\n        )\n\n        if topic.alone():\n            self.helper['text'].wrap(\n                Field,\n                placeholder=_(u'Vous \u00eates seul dans cette conversation, '\n                              u'vous ne pouvez plus y \u00e9crire.'),\n                disabled=True)\n\n    def clean(self):\n        cleaned_data = super(PrivatePostForm, self).clean()\n\n        text = cleaned_data.get('text')\n\n        if text is not None and text.strip() == '':\n            self._errors['text'] = self.error_class(\n                [_(u'Le champ text ne peut \u00eatre vide')])\n\n        return cleaned_data\n", "path": "zds/mp/forms.py"}], "after_files": [{"content": "# coding: utf-8\n\nfrom crispy_forms.helper import FormHelper\nfrom crispy_forms.layout import Layout, Field, Hidden\nfrom django import forms\nfrom django.contrib.auth.models import User\nfrom django.core.urlresolvers import reverse\n\nfrom zds.mp.models import PrivateTopic\nfrom zds.utils.forms import CommonLayoutEditor\nfrom django.utils.translation import ugettext_lazy as _\n\n\nclass PrivateTopicForm(forms.Form):\n    participants = forms.CharField(\n        label=_('Participants'),\n        widget=forms.TextInput(\n            attrs={\n                'placeholder': _(u'Les participants doivent '\n                                 u'\u00eatre s\u00e9par\u00e9s par une virgule.'),\n                'required': 'required',\n                'data-autocomplete': '{ \"type\": \"multiple\" }'}))\n\n    title = forms.CharField(\n        label=_('Titre'),\n        max_length=PrivateTopic._meta.get_field('title').max_length,\n        widget=forms.TextInput(\n            attrs={\n                'required': 'required'\n            }\n        )\n    )\n\n    subtitle = forms.CharField(\n        label=_('Sous-titre'),\n        max_length=PrivateTopic._meta.get_field('subtitle').max_length,\n        required=False\n    )\n\n    text = forms.CharField(\n        label='Texte',\n        required=False,\n        widget=forms.Textarea(\n            attrs={\n                'placeholder': _('Votre message au format Markdown.'),\n                'required': 'required'\n            }\n        )\n    )\n\n    def __init__(self, username, *args, **kwargs):\n        super(PrivateTopicForm, self).__init__(*args, **kwargs)\n        self.helper = FormHelper()\n        self.helper.form_class = 'content-wrapper'\n        self.helper.form_method = 'post'\n        self.username = username\n\n        self.helper.layout = Layout(\n            Field('participants', autocomplete='off'),\n            Field('title', autocomplete='off'),\n            Field('subtitle', autocomplete='off'),\n            CommonLayoutEditor(),\n        )\n\n    def clean(self):\n        cleaned_data = super(PrivateTopicForm, self).clean()\n\n        participants = cleaned_data.get('participants')\n        title = cleaned_data.get('title')\n        text = cleaned_data.get('text')\n\n        if participants is not None and participants.strip() == '':\n            self._errors['participants'] = self.error_class(\n                [_(u'Le champ participants ne peut \u00eatre vide')])\n\n        if participants is not None and participants.strip() != '':\n            receivers = participants.strip().split(',')\n            for receiver in receivers:\n                if User.objects.filter(username__exact=receiver.strip()).count() == 0 and receiver.strip() != '' \\\n                        or receiver.strip() == '':\n                    self._errors['participants'] = self.error_class(\n                        [_(u'Un des participants saisi est introuvable')])\n                elif receiver.strip().lower() == self.username.lower():\n                    self._errors['participants'] = self.error_class(\n                        [_(u'Vous ne pouvez pas vous \u00e9crire \u00e0 vous-m\u00eame !')])\n\n        if title is not None and title.strip() == '':\n            self._errors['title'] = self.error_class(\n                [_(u'Le champ titre ne peut \u00eatre vide')])\n\n        if text is not None and text.strip() == '':\n            self._errors['text'] = self.error_class(\n                [_(u'Le champ text ne peut \u00eatre vide')])\n\n        return cleaned_data\n\n\nclass PrivatePostForm(forms.Form):\n    text = forms.CharField(\n        label='',\n        widget=forms.Textarea(\n            attrs={\n                'placeholder': _('Votre message au format Markdown.'),\n                'required': 'required'\n            }\n        )\n    )\n\n    def __init__(self, topic, user, *args, **kwargs):\n        super(PrivatePostForm, self).__init__(*args, **kwargs)\n        self.helper = FormHelper()\n        self.helper.form_action = reverse(\n            'zds.mp.views.answer') + '?sujet=' + str(topic.pk)\n        self.helper.form_method = 'post'\n\n        self.helper.layout = Layout(\n            CommonLayoutEditor(),\n            Hidden('last_post', '{{ last_post_pk }}'),\n        )\n\n        if topic.alone():\n            self.helper['text'].wrap(\n                Field,\n                placeholder=_(u'Vous \u00eates seul dans cette conversation, '\n                              u'vous ne pouvez plus y \u00e9crire.'),\n                disabled=True)\n\n    def clean(self):\n        cleaned_data = super(PrivatePostForm, self).clean()\n\n        text = cleaned_data.get('text')\n\n        if text is not None and text.strip() == '':\n            self._errors['text'] = self.error_class(\n                [_(u'Le champ text ne peut \u00eatre vide')])\n\n        return cleaned_data\n", "path": "zds/mp/forms.py"}]}