0001-api-include-a-display_fields-attribute-in-global-geo.patch
tests/test_backoffice_pages.py | ||
---|---|---|
2836 | 2836 |
assert len(resp.json['features']) == 17 |
2837 | 2837 |
assert resp.json['features'][0]['geometry']['coordinates'] == [2.32, 48.83] |
2838 | 2838 |
for feature in resp.json['features']: |
2839 |
assert 'display_fields' in feature['properties'] |
|
2840 | 2839 |
assert feature['properties']['status_colour'] == '#66FF00' |
2841 | 2840 |
assert feature['properties']['view_label'] == 'View' |
2842 | 2841 |
assert feature['properties']['status_name'] == 'New' |
2842 |
assert feature['properties']['display_fields'] |
|
2843 |
assert feature['properties']['display_fields'][0]['label'] == 'Name' |
|
2844 |
assert feature['properties']['display_fields'][0]['value'].startswith('form title #') |
|
2843 | 2845 | |
2844 | 2846 |
resp = app.get('/backoffice/management/geojson?q=aa') |
2845 | 2847 |
assert len(resp.json['features']) == 5 |
wcs/backoffice/management.py | ||
---|---|---|
103 | 103 |
'url': formdata_backoffice_url, |
104 | 104 |
'status_name': str(htmlescape(status.name)), |
105 | 105 |
'status_colour': '#%s' % status_colour, |
106 |
'display_fields': display_fields, |
|
107 | 106 |
'view_label': _('View'), |
108 | 107 |
}, |
109 | 108 |
'geometry': { |
... | ... | |
111 | 110 |
'coordinates': [coords['lon'], coords['lat']], |
112 | 111 |
} |
113 | 112 |
} |
113 |
if display_fields: |
|
114 |
feature['properties']['display_fields'] = display_fields |
|
114 | 115 |
geojson['features'].append(feature) |
115 | 116 | |
116 | 117 |
return geojson |
... | ... | |
959 | 960 |
from wcs import sql |
960 | 961 |
criterias = self.get_global_listing_criterias() |
961 | 962 |
formdatas = sql.AnyFormData.select(criterias) |
962 | ||
963 |
fields = [ |
|
964 |
FakeField('name', 'display_name', _('Name')), |
|
965 |
FakeField('status', 'status', _('Status')), |
|
966 |
] |
|
963 | 967 |
get_response().set_content_type('application/json') |
964 |
return json.dumps(geojson_formdatas(formdatas)) |
|
968 |
return json.dumps(geojson_formdatas(formdatas, fields=fields))
|
|
965 | 969 | |
966 | 970 |
def map(self): |
967 | 971 |
if not get_publisher().is_using_postgresql(): |
wcs/formdata.py | ||
---|---|---|
603 | 603 |
# field types that are shortcuts to internal properties. |
604 | 604 |
if field.type == 'id': |
605 | 605 |
return self.get_display_id() |
606 |
if field.type == 'display_name': |
|
607 |
return self.get_display_name() |
|
606 | 608 |
if field.type == 'time': |
607 | 609 |
return qommon.misc.localstrftime(self.receipt_time) |
608 | 610 |
if field.type == 'last_update_time': |
609 |
- |