Added types to collection objects
This commit is contained in:
parent
8e20424b78
commit
0420fafabf
|
|
@ -118,22 +118,23 @@ class Collection(ProjectBaseMixin, CollectionDateMixin,
|
|||
instances = getattr(self, f'{related_object}')
|
||||
if instances.exists():
|
||||
for instance in instances.all():
|
||||
raw_object = (instance.id, instance.slug) if hasattr(instance, 'slug') else (
|
||||
instance.id, None
|
||||
)
|
||||
raw_object = (instance.id, instance.establishment_type.index_name,
|
||||
instance.slug) if \
|
||||
hasattr(instance, 'slug') else (instance.id, None)
|
||||
raw_objects.append(raw_object)
|
||||
|
||||
# parse slugs
|
||||
related_objects = []
|
||||
object_names = set()
|
||||
re_pattern = r'[\w]+'
|
||||
for object_id, raw_name, in raw_objects:
|
||||
for object_id, object_type, raw_name, in raw_objects:
|
||||
result = re.findall(re_pattern, raw_name)
|
||||
if result:
|
||||
name = ' '.join(result).capitalize()
|
||||
if name not in object_names:
|
||||
related_objects.append({
|
||||
'id': object_id,
|
||||
'establishment_type': object_type,
|
||||
'name': name
|
||||
})
|
||||
object_names.add(name)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user