summaryrefslogtreecommitdiff
path: root/archaeological_operations/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-05-29 11:19:14 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-05-29 11:19:14 +0200
commit84de894f83cb9eaaae81bb5514f8cacef4c1d986 (patch)
tree87d0f32604e7b960870a72713094dabfd3e3553e /archaeological_operations/forms.py
parentda8744afc3ca6d0fbc9c35825e84dcb9a52566ad (diff)
downloadIshtar-84de894f83cb9eaaae81bb5514f8cacef4c1d986.tar.bz2
Ishtar-84de894f83cb9eaaae81bb5514f8cacef4c1d986.zip
Fix operation_code display when old_code is hidden (refs #4104)
Diffstat (limited to 'archaeological_operations/forms.py')
-rw-r--r--archaeological_operations/forms.py24
1 files changed, 10 insertions, 14 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py
index e28fb2421..2309a4f4a 100644
--- a/archaeological_operations/forms.py
+++ b/archaeological_operations/forms.py
@@ -905,14 +905,6 @@ class OperationFormGeneral(CustomForm, ManageOldType):
if 'record_quality' in self.fields:
self.fields['record_quality'].choices = \
[('', '--')] + list(models.QUALITY)
- if 'operation_code' in self.fields:
- fields = OrderedDict()
- ope_code = self.fields.pop('operation_code')
- for key, value in self.fields.items():
- if key == 'old_code':
- fields['operation_code'] = ope_code
- fields[key] = value
- self.fields = fields
def clean(self):
cleaned_data = self.cleaned_data
@@ -955,7 +947,6 @@ class OperationFormGeneral(CustomForm, ManageOldType):
if ops.count():
max_val = models.Operation.objects.filter(year=year).aggregate(
Max('operation_code'))["operation_code__max"]
- msg = ''
if year and max_val:
msg = _(
u"Operation code already exists for year: %(year)d - use a "
@@ -980,14 +971,19 @@ class OperationFormModifGeneral(OperationFormGeneral):
def __init__(self, *args, **kwargs):
super(OperationFormModifGeneral, self).__init__(*args, **kwargs)
- asso_file = self.fields.pop('associated_file')
if not get_current_profile().files:
- return
+ self.fields.pop('associated_file')
+
fields = OrderedDict()
- for key, value in self.fields.items():
- if key == 'in_charge':
- fields['associated_file'] = asso_file
+ for idx, field in enumerate(self.fields.items()):
+ key, value = field
+ if 'associated_file' in self.fields and (
+ key == 'in_charge' or idx > 6):
+ fields['associated_file'] = self.fields.pop('associated_file')
fields[key] = value
+ if 'operation_code' in self.fields and (
+ key == 'year' or idx > 5):
+ fields['operation_code'] = self.fields.pop('operation_code')
self.fields = fields