diff options
Diffstat (limited to 'ishtar_common/wizards.py')
| -rw-r--r-- | ishtar_common/wizards.py | 32 | 
1 files changed, 29 insertions, 3 deletions
| diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 878f083a3..006c2554e 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -52,6 +52,7 @@ class Wizard(NamedUrlWizardView):      translated_keys = ['title']      wizard_done_template = 'ishtar/wizard/wizard_done.html'      wizard_done_window = '' +    wizard_templates = {}      @staticmethod      def _check_right(step, condition=True): @@ -93,7 +94,9 @@ class Wizard(NamedUrlWizardView):      def get_template_names(self):          templates = ['ishtar/wizard/default_wizard.html']          current_step = self.steps.current -        if current_step == self.steps.last: +        if current_step in self.wizard_templates: +            templates = [self.wizard_templates[current_step]] + templates +        elif current_step == self.steps.last:              templates = ['ishtar/wizard/confirm_wizard.html'] + templates          return templates @@ -104,7 +107,8 @@ class Wizard(NamedUrlWizardView):          step = self.steps.first          current_step = self.steps.current          context.update({'current_step':self.form_list[current_step], -                        'wizard_label':self.label}) +                        'wizard_label':self.label, +                        'current_object':self.get_current_object()})          if step == current_step:              return context          previous_steps, next_steps, previous_step_counter = [], [], 0 @@ -795,6 +799,12 @@ class SearchWizard(NamedUrlWizardView):          return context  class DeletionWizard(Wizard): +    def __init__(self, *args, **kwargs): +        if (not hasattr(self, 'fields') or not self.fields) and \ +           (hasattr(self, 'model') and hasattr(self.model, 'TABLE_COLS')): +            self.fields = self.model.TABLE_COLS +        return super(DeletionWizard, self).__init__(*args, **kwargs) +      def get_formated_datas(self, forms):          datas = super(DeletionWizard, self).get_formated_datas(forms)          self.current_obj = None @@ -830,7 +840,10 @@ class DeletionWizard(Wizard):      def done(self, form_list, **kwargs):          obj = self.get_current_object() -        obj.delete() +        try: +            obj.delete() +        except ObjectDoesNotExist: +            pass          return render_to_response('ishtar/wizard/wizard_delete_done.html', {},                                    context_instance=RequestContext(self.request)) @@ -890,12 +903,25 @@ class PersonWizard(Wizard):  class PersonModifWizard(PersonWizard):      modification = True +class PersonDeletionWizard(DeletionWizard): +    model = models.Person +    fields = model.TABLE_COLS +    wizard_templates = { +        'final-person_deletion':'ishtar/wizard/wizard_person_deletion.html'} +  class OrganizationWizard(Wizard):      model = models.Organization  class OrganizationModifWizard(OrganizationWizard):      modification = True +class OrganizationDeletionWizard(DeletionWizard): +    model = models.Organization +    fields = model.TABLE_COLS +    wizard_templates = { +        'final-organization_deletion':\ +            'ishtar/wizard/wizard_organization_deletion.html'} +  class AccountWizard(Wizard):      model = models.Person      def get_formated_datas(self, forms): | 
