summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-06-08 19:26:39 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-06-08 19:26:39 +0200
commit734fbbc2bd73d1ba565058a09d471a114c4e8972 (patch)
treeed047baaf8e6f1f2eafccfafa1e0c8af263ac561
parentde3bf64db15b3925af72b7a2a502a37e2913e5c6 (diff)
downloadIshtar-734fbbc2bd73d1ba565058a09d471a114c4e8972.tar.bz2
Ishtar-734fbbc2bd73d1ba565058a09d471a114c4e8972.zip
Allow to save a find if no operation is associated - 2
-rw-r--r--archaeological_finds/models.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py
index f527bf5d3..adfa67394 100644
--- a/archaeological_finds/models.py
+++ b/archaeological_finds/models.py
@@ -549,9 +549,9 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
super(Find, self).save(*args, **kwargs)
q = self.base_finds
if not self.index and q.count():
- operation = q.order_by(
- '-context_record__operation__start_date')\
- .all()
+ operation = q.filter(
+ context_record__operation__pk__isnull=False).order_by(
+ '-context_record__operation__start_date')
if operation.count():
operation = operation.all()[0].context_record.operation
q = Find.objects\
@@ -563,7 +563,8 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
else:
self.index = 1
self.save()
- for base_find in self.base_finds.all():
+ for base_find in self.base_finds.filter(
+ context_record__operation__pk__isnull=False).all():
modified = False
if not base_find.index:
modified = True