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 | d319e01c50deeba74674b9e0a6389f3637ce154a (patch) | |
tree | 8b84cd2075d6d78144126b73febe7cb0e0f9792c /archaeological_warehouse | |
parent | 5a4747a863ee926223148bad3163b4b7135328d3 (diff) | |
download | Ishtar-d319e01c50deeba74674b9e0a6389f3637ce154a.tar.bz2 Ishtar-d319e01c50deeba74674b9e0a6389f3637ce154a.zip |
Labels: quick access to operation on the container
Diffstat (limited to 'archaeological_warehouse')
-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): |