Browse Source

Reintegrate form parts show/hide

Jocelyn Delande 9 years ago
parent
commit
9f737fb58b

+ 1 - 0
wifiwithme/apps/contribmap/forms.py

@@ -21,6 +21,7 @@ class PublicContribForm(forms.ModelForm):
             'privacy_place_details', 'privacy_comment',
         ]
         widgets = {
+            'contrib_type': forms.RadioSelect,
             'latitude': forms.HiddenInput,
             'longitude': forms.HiddenInput,
         }

+ 1 - 1
wifiwithme/apps/contribmap/models.py

@@ -21,7 +21,7 @@ class Contrib(models.Model):
         max_length=10, choices=(
             (CONTRIB_CONNECT, 'Me raccorder au réseau expérimental'),
             (CONTRIB_SHARE, 'Partager une partie de ma connexion')
-        ))
+        ), default=None)
     latitude = models.FloatField(blank=True, null=True)
     longitude = models.FloatField(blank=True, null=True)
     phone = models.CharField(

+ 3 - 3
wifiwithme/static/form.js

@@ -100,12 +100,12 @@ $( document ).ready(function() {
 
 
     // Contrib share dynamic form
-    if ($('[name="contrib-type"]:checked').val() == 'share') { $('#contrib-type-share').show(); }
+    if ($('[name="contrib_type"]:checked').val() == 'share') { $('#contrib-type-share').show(); }
     else { $('#contrib-type-share').hide(); }
-    if ($('[name="contrib-type"]:checked').val() == 'connect') { $('#contrib-type-connect').show(); }
+    if ($('[name="contrib_type"]:checked').val() == 'connect') { $('#contrib-type-connect').show(); }
     else { $('#contrib-type-connect').hide(); }
     // On change
-    $('[name="contrib-type"]').change(function(e){
+    $('[name="contrib_type"]').change(function(e){
         $('#contrib-type-share').slideUp();
         $('#contrib-type-connect').slideUp();
         if ($(this).val() == 'share') { $('#contrib-type-share').slideDown(); }