summaryrefslogtreecommitdiff
path: root/archaeological_context_records/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-11-14 15:18:00 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-11-14 17:58:03 +0100
commit222506fddb21d3c4e87fc6faf9b905dd988062c6 (patch)
treeb940e28f9eadf2f3a81c859f5c576e42febdb00f /archaeological_context_records/forms.py
parent872bc0f6b00c44a5978a826c063a3f1e50dd4b15 (diff)
downloadIshtar-222506fddb21d3c4e87fc6faf9b905dd988062c6.tar.bz2
Ishtar-222506fddb21d3c4e87fc6faf9b905dd988062c6.zip
✨ datings refactoring: modify view/form
Diffstat (limited to 'archaeological_context_records/forms.py')
-rw-r--r--archaeological_context_records/forms.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py
index 36f6ea516..75b6d71ef 100644
--- a/archaeological_context_records/forms.py
+++ b/archaeological_context_records/forms.py
@@ -935,17 +935,18 @@ class QADating(ManageOldType, forms.Form):
def clean(self):
data = self.cleaned_data
reference = data['reference']
- q_attr = {
- "reference": reference,
- self.dating_model.CURRENT_MODEL_ATTR + "_id": self.current_item.pk
- }
- q = self.dating_model.objects.filter(**q_attr)
- if data.get("pk", None):
- q = q.exclude(pk=data["pk"])
- if q.count():
- raise forms.ValidationError(
- _("This reference already exists for this item.")
- )
+ if reference:
+ q_attr = {
+ "reference": reference,
+ self.dating_model.CURRENT_MODEL_ATTR + "_id": self.current_item.pk
+ }
+ q = self.dating_model.objects.filter(**q_attr)
+ if data.get("pk", None):
+ q = q.exclude(pk=data["pk"])
+ if q.count():
+ raise forms.ValidationError(
+ _("This reference already exists for this item.")
+ )
if any(1 for k in self.cleaned_data if self.cleaned_data[k]):
return data
raise forms.ValidationError(_("No data provided."))