summaryrefslogtreecommitdiff
path: root/archaeological_finds/models_finds.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds/models_finds.py')
-rw-r--r--archaeological_finds/models_finds.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index f4056cf4b..328821386 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -880,7 +880,9 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem,
)
# search parameters
- REVERSED_BOOL_FIELDS = ['documents__image__isnull']
+ REVERSED_BOOL_FIELDS = ['documents__image__isnull',
+ 'documents__associated_url__isnull',
+ 'documents__associated_file__isnull']
BOOL_FIELDS = ['is_complete']
RELATION_TYPES_PREFIX = {
'ope_relation_types':
@@ -1042,10 +1044,6 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem,
SearchAltName(
pgettext_lazy("key for text search", "checked"),
'checked_type__label__iexact'),
- 'documents__image__isnull':
- SearchAltName(
- pgettext_lazy("key for text search", "has-image"),
- 'documents__image__isnull'),
'container_ref__location':
SearchAltName(
pgettext_lazy("key for text search", "location"),
@@ -1364,6 +1362,7 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem,
),
}
ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES)
+ ALT_NAMES.update(DocumentItem.ALT_NAMES)
DYNAMIC_REQUESTS = {
'current_division': DynamicRequest(
@@ -1608,9 +1607,9 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem,
on_delete=models.SET_NULL,
blank=True, null=True
)
- insurance_value = models.FloatField(_(u"Insurance value"), blank=True,
+ insurance_value = models.FloatField(_("Insurance value"), blank=True,
null=True)
- appraisal_date = models.DateField(_(u"Appraisal date"), blank=True,
+ appraisal_date = models.DateField(_("Appraisal date"), blank=True,
null=True)
public_description = models.TextField(_("Public description"), blank=True,
null=True)
@@ -1993,6 +1992,11 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem,
if data:
for k in data:
setattr(new, k, data[k])
+ # remove associated treatments
+ if not duplicate_for_treatment and (
+ new.upstream_treatment or new.downstream_treatment):
+ new.upstream_treatment, new.downstream_treatment = None, None
+ new.uuid = uuid.uuid4()
new.save()
# m2m fields
@@ -2023,6 +2027,8 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem,
user=user, data={"label": new.label, "external_id": None}))
# remove documents for this kind of duplicate (data entry)
new.documents.clear()
+ # remove associated treatments
+ new.treatments.clear()
return new
@classmethod