diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2014-05-12 21:21:04 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2014-05-12 21:23:12 +0200 |
commit | 0044979f420102dde6b876ec7a9e986e9c62cda7 (patch) | |
tree | e69bfd5b3bc0843ec93223dc12d4a376d6b489c0 /ishtar_common/wizards.py | |
parent | e377a4c28bfc63170dd5cbf182493bbc6bf590e0 (diff) | |
download | Ishtar-0044979f420102dde6b876ec7a9e986e9c62cda7.tar.bz2 Ishtar-0044979f420102dde6b876ec7a9e986e9c62cda7.zip |
Person and organization deletion (refs #1675)
* add associated actions, wizards, forms
* prevent deletion of associted items (operations, files, etc.)
* give list of associated items before deletion and give access to these
items
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): |