From ae016dba63ffa329a69f25f0746fceb2d06af677 Mon Sep 17 00:00:00 2001
From: Benjamin Dauvergne fie
+Les différentes géolocalisation associées au formulaire sont listés dans l'attribut
+geolocations
. Pour l'instant il n'en existe qu'une toujours nommée base
.
+
Concernant les rôles et fonctions de workflow, les différents intervenants sont
listés dans l'attribut roles
, en différentes séries qui vont
dépendre de fonctions attachées au workflow. Deux séries sont particulières,
diff --git a/tests/test_api.py b/tests/test_api.py
index 23ca492..e463b0c 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -772,6 +772,7 @@ def test_formdata(pub, local_user):
another_role.store()
FormDef.wipe()
formdef = FormDef()
+ formdef.geolocations = {'base': 'blah'}
formdef.name = 'test'
formdef.fields = [
fields.StringField(id='0', label='foobar', varname='foobar'),
@@ -811,6 +812,7 @@ def test_formdata(pub, local_user):
formdata.just_created()
formdata.status = 'wf-new'
formdata.evolution[-1].status = 'wf-new'
+ formdata.geolocations = {'base': {'lon': 10, 'lat': -12}}
formdata.store()
resp = get_app(pub).get(
@@ -838,6 +840,8 @@ def test_formdata(pub, local_user):
assert resp.json['fields']['item_structured'] == {'id': '1', 'text': 'foo', 'more': 'XXX'}
assert resp.json['workflow']['status']['name'] == 'New'
assert resp.json['submission']['channel'] == 'web'
+ assert resp.json['geolocations']['base']['lon'] == 10
+ assert resp.json['geolocations']['base']['lat'] == -12
assert [x.get('id') for x in resp.json['roles']['_receiver']] == [str(role.id)]
assert [x.get('id') for x in resp.json['roles']['_foobar']] == [str(another_role.id)]
diff --git a/wcs/formdata.py b/wcs/formdata.py
index a1bf678..c63433e 100644
--- a/wcs/formdata.py
+++ b/wcs/formdata.py
@@ -780,6 +780,11 @@ class FormData(StorableObject):
evolution.append(evo.get_json_export_dict(None if anonymise else user,
anonymise=anonymise))
+ if self.geolocations:
+ data['geolocations'] = {}
+ for k, v in self.geolocations.iteritems():
+ data['geolocations'][k] = v.copy()
+
return data
def export_to_json(self, include_files=True, anonymise=False):
--
2.1.4