def get_context_data(self, *args, **kwargs):
        context = super().get_context_data(*args, **kwargs)
        context.update({
            'model_name_plural':
            self.model._meta.verbose_name_plural.title,
            'model_name':
            self.model._meta.verbose_name.title,
            'model':
            self.model._meta.model_name,
            'app_label':
            self.model._meta.app_label,
            'item':
            self.item,
            'model_class':
            self.model,
            'help':
            ConceptHelp.objects.filter(
                app_label=self.model._meta.app_label,
                concept_type=self.model._meta.model_name).first(),
        })

        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().__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.º 3
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
Ejemplo n.º 4
0
 def cloud_help_handler(ct, field_name, kwargs):
     """
     This static method checks the availability of Aristotle Cloud and
     updates the kwargs with the Custom Help object for a specific model.
     :param ct: Content Type (Model) name of the Help Object requested.
     :param field_name: Specific field name of the Content Type (Model).
     :param kwargs: key_word_arguments to be updated with the Custom Help required.
     """
     custom_help = None
     if cloud_enabled():
         from aristotle_cloud.contrib.custom_help.models import CustomHelp
         try:
             custom_help = ct.custom_help.field_help.get(field_name, None)
         except CustomHelp.DoesNotExist:
             pass
         kwargs.update({'custom_help': custom_help})
Ejemplo n.º 5
0
    def get_context_data(self, **kwargs):
        from aristotle_mdr.contrib.custom_fields.models import CustomField

        context = super().get_context_data(**kwargs)

        model = self.kwargs['model']

        ct = ContentType.objects.get(app_label=self.app, model=model)
        context['model'] = ct.model_class()
        custom_help = None

        if cloud_enabled():
            from aristotle_cloud.contrib.custom_help.models import CustomHelp
            custom_help = CustomHelp.objects.filter(content_type=ct).first()

        context['custom_help'] = custom_help

        context['custom_fields'] = CustomField.objects.filter(allowed_model=ct)

        return context
    def get_base_download_context(self) -> Dict[str, Any]:

        aristotle_settings = fetch_aristotle_settings()

        context = {
            'infobox_identifier_name':
            aristotle_settings.get('INFOBOX_IDENTIFIER_NAME', _("Item ID")),
            'user':
            self.user,
            'options':
            self.options,
            'config':
            aristotle_settings,
            'aristotle_cloud_is_active':
            cloud_enabled(),
            'export_date':
            now(),
            'viewable_ids':
            get_lazy_viewable_ids(self.user)
        }
        context['CURRENT_CLIENT_BASE'] = getattr(settings,
                                                 'CURRENT_CLIENT_BASE', None)
        return context