0002-fields-add-support-for-inert-fields-in-blocks-44760.patch
tests/test_form_pages.py | ||
---|---|---|
8410 | 8410 |
assert '>Bar<' in resp |
8411 | 8411 | |
8412 | 8412 | |
8413 |
def test_block_title_and_comment(pub, blocks_feature): |
|
8414 |
create_user(pub) |
|
8415 |
FormDef.wipe() |
|
8416 |
BlockDef.wipe() |
|
8417 | ||
8418 |
block = BlockDef() |
|
8419 |
block.name = 'foobar' |
|
8420 |
block.fields = [ |
|
8421 |
fields.StringField(id='123', required=True, label='Test', type='string'), |
|
8422 |
fields.TitleField(id='234', label='Blah', type='title'), |
|
8423 |
fields.CommentField(id='345', label='Blah', type='comment'), |
|
8424 |
] |
|
8425 |
block.store() |
|
8426 | ||
8427 |
formdef = FormDef() |
|
8428 |
formdef.name = 'form title' |
|
8429 |
formdef.fields = [ |
|
8430 |
fields.BlockField(id='1', label='test', type='block:foobar'), |
|
8431 |
] |
|
8432 |
formdef.store() |
|
8433 | ||
8434 |
app = get_app(pub) |
|
8435 |
resp = app.get(formdef.get_url()) |
|
8436 |
resp.form['f1$element0$f123'] = 'foo' |
|
8437 |
resp = resp.form.submit('submit') # -> validation page |
|
8438 |
assert 'Check values then click submit.' in resp.text |
|
8439 |
resp = resp.form.submit('submit') # -> submit |
|
8440 |
resp = resp.follow() |
|
8441 | ||
8442 | ||
8413 | 8443 |
def test_block_multipage(pub, blocks_feature): |
8414 | 8444 |
create_user(pub) |
8415 | 8445 |
FormDef.wipe() |
wcs/blocks.py | ||
---|---|---|
218 | 218 | |
219 | 219 |
def set_value(self, value): |
220 | 220 |
for widget in self.get_widgets(): |
221 |
widget.set_value(value.get(widget.field.id)) |
|
221 |
if hasattr(widget, 'set_value'): |
|
222 |
widget.set_value(value.get(widget.field.id)) |
|
222 | 223 | |
223 | 224 |
def get_field_data(self, field, widget): |
224 | 225 |
from wcs.formdef import FormDef |
wcs/fields.py | ||
---|---|---|
650 | 650 |
) |
651 | 651 |
label = wcs.workflows.template_on_formdata(None, self.label, autoescape=False) |
652 | 652 |
widget = HtmlWidget(htmltext(title_markup) % label) |
653 |
widget.field = self |
|
653 | 654 |
form.widgets.append(widget) |
654 | 655 |
return widget |
655 | 656 |
add_to_view_form = add_to_form |
... | ... | |
700 | 701 |
content=self.get_text(), |
701 | 702 |
extra_css_class=self.extra_css_class) |
702 | 703 |
form.widgets.append(widget) |
704 |
widget.field = self |
|
703 | 705 |
return widget |
704 | 706 | |
705 |
def add_to_view_form(self, *args): |
|
707 |
def add_to_view_form(self, *args, **kwargs):
|
|
706 | 708 |
if self.include_in_validation_page: |
707 |
return self.add_to_form(*args) |
|
709 |
return self.add_to_form(*args, **kwargs)
|
|
708 | 710 |
return None |
709 | 711 | |
710 | 712 |
def get_html_content(self): |
... | ... | |
2013 | 2015 |
changed = True |
2014 | 2016 |
return changed |
2015 | 2017 | |
2016 |
def add_to_view_form(self, *args): |
|
2018 |
def add_to_view_form(self, *args, **kwargs):
|
|
2017 | 2019 |
pass |
2018 | 2020 | |
2019 | 2021 |
register_field_class(PageField) |
2020 |
- |