diff options
Diffstat (limited to 'archaeological_warehouse/models.py')
-rw-r--r-- | archaeological_warehouse/models.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 06944fa38..efbdd922d 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -1311,10 +1311,30 @@ class Container(DocumentItem, Merge, LightHistorizedItem, prefix=prefix, no_values=no_values, filtr=filtr, **kwargs) if not filtr or prefix + 'finds' in filtr: + kwargs["exclude"] = [prefix + "container", prefix + "container_ref"] + # prevent recursive call values[prefix + 'finds'] = [ f.get_values( prefix=prefix, no_values=True, filtr=None, **kwargs) for f in self.finds.distinct().all()] + if (not filtr or prefix + 'operation' in filtr or + prefix + "context_record" in filtr) and self.finds.count(): + # assume that only one operation is in this container + # you should know what you are doing when using theses variables + f = self.finds.all()[0] + bf = f.get_first_base_find() + if bf: + cr = bf.context_record + if not filtr or prefix + "context_record" in filtr: + kwargs["exclude"] = [prefix + "operation"] + values[prefix + 'context_record'] = \ + cr.get_values( + prefix=prefix, no_values=True, filtr=None, **kwargs) + if not filtr or prefix + "operation" in filtr: + kwargs["exclude"] = [prefix + "context_records"] + values[prefix + 'operation'] = \ + cr.operation.get_values( + prefix=prefix, no_values=True, filtr=None, **kwargs) return values def get_extra_actions(self, request): |