def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # TODO: introduce better behavior for this
        self.additional_records_active = True
        self.reference_links_active = cloud_enabled()

        self.slots_active = is_active_module('aristotle_mdr.contrib.slots')
        self.identifiers_active = is_active_module(
            'aristotle_mdr.contrib.identifiers')
Ejemplo n.º 2
0
    def get_context_data(self, form, **kwargs):
        context = super().get_context_data(form=form, **kwargs)

        if self.steps.current == 'initial':
            context['step_title'] = _('Search for existing content')

        if self.steps.current == 'results':
            self.search_terms = self.get_cleaned_data_for_step('initial')
            context.update({'search_name': self.search_terms['name'], })
            duplicates = self.find_duplicates()
            if duplicates:
                context.update({'duplicate_items': duplicates})
            else:
                context.update({'similar_items': self.find_similar()})
            context['step_title'] = _('Select or create')

            slots_active = is_active_module('aristotle_mdr.contrib.slots')
            context['slots_active'] = slots_active
            context['show_slots_tab'] = slots_active or form.custom_fields

            if 'extra_formsets' in kwargs:
                fslist = kwargs['extra_formsets']
            else:
                fslist = self.get_extra_formsets(item=self.model)

            fscontext = self.get_formset_context(fslist)
            context.update(fscontext)

        context.update({'model_name': self.model._meta.verbose_name,
                        'model_name_plural': self.model._meta.verbose_name_plural.title,
                        'help': ConceptHelp.objects.filter(
                            app_label=self.model._meta.app_label,
                            concept_type=self.model._meta.model_name
                        ).first(),
                        'model_class': self.model,
                        'template_name': self.template_name,
                        'current_step': self.steps.current,
                        'additional_records_active': self.additional_records_active
                        })

        if cloud_enabled():
            from aristotle_cloud.contrib.custom_help.models import CustomHelp
            context.update({
                "custom_help": CustomHelp.objects.filter(
                    content_type__app_label=self.model._meta.app_label,
                    content_type__model=self.model._meta.model_name,
                ).first()
            })

        return context
 def __init__(self, *args, **kwargs):
     super(EditItemView, self).__init__(*args, **kwargs)
     self.slots_active = is_active_module('aristotle_mdr.contrib.slots')
     self.identifiers_active = is_active_module(
         'aristotle_mdr.contrib.identifiers')
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.slots_active = is_active_module('aristotle_mdr.contrib.slots')