0001-backoffice-do-not-propose-block-subfields-for-column.patch
tests/backoffice_pages/test_all.py | ||
---|---|---|
824 | 824 |
} in resp_geojson.json['features'][0]['properties']['display_fields'] |
825 | 825 | |
826 | 826 | |
827 |
def test_backoffice_block_columns(pub): |
|
828 |
create_environment(pub) |
|
829 |
create_superuser(pub) |
|
830 | ||
831 |
BlockDef.wipe() |
|
832 |
block = BlockDef() |
|
833 |
block.name = 'foobar' |
|
834 |
block.fields = [ |
|
835 |
fields.StringField(id='123', required=True, label='Test', type='string'), |
|
836 |
] |
|
837 |
block.store() |
|
838 | ||
839 |
formdef = FormDef.get_by_urlname('form-title') |
|
840 |
formdef.fields.append( |
|
841 |
fields.BlockField(id='8', label='Block', type='block:foobar', varname='data', max_items=3), |
|
842 |
) |
|
843 |
formdef.store() |
|
844 | ||
845 |
for formdata in formdef.data_class().select(lambda x: x.status == 'wf-new'): |
|
846 |
formdata.data['8'] = { |
|
847 |
'data': [{'123': 'blah'}], |
|
848 |
'schema': {'123': 'string'}, |
|
849 |
} |
|
850 |
formdata.data['8_display'] = 'blah' |
|
851 |
formdata.store() |
|
852 | ||
853 |
app = login(get_app(pub)) |
|
854 |
resp = app.get('/backoffice/management/form-title/') |
|
855 |
# check Block / Test is not part of the possible columns |
|
856 |
assert [x.text_content() for x in resp.pyquery('#columns-filter label')] == [ |
|
857 |
'Number', |
|
858 |
'Created', |
|
859 |
'Last Modified', |
|
860 |
'User Label', |
|
861 |
'1st field', |
|
862 |
'2nd field', |
|
863 |
'Status', |
|
864 |
'3rd field', |
|
865 |
'Block', |
|
866 |
'Anonymised', |
|
867 |
] |
|
868 | ||
869 | ||
827 | 870 |
def test_backoffice_form_category_permissions(pub): |
828 | 871 |
user = create_user(pub) |
829 | 872 |
create_environment(pub) |
tests/backoffice_pages/test_filters.py | ||
---|---|---|
794 | 794 | |
795 | 795 |
app = login(get_app(pub)) |
796 | 796 |
resp = app.get('/backoffice/management/form-title/') |
797 |
assert '<label><input type="checkbox" name="1"/>Block Data / String</label>' in resp |
|
798 |
assert '<label><input type="checkbox" name="2"/>Block Data / Item</label>' in resp |
|
799 |
assert '<label><input type="checkbox" name="3"/>Block Data / Bool</label>' in resp |
|
800 |
assert '<label><input type="checkbox" name="4"/>Block Data / Date</label>' in resp |
|
801 |
assert '<label><input type="checkbox" name="5"/>Block Data / Email</label>' in resp |
|
797 |
# block subfields should not be proposed as columns |
|
798 |
assert '<label><input type="checkbox" name="1"/>Block Data / String</label>' not in resp |
|
799 |
assert '<label><input type="checkbox" name="2"/>Block Data / Item</label>' not in resp |
|
800 |
assert '<label><input type="checkbox" name="3"/>Block Data / Bool</label>' not in resp |
|
801 |
assert '<label><input type="checkbox" name="4"/>Block Data / Date</label>' not in resp |
|
802 |
assert '<label><input type="checkbox" name="5"/>Block Data / Email</label>' not in resp |
|
802 | 803 | |
803 | 804 |
# string |
804 | 805 |
resp = app.get('/backoffice/management/form-title/') |
wcs/backoffice/management.py | ||
---|---|---|
1335 | 1335 |
for field in sorted(self.get_formdef_fields(), key=get_column_position): |
1336 | 1336 |
if not hasattr(field, 'get_view_value'): |
1337 | 1337 |
continue |
1338 |
if getattr(field, 'block_field', None): |
|
1339 |
# fields from blocks cannot yet be added as column |
|
1340 |
continue |
|
1338 | 1341 |
classnames = '' |
1339 | 1342 |
attrs = '' |
1340 | 1343 |
if isinstance(field, RelatedField): |
1341 |
- |