0001-export-geolocations-in-forms-API-fixes-13483.patch
help/fr/api-get.page | ||
---|---|---|
48 | 48 |
"nom": "L.", |
49 | 49 |
"prenom": "Marc" |
50 | 50 |
}, |
51 |
"geolocations": { |
|
52 |
"base": { |
|
53 |
"lat": 10, |
|
54 |
"lon": -12, |
|
55 |
} |
|
56 |
}, |
|
51 | 57 |
"user": { |
52 | 58 |
"id": 1, |
53 | 59 |
"name": "Fred" |
... | ... | |
143 | 149 |
</p> |
144 | 150 | |
145 | 151 |
<p> |
152 |
Les différentes géolocalisation associées au formulaire sont listés dans l'attribut |
|
153 |
<code>geolocations</code>. Pour l'instant il n'en existe qu'une toujours nommée <code>base</code>. |
|
154 |
</p> |
|
155 | ||
156 |
<p> |
|
146 | 157 |
Concernant les rôles et fonctions de workflow, les différents intervenants sont |
147 | 158 |
listés dans l'attribut <code>roles</code>, en différentes séries qui vont |
148 | 159 |
dépendre de fonctions attachées au workflow. Deux séries sont particulières, |
tests/test_api.py | ||
---|---|---|
772 | 772 |
another_role.store() |
773 | 773 |
FormDef.wipe() |
774 | 774 |
formdef = FormDef() |
775 |
formdef.geolocations = {'base': 'blah'} |
|
775 | 776 |
formdef.name = 'test' |
776 | 777 |
formdef.fields = [ |
777 | 778 |
fields.StringField(id='0', label='foobar', varname='foobar'), |
... | ... | |
811 | 812 |
formdata.just_created() |
812 | 813 |
formdata.status = 'wf-new' |
813 | 814 |
formdata.evolution[-1].status = 'wf-new' |
815 |
formdata.geolocations = {'base': {'lon': 10, 'lat': -12}} |
|
814 | 816 |
formdata.store() |
815 | 817 | |
816 | 818 |
resp = get_app(pub).get( |
... | ... | |
838 | 840 |
assert resp.json['fields']['item_structured'] == {'id': '1', 'text': 'foo', 'more': 'XXX'} |
839 | 841 |
assert resp.json['workflow']['status']['name'] == 'New' |
840 | 842 |
assert resp.json['submission']['channel'] == 'web' |
843 |
assert resp.json['geolocations']['base']['lon'] == 10 |
|
844 |
assert resp.json['geolocations']['base']['lat'] == -12 |
|
841 | 845 | |
842 | 846 |
assert [x.get('id') for x in resp.json['roles']['_receiver']] == [str(role.id)] |
843 | 847 |
assert [x.get('id') for x in resp.json['roles']['_foobar']] == [str(another_role.id)] |
wcs/formdata.py | ||
---|---|---|
780 | 780 |
evolution.append(evo.get_json_export_dict(None if anonymise else user, |
781 | 781 |
anonymise=anonymise)) |
782 | 782 | |
783 |
if self.geolocations: |
|
784 |
data['geolocations'] = {} |
|
785 |
for k, v in self.geolocations.iteritems(): |
|
786 |
data['geolocations'][k] = v.copy() |
|
787 | ||
783 | 788 |
return data |
784 | 789 | |
785 | 790 |
def export_to_json(self, include_files=True, anonymise=False): |
786 |
- |