diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-01-05 16:57:05 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-28 12:15:23 +0100 |
commit | 605b06762736e2dff6f6aa8e812862115bcfb0cf (patch) | |
tree | 8b84cd2075d6d78144126b73febe7cb0e0f9792c /archaeological_warehouse/models.py | |
parent | 8aa747850493a48e13e7a7ad6255f833aeedcd63 (diff) | |
download | Ishtar-605b06762736e2dff6f6aa8e812862115bcfb0cf.tar.bz2 Ishtar-605b06762736e2dff6f6aa8e812862115bcfb0cf.zip |
Labels: quick access to operation on the container
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): |