def flowblock_data_from_ini(id, inifile, lang): return dict( filename=inifile.filename, id=id, name=get_i18n(inifile, 'block.name', lang) or id.title().replace('_', ' '), fields=fielddata_from_ini(inifile, lang), )
def datamodel_data_from_ini(id, inifile, lang='en'): def _parse_order(value): value = (value or '').strip() if not value: return None return [x for x in [x.strip() for x in value.strip().split(',')] if x] return dict( filename=inifile.filename, id=id, parent=inifile.get('model.inherits'), name=get_i18n(inifile, 'model.name', lang) or id.title().replace('_', ' '), label=get_i18n(inifile, 'model.label', lang), primary_field=inifile.get('model.primary_field'), hidden=inifile.get_bool('model.hidden', default=None), protected=inifile.get_bool('model.protected', default=None), expose=inifile.get_bool('model.expose', default=None), child_config=dict( enabled=inifile.get_bool('children.enabled', default=None), slug_format=inifile.get('children.slug_format'), model=inifile.get('children.model'), order_by=_parse_order(inifile.get('children.order_by')), replaced_with=inifile.get('children.replaced_with'), ), attachment_config=dict( enabled=inifile.get_bool('attachments.enabled', default=None), model=inifile.get('attachments.model'), order_by=_parse_order(inifile.get('attachments.order_by')), ), pagination_config=dict( enabled=inifile.get_bool('pagination.enabled', default=None), per_page=inifile.get_int('pagination.per_page'), url_suffix=inifile.get('pagination.url_suffix'), ), fields=fielddata_from_ini(inifile, lang), )