backoffice: add note about no displayed columns in card fields page (#75953) #552
|
@ -955,3 +955,32 @@ def test_card_edit_field_warnings(pub):
|
|||
assert 'first field should be of type "page"' in resp.text
|
||||
assert '<div id="new-field"><h3>New Field</h3>' not in resp.text
|
||||
assert '>Duplicate<' not in resp.text
|
||||
|
||||
|
||||
def test_card_edit_field_infonotices(pub):
|
||||
create_superuser(pub)
|
||||
|
||||
CardDef.wipe()
|
||||
carddef = CardDef()
|
||||
carddef.name = 'card title'
|
||||
carddef.fields = []
|
||||
carddef.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/cards/%s/fields/' % carddef.id)
|
||||
assert 'This card model currently has no field configured for listings.' not in resp.text
|
||||
|
||||
carddef.fields = [fields.StringField(id='0', label='field')]
|
||||
carddef.store()
|
||||
resp = app.get('/backoffice/cards/%s/fields/' % carddef.id)
|
||||
assert 'This card model currently has no field configured for listings.' in resp.text
|
||||
|
||||
carddef.fields = [fields.StringField(id='1', label='field', display_locations=['listings'])]
|
||||
carddef.store()
|
||||
resp = app.get('/backoffice/cards/%s/fields/' % carddef.id)
|
||||
assert 'This card model currently has no field configured for listings.' not in resp.text
|
||||
|
||||
carddef.fields = [fields.PageField(id='2', label='field')]
|
||||
carddef.store()
|
||||
resp = app.get('/backoffice/cards/%s/fields/' % carddef.id)
|
||||
assert 'This card model currently has no field configured for listings.' not in resp.text
|
||||
|
|
|
@ -58,6 +58,21 @@ class CardFieldsDirectory(FormFieldsDirectory):
|
|||
field_over_count_message = _('This card model contains more than %d fields.')
|
||||
readonly_message = _('This card model is readonly.')
|
||||
|
||||
def index_bottom(self):
|
||||
if self.objectdef.is_readonly():
|
||||
return
|
||||
if any(
|
||||
'display_locations' in x.get_admin_attributes() for x in self.objectdef.fields or []
|
||||
) and not any(x.include_in_listing for x in self.objectdef.fields):
|
||||
r = TemplateIO(html=True)
|
||||
r += htmltext('<div class="pk-information">')
|
||||
r += htmltext('<p>%s</p>') % _('This card model currently has no field configured for listings.')
|
||||
r += htmltext('<p>%s</p>') % _(
|
||||
'You should configure at least one to have some content displayed.'
|
||||
)
|
||||
r += htmltext('</div>')
|
||||
return r.getvalue()
|
||||
|
||||
|
||||
class CardDefPage(FormDefPage):
|
||||
formdef_class = CardDef
|
||||
|
|
Loading…
Reference in New Issue