diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-03-14 12:15:41 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-07-08 09:58:49 +0200 |
commit | e2f2467af66befce3d1934f8b7029166f0775d9d (patch) | |
tree | abae201e49b1524f765d6bc8743413b63bafef7f | |
parent | b7369ecbaf3f391f8131f4b5ad2c6c8e58f701b8 (diff) | |
download | Ishtar-e2f2467af66befce3d1934f8b7029166f0775d9d.tar.bz2 Ishtar-e2f2467af66befce3d1934f8b7029166f0775d9d.zip |
QA context record bulk-update: small refactoring
-rw-r--r-- | archaeological_context_records/forms.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py index 8993675e6..9b2ae129c 100644 --- a/archaeological_context_records/forms.py +++ b/archaeological_context_records/forms.py @@ -753,16 +753,16 @@ class QAContextRecordFormMulti(QAForm): def __init__(self, *args, **kwargs): super(QAContextRecordFormMulti, self).__init__(*args, **kwargs) self.items = kwargs.pop("items") - op_pk = 0 disable = False - for cr in self.items: - if op_pk != cr.operation.pk and op_pk > 0: - disable = self.fields["qa_parcel"].disabled = True - self.fields["qa_parcel"].choices = [ - (1, _("Parcel can be modified only if operations are the same")) - ] - break - op_pk = cr.operation.pk + if self.items > 1: + op_pk = self.items[0].pk + for cr in self.items[1:]: + if op_pk != cr.operation.pk: + disable = self.fields["qa_parcel"].disabled = True + self.fields["qa_parcel"].choices = [ + (1, _("Parcel can be modified only if operations are the same")) + ] + break if not disable: self.fields["qa_parcel"].choices += [ (p.pk, str(p)) for p in Parcel.objects.filter( @@ -770,7 +770,6 @@ class QAContextRecordFormMulti(QAForm): ).all() ] - def clean(self): cleaned_data = super().clean() r_type = cleaned_data.get("qa_relation_type") |