From cb7cd51fa542732b867c67aa406ac996a8d2ae0d Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 9 Oct 2024 12:40:46 +0200 Subject: 🐛 archaeological files - on operation creation report address and locality (refs #6045) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archaeological_operations/wizards.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'archaeological_operations') diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py index e70eea676..ac8aaf40d 100644 --- a/archaeological_operations/wizards.py +++ b/archaeological_operations/wizards.py @@ -162,32 +162,37 @@ class OperationWizard(Wizard): value = c_value if not value: continue - initial[dest_key] = value + if initial.get(dest_key, None): + initial[dest_key] += "\n" + value + else: + initial[dest_key] = value return initial def _copy_from_associated_field(self): initial = {} - file = self.get_current_file() - if not file: + current_file = self.get_current_file() + if not current_file: return initial keys = ( (("in_charge", "pk"), "in_charge"), (("operation_name",), "common_name"), (("total_surface",), "surface"), + (("locality",), "address"), + (("address",), "address"), ) - initial.update(self.__copy_fields(file, keys)) + initial.update(self.__copy_fields(current_file, keys)) if not initial.get("common_name", None): - initial["common_name"] = file.name or "" + initial["common_name"] = current_file.name or "" if "town" not in initial: initial["town"] = [idx for idx, __ in self.get_towns()] - if file.is_preventive(): + if current_file.is_preventive(): return initial keys = ( (("scientist", "pk"), "scientist"), (("requested_operation_type", "pk"), "operation_type"), (("organization", "pk"), "operator"), ) - initial.update(self.__copy_fields(file, keys)) + initial.update(self.__copy_fields(current_file, keys)) return initial -- cgit v1.2.3