From 3610940a68df6d3435ec065fbeed6cead5254c96 Mon Sep 17 00:00:00 2001 From: Julia Damerow Date: Thu, 26 Nov 2020 12:58:01 -0500 Subject: [PATCH] [IEXP-271] check if property is in property list of an element before getting it --- isiscb/curation/taskslib/authority_tasks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/isiscb/curation/taskslib/authority_tasks.py b/isiscb/curation/taskslib/authority_tasks.py index 3786e780a..4ab1190ee 100644 --- a/isiscb/curation/taskslib/authority_tasks.py +++ b/isiscb/curation/taskslib/authority_tasks.py @@ -470,7 +470,9 @@ def update_elements(file_path, error_path, task_id, user_id): field_to_change, new_value = _find_value(field_to_change, new_value, element) # check if field to change is a ManyToManyField (IEXP-232) - if isinstance(element.__class__.__dict__[field_to_change], models.fields.related_descriptors.ManyToManyDescriptor): + # if class is a subclass, this won't work, but we only have Person so far that Subclasses + # Authority, which doesn't have any many to many relationships + if field_to_change in element.__class__.__dict__ and isinstance(element.__class__.__dict__[field_to_change], models.fields.related_descriptors.ManyToManyDescriptor): # all this is really ugly, but we have to store the old list for the # administrator notes old_value = element.__getattribute__(field_to_change).all()