We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
La página de agregar antecedentes no dice mucho.
Actualmente agregar más antecedentes puede ser accedida desde una sola parte:
![uploads/19ccfce5-ca60-4229-b13c-6eca8c6f144f/Captura de pantalla 2016-07-26 a las 1.29.28 p.m..png](https://s3-us-west-2.amazonaws.com/prod.huboard.com/uploads%2F19ccfce5-ca60-4229-b13c-6eca8c6f144f%2FCaptura+de+pantalla+2016-07-26+a+las+1.29.28+p.m..png)

Y debería ser accesible desde el mail de felicitaciones, la lista de tus propuestas.
Y además debería poder proveer de ejemplos que te permitan hacer de tu propuesta una más completa.
Por ejemplo en la parte donde dice "Background" debería decir algo así como: 
 "Puedes agregar más antecedentes? como por ejemplo, en qué año se inició el problema? o quizás cuantas veces han intentado darle solución?"

Además debería poder utilizarse esta información en el detalle de la propuesta.

<!---
@huboard:{"order":50.8644609375,"milestone_order":237,"custom_state":""}
-->


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `popular_proposal/forms/forms.py`
Content:
```
1 # coding=utf-8
2 from django import forms
3 from popular_proposal.models import (ProposalTemporaryData,
4                                      ProposalLike,
5                                      PopularProposal)
6 from votainteligente.send_mails import send_mail
7 from django.utils.translation import ugettext as _
8 from django.contrib.sites.models import Site
9 from .form_texts import TEXTS, TOPIC_CHOICES, WHEN_CHOICES
10 from popolo.models import Area
11 from collections import OrderedDict
12 
13 
14 class TextsFormMixin():
15 
16     def add_texts_to_fields(self):
17         for field in self.fields:
18             if field in TEXTS.keys():
19                 texts = TEXTS[field]
20                 if 'label' in texts.keys() and texts['label']:
21                     self.fields[field].label = texts['label']
22                 if 'help_text' in texts.keys() and texts['help_text']:
23                     self.fields[field].help_text = texts['help_text']
24                 if 'placeholder' in texts.keys() and texts['placeholder']:
25                     self.fields[field].widget.attrs[
26                         'placeholder'] = texts['placeholder']
27                 if 'long_text' in texts.keys() and texts['long_text']:
28                     self.fields[field].widget.attrs[
29                         'long_text'] = texts['long_text']
30                 if 'step' in texts.keys() and texts['step']:
31                     self.fields[field].widget.attrs['tab_text'] = texts['step']
32 
33 
34 def get_user_organizations_choicefield(user=None):
35     if user is None or not user.is_authenticated():
36         return None
37 
38     if user.enrollments.all():
39         choices = [('', 'Lo haré a nombre personal')]
40         for enrollment in user.enrollments.all():
41             choice = (enrollment.organization.id, enrollment.organization.name)
42             choices.append(choice)
43         label = _(u'¿Esta promesa es a nombre de un grupo ciudadano?')
44         return forms.ChoiceField(choices=choices,
45                                  label=label)
46     return None
47 
48 wizard_forms_fields = [
49     {
50         'template': 'popular_proposal/wizard/form_step.html',
51         'explation_template': "popular_proposal/steps/paso1.html",
52         'fields': OrderedDict([
53             ('problem', forms.CharField(max_length=512,
54                                         widget=forms.Textarea(),
55                                         ))
56         ])
57     },
58     {
59         'template': 'popular_proposal/wizard/form_step.html',
60         'explation_template': "popular_proposal/steps/paso2.html",
61         'fields': OrderedDict([(
62             'causes', forms.CharField(max_length=256,
63                                       widget=forms.Textarea(),
64                                       )
65 
66         )])
67     },
68     {
69         'template': 'popular_proposal/wizard/paso3.html',
70         'explation_template': "popular_proposal/steps/paso3.html",
71         'fields': OrderedDict([(
72             'clasification', forms.ChoiceField(choices=TOPIC_CHOICES,
73                                                widget=forms.Select())
74         ), (
75 
76             'solution', forms.CharField(max_length=512,
77                                         widget=forms.Textarea(),
78                                         )
79         )])
80     },
81     {
82         'template': 'popular_proposal/wizard/form_step.html',
83         'explation_template': "popular_proposal/steps/paso4.html",
84         'fields': OrderedDict([(
85             'solution_at_the_end', forms.CharField(widget=forms.Textarea(),
86                                                    required=False)
87 
88         ),
89             ('when', forms.ChoiceField(widget=forms.Select(),
90                                        choices=WHEN_CHOICES))
91         ])
92     },
93     {
94         'template': 'popular_proposal/wizard/paso5.html',
95         'explation_template': "popular_proposal/steps/paso5.html",
96         'fields': OrderedDict([
97             ('title', forms.CharField(max_length=256,
98                                       widget=forms.TextInput())),
99             ('organization', get_user_organizations_choicefield),
100             ('terms_and_conditions', forms.BooleanField(
101                 error_messages={'required':
102                                 _(u'Debes aceptar nuestros Términos y \
103 Condiciones')}
104             )
105             )
106         ])
107     }
108 ]
109 
110 
111 def get_form_list(wizard_forms_fields=wizard_forms_fields, **kwargs):
112     form_list = []
113     counter = 0
114     for step in wizard_forms_fields:
115         counter += 1
116         fields_dict = OrderedDict()
117         for field in step['fields']:
118             tha_field = step['fields'][field]
119             if hasattr(tha_field, '__call__'):
120                 executed_field = tha_field.__call__(**kwargs)
121                 if executed_field is not None:
122                     fields_dict[field] = executed_field
123             else:
124                 fields_dict[field] = tha_field
125 
126         def __init__(self, *args, **kwargs):
127             super(forms.Form, self).__init__(*args, **kwargs)
128             self.add_texts_to_fields()
129         cls_attrs = {"__init__": __init__,
130                      "explanation_template": step['explation_template'],
131                      "template": step['template']}
132         form_class = type('Step%d' % (counter),
133                           (forms.Form, TextsFormMixin, object), cls_attrs)
134         form_class.base_fields = fields_dict
135         form_list.append(form_class)
136     return form_list
137 
138 
139 class ProposalFormBase(forms.Form, TextsFormMixin):
140     def set_fields(self):
141         for steps in wizard_forms_fields:
142             for field_name in steps['fields']:
143                 field = steps['fields'][field_name]
144                 if hasattr(field, '__call__'):
145                     kwargs = {'user': self.proposer}
146                     field = field.__call__(**kwargs)
147                     if field is None:
148                         continue
149                 self.fields[field_name] = field
150 
151     def __init__(self, *args, **kwargs):
152         self.proposer = kwargs.pop('proposer', None)
153         super(ProposalFormBase, self).__init__(*args, **kwargs)
154         self.set_fields()
155         self.add_texts_to_fields()
156 
157 
158 class ProposalForm(ProposalFormBase):
159     def __init__(self, *args, **kwargs):
160         self.area = kwargs.pop('area')
161         super(ProposalForm, self).__init__(*args, **kwargs)
162 
163     def save(self):
164         t_data = ProposalTemporaryData.objects.create(proposer=self.proposer,
165                                                       area=self.area,
166                                                       data=self.cleaned_data)
167         t_data.notify_new()
168         return t_data
169 
170 
171 class UpdateProposalForm(forms.ModelForm):
172     def __init__(self, *args, **kwargs):
173         return super(UpdateProposalForm, self).__init__(*args, **kwargs)
174 
175     class Meta:
176         model = PopularProposal
177         fields = ['background', 'image']
178 
179 
180 class CommentsForm(forms.Form):
181     def __init__(self, *args, **kwargs):
182         self.temporary_data = kwargs.pop('temporary_data')
183         self.moderator = kwargs.pop('moderator')
184         super(CommentsForm, self).__init__(*args, **kwargs)
185         for field in self.temporary_data.comments.keys():
186             help_text = _(u'La ciudadana dijo: %s') % self.temporary_data.data.get(field, u'')
187             comments = self.temporary_data.comments[field]
188             if comments:
189                 help_text += _(u' <b>Y tus comentarios fueron: %s </b>') % comments
190             self.fields[field] = forms.CharField(required=False, help_text=help_text)
191 
192     def save(self, *args, **kwargs):
193         for field_key in self.cleaned_data.keys():
194             self.temporary_data.comments[field_key] = self.cleaned_data[field_key]
195         self.temporary_data.status = ProposalTemporaryData.Statuses.InTheirSide
196         self.temporary_data.save()
197         comments = {}
198         for key in self.temporary_data.data.keys():
199             if self.temporary_data.comments[key]:
200                 comments[key] = {
201                     'original': self.temporary_data.data[key],
202                     'comments': self.temporary_data.comments[key]
203                 }
204 
205         site = Site.objects.get_current()
206         mail_context = {
207             'area': self.temporary_data.area,
208             'temporary_data': self.temporary_data,
209             'moderator': self.moderator,
210             'comments': comments,
211             'site': site,
212 
213         }
214         send_mail(mail_context, 'popular_proposal_moderation',
215                   to=[self.temporary_data.proposer.email])
216         return self.temporary_data
217 
218 
219 class RejectionForm(forms.Form):
220     reason = forms.CharField()
221 
222     def __init__(self, *args, **kwargs):
223         self.temporary_data = kwargs.pop('temporary_data')
224         self.moderator = kwargs.pop('moderator')
225         super(RejectionForm, self).__init__(*args, **kwargs)
226 
227     def reject(self):
228         self.temporary_data.reject(self.cleaned_data['reason'])
229 
230 
231 class ProposalTemporaryDataUpdateForm(ProposalFormBase):
232     overall_comments = forms.CharField(required=False, label=_(u'Comentarios sobre tu revisón'))
233 
234     def __init__(self, *args, **kwargs):
235         self.proposer = kwargs.pop('proposer')
236         self.temporary_data = kwargs.pop('temporary_data')
237         super(ProposalTemporaryDataUpdateForm, self).__init__(*args, **kwargs)
238         self.initial = self.temporary_data.data
239         for comment_key in self.temporary_data.comments.keys():
240             comment = self.temporary_data.comments[comment_key]
241             if comment:
242                 self.fields[comment_key].help_text += _(' <b>Commentarios: %s </b>') % (comment)
243 
244     def save(self):
245         self.overall_comments = self.cleaned_data.pop('overall_comments')
246         self.temporary_data.data = self.cleaned_data
247         self.temporary_data.overall_comments = self.overall_comments
248         self.temporary_data.status = ProposalTemporaryData.Statuses.InOurSide
249         self.temporary_data.save()
250         return self.temporary_data
251 
252     def get_overall_comments(self):
253         return self.cleaned_data.get('overall_comments', '')
254 
255 
256 class SubscriptionForm(forms.Form):
257     def __init__(self, *args, **kwargs):
258         self.user = kwargs.pop('user')
259         self.proposal = kwargs.pop('proposal')
260         super(SubscriptionForm, self).__init__(*args, **kwargs)
261 
262     def subscribe(self):
263         like = ProposalLike.objects.create(user=self.user,
264                                            proposal=self.proposal)
265         return like
266 
267 
268 class AreaForm(forms.Form):
269     area = forms.ChoiceField()
270     explanation_template = "popular_proposal/steps/select_area.html"
271 
272     def __init__(self, *args, **kwargs):
273         super(AreaForm, self).__init__(*args, **kwargs)
274         self.fields['area'].choices = [(a.id, a.name) for a in Area.objects.all()]
275 
276     def clean(self):
277         cleaned_data = super(AreaForm, self).clean()
278         area = Area.objects.get(id=cleaned_data['area'])
279         cleaned_data['area'] = area
280         return cleaned_data
281
```
--- 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()

```

diff --git a/popular_proposal/forms/forms.py b/popular_proposal/forms/forms.py
--- a/popular_proposal/forms/forms.py
+++ b/popular_proposal/forms/forms.py
@@ -175,6 +175,10 @@
     class Meta:
         model = PopularProposal
         fields = ['background', 'image']
+        labels = {'background': _(u'Más antecedentes sobre tu propuesta.'),
+                  'image': _(u'¿Tienes alguna imagen para compartir?')
+                  }
+        help_texts = {'background': _(u'Ejemplo: Durante el año 2011, existió una iniciativa de otra comunidad que no llegó a buen puerto.')}
 
 
 class CommentsForm(forms.Form):

{"golden_diff": "diff --git a/popular_proposal/forms/forms.py b/popular_proposal/forms/forms.py\n--- a/popular_proposal/forms/forms.py\n+++ b/popular_proposal/forms/forms.py\n@@ -175,6 +175,10 @@\n     class Meta:\n         model = PopularProposal\n         fields = ['background', 'image']\n+        labels = {'background': _(u'M\u00e1s antecedentes sobre tu propuesta.'),\n+                  'image': _(u'\u00bfTienes alguna imagen para compartir?')\n+                  }\n+        help_texts = {'background': _(u'Ejemplo: Durante el a\u00f1o 2011, existi\u00f3 una iniciativa de otra comunidad que no lleg\u00f3 a buen puerto.')}\n \n \n class CommentsForm(forms.Form):\n", "issue": "La p\u00e1gina de agregar antecedentes no dice mucho.\nActualmente agregar m\u00e1s antecedentes puede ser accedida desde una sola parte:\n![uploads/19ccfce5-ca60-4229-b13c-6eca8c6f144f/Captura de pantalla 2016-07-26 a las 1.29.28 p.m..png](https://s3-us-west-2.amazonaws.com/prod.huboard.com/uploads%2F19ccfce5-ca60-4229-b13c-6eca8c6f144f%2FCaptura+de+pantalla+2016-07-26+a+las+1.29.28+p.m..png)\n\nY deber\u00eda ser accesible desde el mail de felicitaciones, la lista de tus propuestas.\nY adem\u00e1s deber\u00eda poder proveer de ejemplos que te permitan hacer de tu propuesta una m\u00e1s completa.\nPor ejemplo en la parte donde dice \"Background\" deber\u00eda decir algo as\u00ed como: \n \"Puedes agregar m\u00e1s antecedentes? como por ejemplo, en qu\u00e9 a\u00f1o se inici\u00f3 el problema? o quiz\u00e1s cuantas veces han intentado darle soluci\u00f3n?\"\n\nAdem\u00e1s deber\u00eda poder utilizarse esta informaci\u00f3n en el detalle de la propuesta.\n\n<!---\n@huboard:{\"order\":50.8644609375,\"milestone_order\":237,\"custom_state\":\"\"}\n-->\n\n", "before_files": [{"content": "# coding=utf-8\nfrom django import forms\nfrom popular_proposal.models import (ProposalTemporaryData,\n                                     ProposalLike,\n                                     PopularProposal)\nfrom votainteligente.send_mails import send_mail\nfrom django.utils.translation import ugettext as _\nfrom django.contrib.sites.models import Site\nfrom .form_texts import TEXTS, TOPIC_CHOICES, WHEN_CHOICES\nfrom popolo.models import Area\nfrom collections import OrderedDict\n\n\nclass TextsFormMixin():\n\n    def add_texts_to_fields(self):\n        for field in self.fields:\n            if field in TEXTS.keys():\n                texts = TEXTS[field]\n                if 'label' in texts.keys() and texts['label']:\n                    self.fields[field].label = texts['label']\n                if 'help_text' in texts.keys() and texts['help_text']:\n                    self.fields[field].help_text = texts['help_text']\n                if 'placeholder' in texts.keys() and texts['placeholder']:\n                    self.fields[field].widget.attrs[\n                        'placeholder'] = texts['placeholder']\n                if 'long_text' in texts.keys() and texts['long_text']:\n                    self.fields[field].widget.attrs[\n                        'long_text'] = texts['long_text']\n                if 'step' in texts.keys() and texts['step']:\n                    self.fields[field].widget.attrs['tab_text'] = texts['step']\n\n\ndef get_user_organizations_choicefield(user=None):\n    if user is None or not user.is_authenticated():\n        return None\n\n    if user.enrollments.all():\n        choices = [('', 'Lo har\u00e9 a nombre personal')]\n        for enrollment in user.enrollments.all():\n            choice = (enrollment.organization.id, enrollment.organization.name)\n            choices.append(choice)\n        label = _(u'\u00bfEsta promesa es a nombre de un grupo ciudadano?')\n        return forms.ChoiceField(choices=choices,\n                                 label=label)\n    return None\n\nwizard_forms_fields = [\n    {\n        'template': 'popular_proposal/wizard/form_step.html',\n        'explation_template': \"popular_proposal/steps/paso1.html\",\n        'fields': OrderedDict([\n            ('problem', forms.CharField(max_length=512,\n                                        widget=forms.Textarea(),\n                                        ))\n        ])\n    },\n    {\n        'template': 'popular_proposal/wizard/form_step.html',\n        'explation_template': \"popular_proposal/steps/paso2.html\",\n        'fields': OrderedDict([(\n            'causes', forms.CharField(max_length=256,\n                                      widget=forms.Textarea(),\n                                      )\n\n        )])\n    },\n    {\n        'template': 'popular_proposal/wizard/paso3.html',\n        'explation_template': \"popular_proposal/steps/paso3.html\",\n        'fields': OrderedDict([(\n            'clasification', forms.ChoiceField(choices=TOPIC_CHOICES,\n                                               widget=forms.Select())\n        ), (\n\n            'solution', forms.CharField(max_length=512,\n                                        widget=forms.Textarea(),\n                                        )\n        )])\n    },\n    {\n        'template': 'popular_proposal/wizard/form_step.html',\n        'explation_template': \"popular_proposal/steps/paso4.html\",\n        'fields': OrderedDict([(\n            'solution_at_the_end', forms.CharField(widget=forms.Textarea(),\n                                                   required=False)\n\n        ),\n            ('when', forms.ChoiceField(widget=forms.Select(),\n                                       choices=WHEN_CHOICES))\n        ])\n    },\n    {\n        'template': 'popular_proposal/wizard/paso5.html',\n        'explation_template': \"popular_proposal/steps/paso5.html\",\n        'fields': OrderedDict([\n            ('title', forms.CharField(max_length=256,\n                                      widget=forms.TextInput())),\n            ('organization', get_user_organizations_choicefield),\n            ('terms_and_conditions', forms.BooleanField(\n                error_messages={'required':\n                                _(u'Debes aceptar nuestros T\u00e9rminos y \\\nCondiciones')}\n            )\n            )\n        ])\n    }\n]\n\n\ndef get_form_list(wizard_forms_fields=wizard_forms_fields, **kwargs):\n    form_list = []\n    counter = 0\n    for step in wizard_forms_fields:\n        counter += 1\n        fields_dict = OrderedDict()\n        for field in step['fields']:\n            tha_field = step['fields'][field]\n            if hasattr(tha_field, '__call__'):\n                executed_field = tha_field.__call__(**kwargs)\n                if executed_field is not None:\n                    fields_dict[field] = executed_field\n            else:\n                fields_dict[field] = tha_field\n\n        def __init__(self, *args, **kwargs):\n            super(forms.Form, self).__init__(*args, **kwargs)\n            self.add_texts_to_fields()\n        cls_attrs = {\"__init__\": __init__,\n                     \"explanation_template\": step['explation_template'],\n                     \"template\": step['template']}\n        form_class = type('Step%d' % (counter),\n                          (forms.Form, TextsFormMixin, object), cls_attrs)\n        form_class.base_fields = fields_dict\n        form_list.append(form_class)\n    return form_list\n\n\nclass ProposalFormBase(forms.Form, TextsFormMixin):\n    def set_fields(self):\n        for steps in wizard_forms_fields:\n            for field_name in steps['fields']:\n                field = steps['fields'][field_name]\n                if hasattr(field, '__call__'):\n                    kwargs = {'user': self.proposer}\n                    field = field.__call__(**kwargs)\n                    if field is None:\n                        continue\n                self.fields[field_name] = field\n\n    def __init__(self, *args, **kwargs):\n        self.proposer = kwargs.pop('proposer', None)\n        super(ProposalFormBase, self).__init__(*args, **kwargs)\n        self.set_fields()\n        self.add_texts_to_fields()\n\n\nclass ProposalForm(ProposalFormBase):\n    def __init__(self, *args, **kwargs):\n        self.area = kwargs.pop('area')\n        super(ProposalForm, self).__init__(*args, **kwargs)\n\n    def save(self):\n        t_data = ProposalTemporaryData.objects.create(proposer=self.proposer,\n                                                      area=self.area,\n                                                      data=self.cleaned_data)\n        t_data.notify_new()\n        return t_data\n\n\nclass UpdateProposalForm(forms.ModelForm):\n    def __init__(self, *args, **kwargs):\n        return super(UpdateProposalForm, self).__init__(*args, **kwargs)\n\n    class Meta:\n        model = PopularProposal\n        fields = ['background', 'image']\n\n\nclass CommentsForm(forms.Form):\n    def __init__(self, *args, **kwargs):\n        self.temporary_data = kwargs.pop('temporary_data')\n        self.moderator = kwargs.pop('moderator')\n        super(CommentsForm, self).__init__(*args, **kwargs)\n        for field in self.temporary_data.comments.keys():\n            help_text = _(u'La ciudadana dijo: %s') % self.temporary_data.data.get(field, u'')\n            comments = self.temporary_data.comments[field]\n            if comments:\n                help_text += _(u' <b>Y tus comentarios fueron: %s </b>') % comments\n            self.fields[field] = forms.CharField(required=False, help_text=help_text)\n\n    def save(self, *args, **kwargs):\n        for field_key in self.cleaned_data.keys():\n            self.temporary_data.comments[field_key] = self.cleaned_data[field_key]\n        self.temporary_data.status = ProposalTemporaryData.Statuses.InTheirSide\n        self.temporary_data.save()\n        comments = {}\n        for key in self.temporary_data.data.keys():\n            if self.temporary_data.comments[key]:\n                comments[key] = {\n                    'original': self.temporary_data.data[key],\n                    'comments': self.temporary_data.comments[key]\n                }\n\n        site = Site.objects.get_current()\n        mail_context = {\n            'area': self.temporary_data.area,\n            'temporary_data': self.temporary_data,\n            'moderator': self.moderator,\n            'comments': comments,\n            'site': site,\n\n        }\n        send_mail(mail_context, 'popular_proposal_moderation',\n                  to=[self.temporary_data.proposer.email])\n        return self.temporary_data\n\n\nclass RejectionForm(forms.Form):\n    reason = forms.CharField()\n\n    def __init__(self, *args, **kwargs):\n        self.temporary_data = kwargs.pop('temporary_data')\n        self.moderator = kwargs.pop('moderator')\n        super(RejectionForm, self).__init__(*args, **kwargs)\n\n    def reject(self):\n        self.temporary_data.reject(self.cleaned_data['reason'])\n\n\nclass ProposalTemporaryDataUpdateForm(ProposalFormBase):\n    overall_comments = forms.CharField(required=False, label=_(u'Comentarios sobre tu revis\u00f3n'))\n\n    def __init__(self, *args, **kwargs):\n        self.proposer = kwargs.pop('proposer')\n        self.temporary_data = kwargs.pop('temporary_data')\n        super(ProposalTemporaryDataUpdateForm, self).__init__(*args, **kwargs)\n        self.initial = self.temporary_data.data\n        for comment_key in self.temporary_data.comments.keys():\n            comment = self.temporary_data.comments[comment_key]\n            if comment:\n                self.fields[comment_key].help_text += _(' <b>Commentarios: %s </b>') % (comment)\n\n    def save(self):\n        self.overall_comments = self.cleaned_data.pop('overall_comments')\n        self.temporary_data.data = self.cleaned_data\n        self.temporary_data.overall_comments = self.overall_comments\n        self.temporary_data.status = ProposalTemporaryData.Statuses.InOurSide\n        self.temporary_data.save()\n        return self.temporary_data\n\n    def get_overall_comments(self):\n        return self.cleaned_data.get('overall_comments', '')\n\n\nclass SubscriptionForm(forms.Form):\n    def __init__(self, *args, **kwargs):\n        self.user = kwargs.pop('user')\n        self.proposal = kwargs.pop('proposal')\n        super(SubscriptionForm, self).__init__(*args, **kwargs)\n\n    def subscribe(self):\n        like = ProposalLike.objects.create(user=self.user,\n                                           proposal=self.proposal)\n        return like\n\n\nclass AreaForm(forms.Form):\n    area = forms.ChoiceField()\n    explanation_template = \"popular_proposal/steps/select_area.html\"\n\n    def __init__(self, *args, **kwargs):\n        super(AreaForm, self).__init__(*args, **kwargs)\n        self.fields['area'].choices = [(a.id, a.name) for a in Area.objects.all()]\n\n    def clean(self):\n        cleaned_data = super(AreaForm, self).clean()\n        area = Area.objects.get(id=cleaned_data['area'])\n        cleaned_data['area'] = area\n        return cleaned_data\n", "path": "popular_proposal/forms/forms.py"}], "after_files": [{"content": "# coding=utf-8\nfrom django import forms\nfrom popular_proposal.models import (ProposalTemporaryData,\n                                     ProposalLike,\n                                     PopularProposal)\nfrom votainteligente.send_mails import send_mail\nfrom django.utils.translation import ugettext as _\nfrom django.contrib.sites.models import Site\nfrom .form_texts import TEXTS, TOPIC_CHOICES, WHEN_CHOICES\nfrom popolo.models import Area\nfrom collections import OrderedDict\n\n\nclass TextsFormMixin():\n\n    def add_texts_to_fields(self):\n        for field in self.fields:\n            if field in TEXTS.keys():\n                texts = TEXTS[field]\n                if 'label' in texts.keys() and texts['label']:\n                    self.fields[field].label = texts['label']\n                if 'help_text' in texts.keys() and texts['help_text']:\n                    self.fields[field].help_text = texts['help_text']\n                if 'placeholder' in texts.keys() and texts['placeholder']:\n                    self.fields[field].widget.attrs[\n                        'placeholder'] = texts['placeholder']\n                if 'long_text' in texts.keys() and texts['long_text']:\n                    self.fields[field].widget.attrs[\n                        'long_text'] = texts['long_text']\n                if 'step' in texts.keys() and texts['step']:\n                    self.fields[field].widget.attrs['tab_text'] = texts['step']\n\n\ndef get_user_organizations_choicefield(user=None):\n    if user is None or not user.is_authenticated():\n        return None\n\n    if user.enrollments.all():\n        choices = [('', 'Lo har\u00e9 a nombre personal')]\n        for enrollment in user.enrollments.all():\n            choice = (enrollment.organization.id, enrollment.organization.name)\n            choices.append(choice)\n        label = _(u'\u00bfEsta promesa es a nombre de un grupo ciudadano?')\n        return forms.ChoiceField(choices=choices,\n                                 label=label)\n    return None\n\nwizard_forms_fields = [\n    {\n        'template': 'popular_proposal/wizard/form_step.html',\n        'explation_template': \"popular_proposal/steps/paso1.html\",\n        'fields': OrderedDict([\n            ('problem', forms.CharField(max_length=512,\n                                        widget=forms.Textarea(),\n                                        ))\n        ])\n    },\n    {\n        'template': 'popular_proposal/wizard/form_step.html',\n        'explation_template': \"popular_proposal/steps/paso2.html\",\n        'fields': OrderedDict([(\n            'causes', forms.CharField(max_length=256,\n                                      widget=forms.Textarea(),\n                                      )\n\n        )])\n    },\n    {\n        'template': 'popular_proposal/wizard/paso3.html',\n        'explation_template': \"popular_proposal/steps/paso3.html\",\n        'fields': OrderedDict([(\n            'clasification', forms.ChoiceField(choices=TOPIC_CHOICES,\n                                               widget=forms.Select())\n        ), (\n\n            'solution', forms.CharField(max_length=512,\n                                        widget=forms.Textarea(),\n                                        )\n        )])\n    },\n    {\n        'template': 'popular_proposal/wizard/form_step.html',\n        'explation_template': \"popular_proposal/steps/paso4.html\",\n        'fields': OrderedDict([(\n            'solution_at_the_end', forms.CharField(widget=forms.Textarea(),\n                                                   required=False)\n\n        ),\n            ('when', forms.ChoiceField(widget=forms.Select(),\n                                       choices=WHEN_CHOICES))\n        ])\n    },\n    {\n        'template': 'popular_proposal/wizard/paso5.html',\n        'explation_template': \"popular_proposal/steps/paso5.html\",\n        'fields': OrderedDict([\n            ('title', forms.CharField(max_length=256,\n                                      widget=forms.TextInput())),\n            ('organization', get_user_organizations_choicefield),\n            ('terms_and_conditions', forms.BooleanField(\n                error_messages={'required':\n                                _(u'Debes aceptar nuestros T\u00e9rminos y \\\nCondiciones')}\n            )\n            )\n        ])\n    }\n]\n\n\ndef get_form_list(wizard_forms_fields=wizard_forms_fields, **kwargs):\n    form_list = []\n    counter = 0\n    for step in wizard_forms_fields:\n        counter += 1\n        fields_dict = OrderedDict()\n        for field in step['fields']:\n            tha_field = step['fields'][field]\n            if hasattr(tha_field, '__call__'):\n                executed_field = tha_field.__call__(**kwargs)\n                if executed_field is not None:\n                    fields_dict[field] = executed_field\n            else:\n                fields_dict[field] = tha_field\n\n        def __init__(self, *args, **kwargs):\n            super(forms.Form, self).__init__(*args, **kwargs)\n            self.add_texts_to_fields()\n        cls_attrs = {\"__init__\": __init__,\n                     \"explanation_template\": step['explation_template'],\n                     \"template\": step['template']}\n        form_class = type('Step%d' % (counter),\n                          (forms.Form, TextsFormMixin, object), cls_attrs)\n        form_class.base_fields = fields_dict\n        form_list.append(form_class)\n    return form_list\n\n\nclass ProposalFormBase(forms.Form, TextsFormMixin):\n    def set_fields(self):\n        for steps in wizard_forms_fields:\n            for field_name in steps['fields']:\n                field = steps['fields'][field_name]\n                if hasattr(field, '__call__'):\n                    kwargs = {'user': self.proposer}\n                    field = field.__call__(**kwargs)\n                    if field is None:\n                        continue\n                self.fields[field_name] = field\n\n    def __init__(self, *args, **kwargs):\n        self.proposer = kwargs.pop('proposer', None)\n        super(ProposalFormBase, self).__init__(*args, **kwargs)\n        self.set_fields()\n        self.add_texts_to_fields()\n\n\nclass ProposalForm(ProposalFormBase):\n    def __init__(self, *args, **kwargs):\n        self.area = kwargs.pop('area')\n        super(ProposalForm, self).__init__(*args, **kwargs)\n\n    def save(self):\n        t_data = ProposalTemporaryData.objects.create(proposer=self.proposer,\n                                                      area=self.area,\n                                                      data=self.cleaned_data)\n        t_data.notify_new()\n        return t_data\n\n\nclass UpdateProposalForm(forms.ModelForm):\n    def __init__(self, *args, **kwargs):\n        return super(UpdateProposalForm, self).__init__(*args, **kwargs)\n\n    class Meta:\n        model = PopularProposal\n        fields = ['background', 'image']\n        labels = {'background': _(u'M\u00e1s antecedentes sobre tu propuesta.'),\n                  'image': _(u'\u00bfTienes alguna imagen para compartir?')\n                  }\n        help_texts = {'background': _(u'Ejemplo: Durante el a\u00f1o 2011, existi\u00f3 una iniciativa de otra comunidad que no lleg\u00f3 a buen puerto.')}\n\n\nclass CommentsForm(forms.Form):\n    def __init__(self, *args, **kwargs):\n        self.temporary_data = kwargs.pop('temporary_data')\n        self.moderator = kwargs.pop('moderator')\n        super(CommentsForm, self).__init__(*args, **kwargs)\n        for field in self.temporary_data.comments.keys():\n            help_text = _(u'La ciudadana dijo: %s') % self.temporary_data.data.get(field, u'')\n            comments = self.temporary_data.comments[field]\n            if comments:\n                help_text += _(u' <b>Y tus comentarios fueron: %s </b>') % comments\n            self.fields[field] = forms.CharField(required=False, help_text=help_text)\n\n    def save(self, *args, **kwargs):\n        for field_key in self.cleaned_data.keys():\n            self.temporary_data.comments[field_key] = self.cleaned_data[field_key]\n        self.temporary_data.status = ProposalTemporaryData.Statuses.InTheirSide\n        self.temporary_data.save()\n        comments = {}\n        for key in self.temporary_data.data.keys():\n            if self.temporary_data.comments[key]:\n                comments[key] = {\n                    'original': self.temporary_data.data[key],\n                    'comments': self.temporary_data.comments[key]\n                }\n\n        site = Site.objects.get_current()\n        mail_context = {\n            'area': self.temporary_data.area,\n            'temporary_data': self.temporary_data,\n            'moderator': self.moderator,\n            'comments': comments,\n            'site': site,\n\n        }\n        send_mail(mail_context, 'popular_proposal_moderation',\n                  to=[self.temporary_data.proposer.email])\n        return self.temporary_data\n\n\nclass RejectionForm(forms.Form):\n    reason = forms.CharField()\n\n    def __init__(self, *args, **kwargs):\n        self.temporary_data = kwargs.pop('temporary_data')\n        self.moderator = kwargs.pop('moderator')\n        super(RejectionForm, self).__init__(*args, **kwargs)\n\n    def reject(self):\n        self.temporary_data.reject(self.cleaned_data['reason'])\n\n\nclass ProposalTemporaryDataUpdateForm(ProposalFormBase):\n    overall_comments = forms.CharField(required=False, label=_(u'Comentarios sobre tu revis\u00f3n'))\n\n    def __init__(self, *args, **kwargs):\n        self.proposer = kwargs.pop('proposer')\n        self.temporary_data = kwargs.pop('temporary_data')\n        super(ProposalTemporaryDataUpdateForm, self).__init__(*args, **kwargs)\n        self.initial = self.temporary_data.data\n        for comment_key in self.temporary_data.comments.keys():\n            comment = self.temporary_data.comments[comment_key]\n            if comment:\n                self.fields[comment_key].help_text += _(' <b>Commentarios: %s </b>') % (comment)\n\n    def save(self):\n        self.overall_comments = self.cleaned_data.pop('overall_comments')\n        self.temporary_data.data = self.cleaned_data\n        self.temporary_data.overall_comments = self.overall_comments\n        self.temporary_data.status = ProposalTemporaryData.Statuses.InOurSide\n        self.temporary_data.save()\n        return self.temporary_data\n\n    def get_overall_comments(self):\n        return self.cleaned_data.get('overall_comments', '')\n\n\nclass SubscriptionForm(forms.Form):\n    def __init__(self, *args, **kwargs):\n        self.user = kwargs.pop('user')\n        self.proposal = kwargs.pop('proposal')\n        super(SubscriptionForm, self).__init__(*args, **kwargs)\n\n    def subscribe(self):\n        like = ProposalLike.objects.create(user=self.user,\n                                           proposal=self.proposal)\n        return like\n\n\nclass AreaForm(forms.Form):\n    area = forms.ChoiceField()\n    explanation_template = \"popular_proposal/steps/select_area.html\"\n\n    def __init__(self, *args, **kwargs):\n        super(AreaForm, self).__init__(*args, **kwargs)\n        self.fields['area'].choices = [(a.id, a.name) for a in Area.objects.all()]\n\n    def clean(self):\n        cleaned_data = super(AreaForm, self).clean()\n        area = Area.objects.get(id=cleaned_data['area'])\n        cleaned_data['area'] = area\n        return cleaned_data\n", "path": "popular_proposal/forms/forms.py"}]}