customviews: fix filtering with in operator on item field with carddef (#78780)
gitea/wcs/pipeline/head This commit looks good
Details
gitea/wcs/pipeline/head This commit looks good
Details
This commit is contained in:
parent
dba0876fe7
commit
3e57131626
|
@ -1552,6 +1552,12 @@ def test_dynamic_item_fields_from_custom_view_on_cards(pub):
|
|||
fields.ItemField(
|
||||
id='2', label='Card', varname='card', data_source={'type': 'carddef:%s' % carddef1.url_name}
|
||||
),
|
||||
fields.ItemField(
|
||||
id='3',
|
||||
label='Card bis',
|
||||
varname='card_bis',
|
||||
data_source={'type': 'carddef:%s' % carddef1.url_name},
|
||||
),
|
||||
]
|
||||
carddef2.store()
|
||||
carddef2.data_class().wipe()
|
||||
|
@ -1574,6 +1580,8 @@ def test_dynamic_item_fields_from_custom_view_on_cards(pub):
|
|||
'1': 'Bar 1',
|
||||
'2': str(carddata11.id),
|
||||
'2_display': 'Foo 1',
|
||||
'3': str(carddata11.id),
|
||||
'3_display': 'Foo 1',
|
||||
}
|
||||
carddata21.just_created()
|
||||
carddata21.store()
|
||||
|
@ -1582,6 +1590,8 @@ def test_dynamic_item_fields_from_custom_view_on_cards(pub):
|
|||
'1': 'Bar 1',
|
||||
'2': str(carddata12.id),
|
||||
'2_display': 'Foo 2',
|
||||
'3': str(carddata11.id),
|
||||
'3_display': 'Foo 1',
|
||||
}
|
||||
carddata22.just_created()
|
||||
carddata22.store()
|
||||
|
@ -1618,6 +1628,49 @@ def test_dynamic_item_fields_from_custom_view_on_cards(pub):
|
|||
assert pub.loggederror_class.count() == 0
|
||||
assert '<li class="warning">Invalid value' not in resp
|
||||
|
||||
# add a filter on third field
|
||||
# EQ operator
|
||||
custom_view.filters = {
|
||||
'filter-2': 'on',
|
||||
'filter-2-value': '{{ form_var_card }}',
|
||||
'filter-3': 'on',
|
||||
'filter-3-value': str(carddata11.id),
|
||||
'filter-3-operator': 'eq',
|
||||
}
|
||||
custom_view.store()
|
||||
resp = get_app(pub).get('/test/', status=200)
|
||||
# just check options
|
||||
assert resp.form['f1'].options == [('1', False, 'Foo 1'), ('2', False, 'Foo 2')]
|
||||
assert resp.form['f2'].options == [('', False, '---')]
|
||||
assert pub.loggederror_class.count() == 0
|
||||
assert '<li class="warning">Invalid value' not in resp
|
||||
|
||||
# IN operator
|
||||
custom_view.filters.update(
|
||||
{
|
||||
'filter-3-operator': 'in',
|
||||
}
|
||||
)
|
||||
custom_view.store()
|
||||
resp = get_app(pub).get('/test/', status=200)
|
||||
|
||||
# BETWEEN operator
|
||||
custom_view.filters.update(
|
||||
{
|
||||
'filter-3-operator': 'in',
|
||||
}
|
||||
)
|
||||
custom_view.store()
|
||||
resp = get_app(pub).get('/test/', status=200)
|
||||
custom_view.filters.update(
|
||||
{
|
||||
'filter-3-operator': 'in',
|
||||
'filter-3-value': '%s|%s' % (carddata11.id, carddata12.id),
|
||||
}
|
||||
)
|
||||
custom_view.store()
|
||||
resp = get_app(pub).get('/test/', status=200)
|
||||
|
||||
|
||||
def test_dynamic_items_field_from_custom_view_on_cards(pub):
|
||||
pub.role_class.wipe()
|
||||
|
|
|
@ -2099,7 +2099,7 @@ class FormPage(FormdefDirectoryBase):
|
|||
field=filter_field,
|
||||
)
|
||||
)
|
||||
if filter_field.key in ('item', 'items'):
|
||||
if filter_field.key in ('item', 'items') and isinstance(filter_field_value, (str, int)):
|
||||
criterias[-1]._label = '%s: %s' % (
|
||||
filter_field.label,
|
||||
filter_field.get_display_value(filter_field_value),
|
||||
|
|
Loading…
Reference in New Issue