diff options
-rw-r--r-- | CHANGES.txt | 1 | ||||
-rw-r--r-- | archaeological_finds/models.py | 30 | ||||
-rw-r--r-- | version.py | 2 |
3 files changed, 19 insertions, 14 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 3989c84c6..368f5a3c4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -10,6 +10,7 @@ Bug fixes: - Basket update after a treatment - Fix operation code for operation with no year (or year 0) - Fix warehouse creation +- Allow to save a find if no operation is defined 0.94 (2016-06-03) ----------------- diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index b84b7614f..f527bf5d3 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -418,7 +418,8 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem): base_finds = [bf.pk for bf in self.base_finds.all()] if self.upstream_treatment and \ self.upstream_treatment.pk not in treatments: - treatments.append((self.upstream_treatment.upstream.distinct( + treatments.append( + (self.upstream_treatment.upstream.distinct( ).order_by('label').all(), self.upstream_treatment)) for upstream in self.upstream_treatment.upstream.all(): if upstream.pk != self.pk and not [ @@ -436,8 +437,9 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem): base_finds = [bf.pk for bf in self.base_finds.all()] if self.downstream_treatment and \ self.downstream_treatment.pk not in treatments: - treatments.append((self.downstream_treatment.downstream.distinct( - ).order_by('label').all(), self.downstream_treatment)) + treatments.append( + (self.downstream_treatment.downstream.distinct( + ).order_by('label').all(), self.downstream_treatment)) for downstream in self.downstream_treatment.downstream.all(): if downstream.pk != self.pk and not [ bf.pk for bf in downstream.base_finds.all() @@ -549,16 +551,18 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem): if not self.index and q.count(): operation = q.order_by( '-context_record__operation__start_date')\ - .all()[0].context_record.operation - q = Find.objects\ - .filter(base_finds__context_record__operation=operation) - if self.pk: - q = q.exclude(pk=self.pk) - if q.count(): - self.index = q.aggregate(Max('index'))['index__max'] + 1 - else: - self.index = 1 - self.save() + .all() + if operation.count(): + operation = operation.all()[0].context_record.operation + q = Find.objects\ + .filter(base_finds__context_record__operation=operation) + if self.pk: + q = q.exclude(pk=self.pk) + if q.count(): + self.index = q.aggregate(Max('index'))['index__max'] + 1 + else: + self.index = 1 + self.save() for base_find in self.base_finds.all(): modified = False if not base_find.index: diff --git a/version.py b/version.py index 4e4579b55..45af47803 100644 --- a/version.py +++ b/version.py @@ -1,4 +1,4 @@ -VERSION = (0, 95) +VERSION = (0, 95, 1) def get_version(): |