diff options
| -rw-r--r-- | ishtar/furnitures/forms_context_records.py | 37 | ||||
| -rw-r--r-- | ishtar/furnitures/views.py | 1 | ||||
| -rw-r--r-- | ishtar/templates/default_wizard.html | 1 | ||||
| -rw-r--r-- | static/media/style.css | 13 | 
4 files changed, 50 insertions, 2 deletions
| diff --git a/ishtar/furnitures/forms_context_records.py b/ishtar/furnitures/forms_context_records.py index 25f1db1c3..3a8ccb242 100644 --- a/ishtar/furnitures/forms_context_records.py +++ b/ishtar/furnitures/forms_context_records.py @@ -42,6 +42,40 @@ class RecordWizard(Wizard):      model = models.ContextRecord      edit = False +    def get_current_operation(self, request, storage): +        step = storage.get_current_step() +        if not step: +            return +        if step.endswith('_creation'): # an operation has been selected +            main_form_key = 'selec-' + self.url_name +            try: +                idx = int(self.session_get_value(request, storage, +                                        main_form_key, 'pk')) +                current_ope = models.Operation.objects.get(pk=idx) +                return current_ope +            except(TypeError, ValueError, ObjectDoesNotExist): +                pass +        current_cr = self.get_current_object(request, storage) +        if current_cr: +            return current_cr.parcel.operation + +    def get_template_context(self, request, storage, form=None): +        """ +        Get the operation "reminder" on top of wizard forms +        """ +        context = super(RecordWizard, self).get_template_context(request, +                                                            storage, form) +        operation = self.get_current_operation(request, storage) +        if not operation: +            return context +        items = [] +        if hasattr(operation, 'code_patriarche') and operation.code_patriarche: +            items.append(unicode(operation.code_patriarche)) +        items.append("-".join((unicode(operation.year), +                               unicode(operation.operation_code)))) +        context['reminder'] = _("Current operation: ") + " - ".join(items) +        return context +      def get_form(self, request, storage, step=None, data=None, files=None):          """          Get associated operation @@ -125,7 +159,8 @@ class RecordFormGeneral(forms.Form):             ('operation' in kwargs['data'] or 'context_record' in kwargs['data']):              if 'operation' in kwargs['data']:                  operation = kwargs['data']['operation'] -            if 'context_record' in kwargs['data']: +            if 'context_record' in kwargs['data'] and \ +               kwargs['data']['context_record']:                  operation = kwargs['data']['context_record'].parcel.operation              # clean data if not "real" data              prefix_value = kwargs['prefix'] diff --git a/ishtar/furnitures/views.py b/ishtar/furnitures/views.py index 7712dc91a..31cb91767 100644 --- a/ishtar/furnitures/views.py +++ b/ishtar/furnitures/views.py @@ -523,7 +523,6 @@ def new_item(model):                  if '_select_' in dct['parent_pk']:                      parents = dct['parent_pk'].split('_')                      dct['parent_pk'] = "_".join([parents[0]] + parents[2:]) -                print dct                  return render_to_response('window.html', dct,                                    context_instance=RequestContext(request))          else: diff --git a/ishtar/templates/default_wizard.html b/ishtar/templates/default_wizard.html index 2b8ade350..9988180d9 100644 --- a/ishtar/templates/default_wizard.html +++ b/ishtar/templates/default_wizard.html @@ -14,6 +14,7 @@    <li class='current'>» <a href='#'>{{current_step.form_label}}</a></li>  </ul>  <div class='form'> +{% if reminder %}<div class='reminder'>{{ reminder }}</div>{%endif%}  {% if form.forms %}  <div class='top_button'><input type="submit" id="submit_form" value="{% trans "Validate" %}"/></div>  <table class='formset'> diff --git a/static/media/style.css b/static/media/style.css index e8c94c552..82c895080 100644 --- a/static/media/style.css +++ b/static/media/style.css @@ -178,6 +178,19 @@ ul#form_path button {      font-family:Arial, Helvetica, sans-serif;  } +.reminder{ +    padding:0.4em; +    border:1px solid #CCC; +    -moz-border-radius:8px; +    -webkit-border-radius:8px; +    border-radius:8px; +    text-align:center; +    width:400px; +    margin-left:auto; +    margin-right:auto; +    background-color:white; +} +  div.form {      margin-left:auto;      margin-right:auto; | 
