diff options
| 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 | 
| commit | d3bf3f911488ddd5a9fd5617fb28e0f26a7f4e1a (patch) | |
| tree | 87d0f32604e7b960870a72713094dabfd3e3553e /archaeological_operations/forms.py | |
| parent | 1384bedf3b57a7a78f2412958d54fb93779b80eb (diff) | |
| download | Ishtar-d3bf3f911488ddd5a9fd5617fb28e0f26a7f4e1a.tar.bz2 Ishtar-d3bf3f911488ddd5a9fd5617fb28e0f26a7f4e1a.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.py | 24 | 
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  | 
