diff options
| author | Étienne Loks <etienne.loks@proxience.com> | 2015-12-21 15:06:21 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@proxience.com> | 2015-12-21 15:06:21 +0100 | 
| commit | b10f1833c7b8586706a1c9d7be9e8a37cd221ef3 (patch) | |
| tree | 74b77b26a995380a6e828b6c8712aa0e5f2c00ea /archaeological_context_records/wizards.py | |
| parent | d7bef92eb2320243e3db1c0e03aeac42781e5585 (diff) | |
| download | Ishtar-b10f1833c7b8586706a1c9d7be9e8a37cd221ef3.tar.bz2 Ishtar-b10f1833c7b8586706a1c9d7be9e8a37cd221ef3.zip | |
Manage context record relations.
Diffstat (limited to 'archaeological_context_records/wizards.py')
| -rw-r--r-- | archaeological_context_records/wizards.py | 20 | 
1 files changed, 20 insertions, 0 deletions
| diff --git a/archaeological_context_records/wizards.py b/archaeological_context_records/wizards.py index 99c666e89..2449b400e 100644 --- a/archaeological_context_records/wizards.py +++ b/archaeological_context_records/wizards.py @@ -29,6 +29,14 @@ class RecordWizard(Wizard):      model = models.ContextRecord      edit = False      wizard_done_window = reverse_lazy('show-contextrecord') +    relations_step_key = 'relations' + +    def get_template_names(self): +        templates = super(RecordWizard, self).get_template_names() +        current_step = self.steps.current +        if current_step.startswith(self.relations_step_key): +            templates = ['ishtar/wizard/relations_wizard.html'] + templates +        return templates      def get_current_operation(self):          step = self.steps.current @@ -87,9 +95,21 @@ class RecordWizard(Wizard):              else:                  current_object = self.get_current_object()                  data['context_record'] = current_object +        elif step.startswith('relations') and hasattr(form, 'management_form'): +            data['CONTEXT_RECORDS'] = self.get_other_context_records()          form = super(RecordWizard, self).get_form(step, data, files)          return form +    def get_other_context_records(self): +        operation = self.get_current_operation() +        if not operation: +            return [] +        q = models.ContextRecord.objects.filter(operation=operation) +        obj = self.get_current_object() +        if obj and obj.pk: +            q = q.exclude(pk=obj.pk) +        return [(cr.pk, unicode(cr)) for cr in q.all()] +  class RecordModifWizard(RecordWizard):      modification = True | 
