diff options
Diffstat (limited to 'ishtar/furnitures')
| -rw-r--r-- | ishtar/furnitures/forms.py | 12 | ||||
| -rw-r--r-- | ishtar/furnitures/models.py | 14 | 
2 files changed, 19 insertions, 7 deletions
diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py index e9a9159eb..bb6555547 100644 --- a/ishtar/furnitures/forms.py +++ b/ishtar/furnitures/forms.py @@ -1227,6 +1227,16 @@ class FileClosingWizard(DeletionWizard):                  datas[0][1].append(res[field])          return datas +    def done(self, request, storage, form_list, **kwargs): +        obj = self.get_current_object(request, storage) +        for form in form_list: +            if form.is_valid(): +                if 'end_date' in form.cleaned_data and hasattr(obj, 'end_date'): +                    obj.end_date = form.cleaned_data['end_date'] +                    obj.save() +        return render_to_response('wizard_done.html', {}, +                                  context_instance=RequestContext(request)) +  class FileDeletionWizard(FileClosingWizard):      def get_formated_datas(self, forms):          datas = super(FileDeletionWizard, self).get_formated_datas(forms) @@ -1790,7 +1800,7 @@ class OperationDateFormSelection(forms.Form):      end_date = forms.DateField(label=_(u"Closing date"),                                 widget=widgets.JQueryDate) -class OperationClosingWizard(DeletionWizard): +class OperationClosingWizard(FileClosingWizard):      model = models.Operation      fields = ['year', 'operation_code', 'operation_type', 'associated_file',             'in_charge', 'start_date', 'end_date', 'comment', 'towns', 'remains'] diff --git a/ishtar/furnitures/models.py b/ishtar/furnitures/models.py index 9bbb8bf2d..db8773ad4 100644 --- a/ishtar/furnitures/models.py +++ b/ishtar/furnitures/models.py @@ -590,16 +590,18 @@ class Operation(BaseHistorizedItem, OwnPerms):          return Q(in_charge=user.person)|Q(history_modifier=user)\                 & Q(end_date__isnull=True) -    """ +    def is_active(self): +        return not bool(self.end_date) +      def closing(self): -        if self.is_active: +        if self.is_active():              return          for item in self.history.all(): -            if item.is_active(): +            if not item.end_date:                  break -            closing_item = item -        return {'date':item.history_date, 'user':item.history_modifier} -""" +        return {'date':item.history_date, +                'user':IshtarUser.objects.get(pk=item.history_modifier_id)} +  class Parcel(LightHistorizedItem):      associated_file = models.ForeignKey(File, related_name='parcels',                                  blank=True, null=True, verbose_name=_(u"File"))  | 
