Skip to content

Commit

Permalink
Ignore fields from extensible metadata schema (#14)
Browse files Browse the repository at this point in the history
* Ignore fields from extensible metadata schema

* Changelog
  • Loading branch information
ramonski authored Jun 22, 2022
1 parent c177d5d commit c3a23dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
2.3.0 (unreleased)
------------------

- #14 Ignore fields from extensible metadata schema
- #13 Remove dependency to Products.TextIndexNG3 (test layer)


Expand Down
22 changes: 21 additions & 1 deletion src/senaite/app/supermodel/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@

IGNORE_CATALOGS = [AUDITLOG_CATALOG]

# Ingore irrelevant fields coming from Archetypes Extensible Metadata
# -> if required, these fields have to be fetched from the instance itself
IGNORE_SCHEMA_FIELDS = [
"allowDiscussion", # avoid depreciation message when accessing the field
"contributors",
"creators",
"expirationDate",
"language",
"location",
"rights",
"subject",
]


class SuperModel(object):
"""Generic wrapper for content objects
Expand Down Expand Up @@ -157,7 +170,14 @@ def __iter__(self):

def keys(self):
fields = api.get_fields(self.instance).keys()
return filter(lambda f: not f.startswith("_"), fields)
keys = []
for field in fields:
if field.startswith("_"):
continue
if field in IGNORE_SCHEMA_FIELDS:
continue
keys.append(field)
return keys

def iteritems(self):
for k in self:
Expand Down

0 comments on commit c3a23dc

Please sign in to comment.