kopia lustrzana https://github.com/wagtail/wagtail
indexed_get_indexed_fields should always return a copy of the configuration (even it its already a dict)
rodzic
29896dcf5e
commit
ea28584b8b
|
@ -37,20 +37,25 @@ class Indexed(object):
|
|||
def indexed_get_indexed_fields(cls):
|
||||
# Get indexed fields for this class as dictionary
|
||||
indexed_fields = cls.indexed_fields
|
||||
if isinstance(indexed_fields, tuple):
|
||||
indexed_fields = list(indexed_fields)
|
||||
if isinstance(indexed_fields, string_types):
|
||||
indexed_fields = [indexed_fields]
|
||||
if isinstance(indexed_fields, list):
|
||||
indexed_fields = dict((field, dict(type="string")) for field in indexed_fields)
|
||||
if not isinstance(indexed_fields, dict):
|
||||
raise ValueError()
|
||||
if isinstance(indexed_fields, dict):
|
||||
# Make sure we have a copy to prevent us accidentally changing the configuration
|
||||
indexed_fields = indexed_fields.copy()
|
||||
else:
|
||||
# Convert to dict
|
||||
if isinstance(indexed_fields, tuple):
|
||||
indexed_fields = list(indexed_fields)
|
||||
if isinstance(indexed_fields, string_types):
|
||||
indexed_fields = [indexed_fields]
|
||||
if isinstance(indexed_fields, list):
|
||||
indexed_fields = dict((field, dict(type="string")) for field in indexed_fields)
|
||||
if not isinstance(indexed_fields, dict):
|
||||
raise ValueError()
|
||||
|
||||
# Get indexed fields for parent class
|
||||
parent = cls.indexed_get_parent(require_model=False)
|
||||
if parent:
|
||||
# Add parent fields into this list
|
||||
parent_indexed_fields = parent.indexed_get_indexed_fields().copy()
|
||||
parent_indexed_fields = parent.indexed_get_indexed_fields()
|
||||
parent_indexed_fields.update(indexed_fields)
|
||||
indexed_fields = parent_indexed_fields
|
||||
return indexed_fields
|
||||
|
|
Ładowanie…
Reference in New Issue