wcs : gestion du type ItemsField et des champs optionnels
authorProgfou <jean-christophe.andre@auf.org>
Wed, 4 May 2011 20:38:22 +0000 (03:38 +0700)
committerProgfou <jean-christophe.andre@auf.org>
Wed, 4 May 2011 20:38:22 +0000 (03:38 +0700)
wcs/wcs-extract
wcs/wcs-extract-all

index 08da8c1..1147ba2 100755 (executable)
@@ -22,7 +22,7 @@ import mimetypes
 from wcs import publisher
 from wcs.formdef import FormDef
 from wcs.fields import TitleField, CommentField, TextField, \
-                       StringField, ItemField, EmailField, \
+                       StringField, ItemField, ItemsField, EmailField, \
                        DateField, FileField, BoolField
 
 
@@ -125,17 +125,20 @@ def extract_data(formdef, output_directory):
                 continue
             field_name = field_names[field_id]
             data = object.data.get(field_id)
+            if data is None:
+                result[field_name] = None
+                continue
             if isinstance(field, StringField) or isinstance(field, TextField) \
             or isinstance(field, EmailField) or isinstance(field, ItemField):
                 result[field_name] = data
+            elif isinstance(field, ItemsField):
+                result[field_name] = data # liste => peux-être joindre sur ';'
             elif isinstance(field, BoolField):
                 result[field_name] = (data == 'True')
             elif isinstance(field, DateField):
                 result[field_name] = '%04d-%02d-%02d' % (data.tm_year,
                                                     data.tm_mon, data.tm_mday)
             elif isinstance(field, FileField):
-                if data is None:
-                    continue
                 if '.' in data.orig_filename:
                     extension = data.orig_filename.rpartition('.')[2].lower()
                 else: # il n'y a pas d'extension dans le nom de fichier
index 097c3ba..fa14f8a 100755 (executable)
@@ -5,6 +5,8 @@ if [ "`id -un`" != "root" ] ; then
 fi
 
 WCS_USER="wcs"
+[ -r /etc/default/wcs ] && . /etc/default/wcs
+
 OUTPUT_USER="wcs-export"
 SITE="formulaires.auf.org"
 FORMS="`su -s /bin/sh -c "ls -d $SITE/form-demande-* | sed 's|^.*/form-||'" -l "$WCS_USER"`"