Browse Source

comment with link to photos required for new connection request

vross 6 years ago
parent
commit
96230ee861
1 changed files with 9 additions and 0 deletions
  1. 9 0
      wifiwithme/apps/contribmap/forms.py

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

@@ -2,6 +2,8 @@ from django import forms
 
 from .models import Contrib
 
+import re
+
 
 ORIENTATIONS = (
     ('N', 'Nord'),
@@ -72,11 +74,18 @@ class PublicContribForm(forms.ModelForm):
             if data.get('access_type') == '':
                 self.add_error('access_type', 'Ce champ est requis')
 
+    #tetaneutral.net: comment with link to photos required for new connection request
+    def _validate_comment(self, data):
+        if data.get('contrib_type') == Contrib.CONTRIB_CONNECT and re.search('https?://', data.get('comment')) is None:
+            self.add_error('comment', 'Des photos de la vue depuis votre toit ou balcon sont nécessaires pour déterminer votre éligibilité à une connexion radio. Vous pouvez les déposer chez un hébergeur (par exemple https://framapic.org ) et mettre le lien d\'accès à ces photos ici.')
+
     def clean(self):
         cleaned_data = super().clean()
         self._validate_contact_information(cleaned_data)
         self._validate_floors(cleaned_data)
         self._validate_share_fields(cleaned_data)
+        #tetaneutral.net: comment with link to photos required for new connection request
+        self._validate_comment(cleaned_data)
         return cleaned_data
 
     def privacy_fields(self):