diff options
| -rw-r--r-- | archaeological_files_pdl/forms.py | 17 | ||||
| -rw-r--r-- | archaeological_files_pdl/templates/ishtar/wizard/wizard_instruction.html | 3 | ||||
| -rw-r--r-- | archaeological_files_pdl/wizards.py | 23 | 
3 files changed, 41 insertions, 2 deletions
| diff --git a/archaeological_files_pdl/forms.py b/archaeological_files_pdl/forms.py index f71bf6a8a..fab2b982b 100644 --- a/archaeological_files_pdl/forms.py +++ b/archaeological_files_pdl/forms.py @@ -317,6 +317,12 @@ class FileFormInstruction(forms.Form):          c_year = datetime.date.today().year          if 'year' in kwargs:              c_year = kwargs.pop('year') +        saisine_type = None +        if 'saisine_type' in kwargs: +            saisine_type = kwargs.pop('saisine_type') +        reception_date = None +        if 'reception_date' in kwargs: +            reception_date = kwargs.pop('reception_date')          if 'data' in kwargs and kwargs['data']:              kwargs['data'][kwargs.get('prefix', '') + '-year'] = c_year @@ -335,6 +341,17 @@ class FileFormInstruction(forms.Form):          self.fields['numeric_reference'].initial = c_num + 1          if self.numeric_reference_is_readonly:              self.fields['numeric_reference'].widget.attrs['readonly'] = True +            if reception_date and saisine_type: +                if type(reception_date) in (unicode, str): +                    try: +                        reception_date = datetime.datetime.strptime( +                            reception_date, '%d/%m/%Y') +                        self.fields['instruction_deadline'].initial = \ +                            (reception_date + datetime.timedelta( +                                days=saisine_type.delay or 0) +                             ).strftime('%Y-%m-%d') +                    except ValueError: +                        pass          def clean_numeric_reference(self):              if self.numeric_reference_is_readonly: diff --git a/archaeological_files_pdl/templates/ishtar/wizard/wizard_instruction.html b/archaeological_files_pdl/templates/ishtar/wizard/wizard_instruction.html index 4162a3764..120b6f9ab 100644 --- a/archaeological_files_pdl/templates/ishtar/wizard/wizard_instruction.html +++ b/archaeological_files_pdl/templates/ishtar/wizard/wizard_instruction.html @@ -42,6 +42,9 @@  <tr class='required'>    <th><label for="id_instruction-{{CURRENT_ACTION}}-instruction_deadline">Date limite d'instruction</label></th>  </tr> +{% if saisine_type %}<tr> +  <th><em>{{ saisine_type }}{% if saisine_type_delay %} : délai de {{saisine_type_delay}} jours{% endif %}</em></th> +</tr>{% endif %}  <tr class='required'>    <td>{{wizard.form.instruction_deadline.errors}}{{wizard.form.instruction_deadline|safe}}</td>  </tr> diff --git a/archaeological_files_pdl/wizards.py b/archaeological_files_pdl/wizards.py index eb3611b26..ebf09178d 100644 --- a/archaeological_files_pdl/wizards.py +++ b/archaeological_files_pdl/wizards.py @@ -48,12 +48,26 @@ class FileWizard(BaseFileWizard):                  returned['status'] = self.request.GET['status']          if args and args[0].startswith('instruction-'):              returned['year'] = self.get_current_year() +            returned['saisine_type'] = self.get_saisine_type() +            returned['reception_date'] = \ +                self.session_get_value( +                    'general-' + self.url_name, 'reception_date')          return returned +    def get_saisine_type(self): +        try: +            idx = int( +                self.session_get_value( +                    'preventivetype-' + self.url_name, 'saisine_type')) +            return models.SaisineType.objects.get(pk=idx) +        except (ValueError, models.PermitType.DoesNotExist): +            pass +      def get_context_data(self, form, **kwargs):          context = super(FileWizard, self).get_context_data(form) -        formkey = "planningservice-" + self.url_name -        if self.steps.current == formkey: +        formplanning = "planningservice-" + self.url_name +        forminstruction = "instruction-" + self.url_name +        if self.steps.current == formplanning:              try:                  idx = int(                      self.session_get_value( @@ -63,6 +77,11 @@ class FileWizard(BaseFileWizard):                  context['permit_type_code'] = unicode(permit_type.txt_idx)              except (ValueError, models.PermitType.DoesNotExist):                  pass +        elif self.steps.current == forminstruction: +            saisine_type = self.get_saisine_type() +            if saisine_type: +                context['saisine_type'] = unicode(saisine_type) +                context['saisine_type_delay'] = saisine_type.delay or 0          return context | 
