[Devel] r191 - scripts

svn at agendadulibre.org svn at agendadulibre.org
Mar 19 Sep 00:00:08 CEST 2006


Author: thomas
Date: Tue Sep 19 00:00:07 2006
New Revision: 191

Modified:
   scripts/adl-submit.py

Log:
- Support du champ 'submitter'
- Amélioration de la vérification des champs présents/absents



Modified: scripts/adl-submit.py
==============================================================================
--- scripts/adl-submit.py	(original)
+++ scripts/adl-submit.py	Tue Sep 19 00:00:07 2006
@@ -26,7 +26,7 @@
 
 eventFields = [ "title", "start-date", "end-date", "start-hour",
                 "end-hour", "description", "city", "region",
-                "url", "contact" ]
+                "url", "contact", "submitter" ]
 
 regions = {
    u'Alsace'               : 1,
@@ -192,13 +192,17 @@
 
 def SubmitEvent(event, testOutputFile):
 
-    if event.has_key ("start-date") is False:
-        print u"La date de début de l'évènement n'est pas spécifiée"
-        return
-
-    if event.has_key ("end-date") is False:
+    if not event.has_key ("end-date") and event.has_key('start-date'):
         event ["end-date"] = event ["start-date"]
 
+    if not event.has_key("submitter") and event.has_key('contact'):
+        event ['submitter'] = event['contact']
+
+    for field in eventFields:
+        if not event.has_key(field):
+            print u"Le champ '%s' n'est pas renseigné" % field
+            return
+
     if re.compile(r'^[^\<\>]*$').search (event['title']) is None:
         print u"Problème de formatage dans le titre: '%s'. Les tags HTML ne sont pas autorisés." % event['title']
         return
@@ -264,6 +268,10 @@
         print u"ERREUR: Problème de formatage dans l'adresse e-mail." % event ['contact']
         return
 
+    if re.compile(r'^([A-Za-z0-9_\.\-]*)@([A-Za-z0-9_\-]*)\.([A-Za-z0-9_\.\-]*)$').search (event['submitter']) is None:
+        print u"ERREUR: Problème de formatage dans l'adresse e-mail." % event ['submitter']
+        return
+
     curl = pycurl.Curl()
 
     contents = StringIO.StringIO()
@@ -291,6 +299,7 @@
                                  ('__event_locality',     str(0)),
                                  ('__event_url',          str(event['url'])),
                                  ('__event_contact',      str(event['contact'])),
+                                 ('__event_submitter',    str(event['submitter'])),
                                  ('__event_save',         str(1))])
 
     curl.perform()


Plus d'informations sur la liste de diffusion Devel