2 Commits

Author SHA1 Message Date
relikd
b05dd31ff0 v0.9.5 2022-04-07 13:33:59 +02:00
relikd
16a26afdce fix data model enumeration with no flow blocks 2022-04-07 01:01:23 +02:00
3 changed files with 7 additions and 4 deletions

View File

@@ -6,6 +6,8 @@ Overview:
- [advanced example](#advanced-example) touches on the potentials of the plugin. - [advanced example](#advanced-example) touches on the potentials of the plugin.
- [Misc](#misc) shows other use-cases. - [Misc](#misc) shows other use-cases.
After reading this tutorial, have a look at other plugins that use `lektor-groupby`:
- [lektor-inlinetags](https://github.com/relikd/lektor-inlinetags-plugin)
## About ## About

View File

@@ -74,8 +74,10 @@ class GroupByModelReader:
''' '''
assert isinstance(record, Record) assert isinstance(record, Record)
for r_key, subs in self._models.get(record.datamodel.id, {}).items(): for r_key, subs in self._models.get(record.datamodel.id, {}).items():
field = record[r_key]
if not field:
continue
if subs == '*': # either normal field or flow type (all blocks) if subs == '*': # either normal field or flow type (all blocks)
field = record[r_key]
if flatten and isinstance(field, Flow): if flatten and isinstance(field, Flow):
for i, flow in enumerate(field.blocks): for i, flow in enumerate(field.blocks):
flowtype = flow['_flowblock'] flowtype = flow['_flowblock']
@@ -86,7 +88,7 @@ class GroupByModelReader:
else: else:
yield FieldKeyPath(r_key), field yield FieldKeyPath(r_key), field
else: # always flow type (only some blocks) else: # always flow type (only some blocks)
for i, flow in enumerate(record[r_key].blocks): for i, flow in enumerate(field.blocks):
flowtype = flow['_flowblock'] flowtype = flow['_flowblock']
for f_key in self._flows.get(flowtype, []): for f_key in self._flows.get(flowtype, []):
yield FieldKeyPath(r_key, i, f_key), flow[f_key] yield FieldKeyPath(r_key, i, f_key), flow[f_key]

View File

@@ -13,7 +13,7 @@ setup(
}, },
author='relikd', author='relikd',
url='https://github.com/relikd/lektor-groupby-plugin', url='https://github.com/relikd/lektor-groupby-plugin',
version='0.9.4', version='0.9.5',
description='Cluster arbitrary records with field attribute keyword.', description='Cluster arbitrary records with field attribute keyword.',
long_description=longdesc, long_description=longdesc,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
@@ -27,7 +27,6 @@ setup(
'cluster', 'cluster',
], ],
classifiers=[ classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment', 'Environment :: Web Environment',
'Environment :: Plugins', 'Environment :: Plugins',
'Framework :: Lektor', 'Framework :: Lektor',