0001-fields-add-support-for-autocomplete-fields-in-blocks.patch
tests/test_form_pages.py | ||
---|---|---|
8378 | 8378 |
assert '>2020-06-16<' in resp |
8379 | 8379 | |
8380 | 8380 | |
8381 |
def test_block_autocomplete_list(pub, blocks_feature): |
|
8382 |
create_user(pub) |
|
8383 |
FormDef.wipe() |
|
8384 |
BlockDef.wipe() |
|
8385 | ||
8386 |
block = BlockDef() |
|
8387 |
block.name = 'foobar' |
|
8388 |
block.fields = [ |
|
8389 |
fields.StringField(id='123', required=True, label='Test', type='string'), |
|
8390 |
fields.ItemField(id='234', required=True, label='Test2', type='item', |
|
8391 |
display_mode='autocomplete', items=['Foo', 'Bar']), |
|
8392 |
] |
|
8393 |
block.store() |
|
8394 | ||
8395 |
formdef = FormDef() |
|
8396 |
formdef.name = 'form title' |
|
8397 |
formdef.fields = [ |
|
8398 |
fields.BlockField(id='1', label='test', type='block:foobar'), |
|
8399 |
] |
|
8400 |
formdef.store() |
|
8401 | ||
8402 |
app = get_app(pub) |
|
8403 |
resp = app.get(formdef.get_url()) |
|
8404 |
resp.form['f1$element0$f123'] = 'foo' |
|
8405 |
resp.form['f1$element0$f234'] = 'Bar' |
|
8406 |
resp = resp.form.submit('submit') # -> validation page |
|
8407 |
assert 'Check values then click submit.' in resp.text |
|
8408 |
resp = resp.form.submit('submit') # -> submit |
|
8409 |
resp = resp.follow() |
|
8410 |
assert '>Bar<' in resp |
|
8411 | ||
8412 | ||
8381 | 8413 |
def test_block_multipage(pub, blocks_feature): |
8382 | 8414 |
create_user(pub) |
8383 | 8415 |
FormDef.wipe() |
wcs/blocks.py | ||
---|---|---|
239 | 239 | |
240 | 240 |
def add_media(self): |
241 | 241 |
for widget in self.get_widgets(): |
242 |
widget.add_media() |
|
242 |
if hasattr(widget, 'add_media'): |
|
243 |
widget.add_media() |
|
243 | 244 | |
244 | 245 | |
245 | 246 |
class BlockWidget(WidgetList): |
wcs/fields.py | ||
---|---|---|
1545 | 1545 |
get_request().form[self.field_key + '_label'] = label_value # :/ |
1546 | 1546 |
form.add(StringWidget, self.field_key + '_label', title = self.label, |
1547 | 1547 |
value=label_value, readonly='readonly', size=len(label_value or '')+2) |
1548 |
form.get_widget(self.field_key + '_label').field = self |
|
1548 | 1549 |
form.add(HiddenWidget, self.field_key, value=real_value) |
1550 |
form.get_widget(self.field_key).field = self |
|
1549 | 1551 |
widget = form.get_widget(self.field_key + '_label') |
1550 | 1552 |
if self.extra_css_class: |
1551 | 1553 |
if hasattr(widget, 'extra_css_class') and widget.extra_css_class: |
1552 |
- |