Commits

hirunatan committed 8cd1313

Add hints to entity proposal form

  • Participants
  • Parent commits 9daa063

Comments (0)

Files changed (4)

src/macadjan_base/forms.py

 from django.forms import formsets
 from captcha.fields import CaptchaField
 from macadjan_base import models
+from django.contrib.sites.models import Site
 from django.utils.translation import ugettext_lazy as _
 
 class MapArgumentsForm(forms.Form):
     captcha = CaptchaField(
             label = _(u'Clave de seguridad'),
             help_text = _(u'Introduce el texto que ves en la imagen (esto es para evitar spam).'))
+
     class Meta:
         model = models.EntityProposal
         exclude = ('existing_entity', 'status', 'status_info', 'creation_date', 'modification_date', 'map_source')
 
+    def __init__(self, *args, **kwargs):
+        super(EntityProposalForm, self).__init__(*args, **kwargs)
+        hints = self.get_current_hints()
+        for name, field in self.fields.items():
+            field.hints = hints.get(name, u'')
+
+    def get_current_hints(self):
+        current_site = Site.objects.get_current()
+        try:
+            site_info = current_site.site_info
+            return {
+                "description": site_info.description_hints,
+                "goals": site_info.goals_hints,
+                "finances": site_info.finances_hints,
+                "social_values": site_info.social_values_hints,
+                "how_to_access": site_info.how_to_access_hints,
+                "networks_member": site_info.networks_member_hints,
+                "networks_works_with": site_info.networks_works_with_hints,
+                "ongoing_projects": site_info.ongoing_projects_hints,
+                "needs": site_info.needs_hints,
+                "offerings": site_info.offerings_hints,
+                "additional_info": site_info.additional_info_hints,
+            }
+        except models.SiteInfo.DoesNotExist:
+            return {}
+

src/macadjan_base/models.py

 proponer cambios.
 '''))
 
+    description_hints = models.TextField(null = False, blank = True, default = '',
+            verbose_name = _(u'Ayuda para Descripción'))
+    goals_hints = models.TextField(null = False, blank = True, default = '',
+            verbose_name = _(u'Ayuda para Objetivo como entidad'))
+    finances_hints = models.TextField(null = False, blank = True, default = '',
+            verbose_name = _(u'Ayuda para Finanzas'))
+    social_values_hints = models.TextField(null = False, blank = True, default = '',
+            verbose_name = _(u'Ayuda para Valores sociales y medioambientales'))
+    how_to_access_hints = models.TextField(null = False, blank = True, default = '',
+            verbose_name = _(u'Ayuda para Forma de acceso'))
+    networks_member_hints = models.TextField(null = False, blank = True, default = '',
+            verbose_name = _(u'Ayuda para Redes de las que forma parte'))
+    networks_works_with_hints = models.TextField(null = False, blank = True, default = '',
+            verbose_name = _(u'Ayuda para Otras entidades con las que colabora'))
+    ongoing_projects_hints = models.TextField(null = False, blank = True, default = '',
+            verbose_name = _(u'Ayuda para Proyectos en marcha'))
+    needs_hints = models.TextField(null = False, blank = True, default = '',
+            verbose_name = _(u'Ayuda para Necesidades'))
+    offerings_hints = models.TextField(null = False, blank = True, default = '',
+            verbose_name = _(u'Ayuda para Qué ofrece'))
+    additional_info_hints = models.TextField(null = False, blank = True, default = '',
+            verbose_name = _(u'Ayuda para Información adicional'))
+
     def __unicode__(self):
         return self.website_name
 

src/macadjan_base/templates/macadjan_base/new_entity_proposal.html

 
 {% block content %}
     <iframe src="{% url "base:new-entity-proposal-iframe" %}"
-        frameborder="0" scrolling="no" width="100%" height="5000em">
+        frameborder="0" scrolling="auto" width="100%" height="5000px">
         {% trans "Debes tener un navegador que soporte iframes para poder ver el formulario." %}
     </iframe>
 {% endblock %}

src/macadjan_base/templates/macadjan_base/new_entity_proposal_iframe.html

     <meta charset="utf-8" />
     <title>{% trans 'Proponer nueva entidad' %} - {{ current_site_info.website_name }}</title>
     <link type="text/css" rel="stylesheet" media="screen" href="{{ STATIC_URL }}{{ current_theme.styles_url }}/styles_iframe.css" />
+    <script type="text/javascript" src="{{ STATIC_URL }}macadjan_base/scripts/jquery-1.6.2.min.js"></script>
 </head>
 
 <body>
                         </td>
                         <td class="help_text">
                             {{ field.help_text }}
+                            {% if field.field.hints %}
+                                <br/>
+                                <a href="#" id="open_hint_{{ field.name }}">{% trans 'Más ayuda' %}</a>
+                                <a href="#" id="close_hint_{{ field.name }}">{% trans 'Cerrar' %}</a>
+                                <div id="hint_content_{{ field.name }}">
+                                    <p>{{ field.field.hints|linebreaksbr }}</p>
+                                </div>
+                                <script>
+                                    $("#close_hint_{{ field.name }}").hide();
+                                    $("#hint_content_{{ field.name }}").hide();
+                                    $('#open_hint_{{ field.name }}').click(function(){
+                                        $("#open_hint_{{ field.name }}").hide();
+                                        $("#close_hint_{{ field.name }}").show();
+                                        $("#hint_content_{{ field.name }}").show();
+                                    });
+                                    $('#close_hint_{{ field.name }}').click(function(){
+                                        $("#open_hint_{{ field.name }}").show();
+                                        $("#close_hint_{{ field.name }}").hide();
+                                        $("#hint_content_{{ field.name }}").hide();
+                                    });
+                                </script>
+                            {% endif %}
                         </td>
                     </tr>
                 {% endfor %}