コード例 #1
0
    def _save_xslt(self, request):
        """Saves an XSLT.

        Args:
            request: Request.

        """
        try:
            # get the XSLT name
            name = request.POST['name']
            # get the file from the form
            xsd_file = request.FILES['upload_file']
            # read the content of the file
            xsd_data = read_xsd_file(xsd_file)
            xslt = XslTransformation(name=name,
                                     filename=xsd_file.name,
                                     content=xsd_data)
            xslt_transformation_api.upsert(xslt)

            return HttpResponseRedirect(reverse("admin:core_main_app_xslt"))
        except exceptions.NotUniqueError:
            self.context.update(
                {'errors': html_escape("This name already exists.")})
            return admin_render(request,
                                'core_main_app/admin/xslt/upload.html',
                                context=self.context)
        except Exception, e:
            self.context.update({'errors': html_escape(e.message)})
            return admin_render(request,
                                'core_main_app/admin/xslt/upload.html',
                                context=self.context)
コード例 #2
0
ファイル: views.py プロジェクト: usnistgov/core_composer_app
def manage_type_buckets(request, version_manager_id):
    """Manage buckets of a type.

    Args:
        request:
        version_manager_id:

    Returns:

    """
    # get the version manager
    version_manager = None

    try:
        version_manager = version_manager_api.get(version_manager_id,
                                                  request=request)
    except ModelError as e:
        logger.error("manage_type_buckets threw a ModelError: {0}".format(
            str(e)))
        return admin_render(
            request,
            "core_main_app/common/commons/error.html",
            context={"error": str(e)},
        )
    except DoesNotExist as e:
        # TODO: catch exception, redirect to error page
        logger.warning(
            "manage_type_buckets threw a DoesNotExist exception: {0}".format(
                str(e)))

    context = {
        "version_manager": version_manager,
        "buckets": bucket_api.get_all()
    }

    assets = {
        "css": ["core_composer_app/common/css/bucket.css"],
        "js": [{
            "path": "core_main_app/common/js/backtoprevious.js",
            "is_raw": True
        }],
    }
    if request.method == "POST":
        form = EditTypeBucketsForm(request.POST)
        if form.is_valid():
            buckets = request.POST.getlist("buckets")
            bucket_api.update_type_buckets(version_manager, buckets)
            return redirect(reverse("admin:core_composer_app_types"))
    else:
        form = EditTypeBucketsForm()

    context["form"] = form
    return admin_render(
        request,
        "core_composer_app/admin/buckets/edit.html",
        assets=assets,
        context=context,
    )
コード例 #3
0
def manage_type_versions(request, version_manager_id):
    """View that allows type versions management.

    Args:
        request:
        version_manager_id:

    Returns:

    """
    try:
        # get the version manager
        version_manager = version_manager_api.get(version_manager_id)
        context = get_context_manage_template_versions(version_manager)

        # updating context regarding the installed apps
        # default back_url initialization
        context.update({"back_url": "admin:core_composer_app_types"})
        if 'core_parser_app' in settings.INSTALLED_APPS:
            context.update(
                {"module_url": "admin:core_composer_app_type_modules"})
        if 'core_dashboard_app' in settings.INSTALLED_APPS:
            # the dashboard exposes the user's version managers
            # in this view, we come from the dashboard
            if version_manager.user:
                context.update({"back_url": "admin:core_dashboard_types"})

        assets = {
            "js": [{
                "path":
                'core_main_app/common/js/templates/versions/set_current.js',
                "is_raw": False
            }, {
                "path":
                'core_main_app/common/js/templates/versions/restore.js',
                "is_raw": False
            }, {
                "path":
                'core_main_app/common/js/templates/versions/modals/disable.js',
                "is_raw": False
            }]
        }

        modals = ["core_main_app/admin/templates/versions/modals/disable.html"]

        return admin_render(request,
                            'core_composer_app/admin/types/versions.html',
                            assets=assets,
                            modals=modals,
                            context=context)
    except Exception, e:
        return admin_render(request,
                            'core_main_app/common/commons/error.html',
                            context={'error': e.message})
コード例 #4
0
def manage_template_versions(request, version_manager_id):
    """View that allows template versions management.

    Args:
        request:
        version_manager_id:

    Returns:

    """
    try:
        # get the version manager
        version_manager = version_manager_api.get(version_manager_id,
                                                  request=request)
        context = get_context_manage_template_versions(version_manager)
        if "core_parser_app" in settings.INSTALLED_APPS:
            context.update(
                {"module_url": "admin:core_parser_app_template_modules"})

        assets = {
            "js": [
                {
                    "path":
                    "core_main_app/common/js/templates/versions/set_current.js",
                    "is_raw": False,
                },
                {
                    "path":
                    "core_main_app/common/js/templates/versions/restore.js",
                    "is_raw": False,
                },
                {
                    "path":
                    "core_main_app/common/js/templates/versions/modals/disable.js",
                    "is_raw": False,
                },
            ]
        }

        modals = ["core_main_app/admin/templates/versions/modals/disable.html"]

        return admin_render(
            request,
            "core_main_app/admin/templates/versions.html",
            assets=assets,
            modals=modals,
            context=context,
        )
    except Exception as e:
        return admin_render(
            request,
            "core_main_app/common/commons/error.html",
            context={"error": str(e)},
        )
コード例 #5
0
def xsl_template_view(request, metadata_format_id):
    assets = {
        "js": [
            AddObjectModalView.get_modal_js_path(),
            EditObjectModalView.get_modal_js_path(),
            DeleteObjectModalView.get_modal_js_path(),
        ],
    }

    modals = [
        AddObjectModalView.get_modal_html_path(),
        EditObjectModalView.get_modal_html_path(),
        DeleteObjectModalView.get_modal_html_path(),
    ]

    metadata_format = oai_metadata_format_api.get_by_id(metadata_format_id)

    context = {
        "xsl_templates": _get_xsl_templates(metadata_format),
        "metadata_format": metadata_format,
    }

    return admin_render(
        request,
        "core_oaipmh_provider_app/admin/registry/xsl_template.html",
        assets=assets,
        context=context,
        modals=modals,
    )
コード例 #6
0
def manage_templates(request):
    """View that allows template management.

    Args:
        request:

    Returns:

    """
    # get all current templates
    templates = template_version_manager_api.get_global_version_managers(
        request=request)

    context = {
        "object_name":
        "Template",
        "available":
        [template for template in templates if not template.is_disabled],
        "disabled":
        [template for template in templates if template.is_disabled],
    }

    assets = {}
    modals = []

    return admin_render(
        request,
        "core_main_app/admin/templates/list.html",
        assets=assets,
        context=context,
        modals=modals,
    )
コード例 #7
0
    def _save_custom_resources(self, request, template_id):
        """Saves an XSLT.

        Args:
            request: Request.
            template_id

        """
        try:
            # get the template
            template = template_api.get(template_id, request=request)

            # get the file from the form
            upload_file = request.FILES["json_file"].read().decode("utf-8")

            data = json.loads(upload_file)
            custom_resource_api.replace_custom_resources_by_template(
                template, data)

            return HttpResponseRedirect(
                reverse("admin:core_main_registry_app_custom_registry"))
        except Exception as e:
            self.context.update({"errors": html_escape(str(e))})
            return admin_render(request,
                                self.template_name,
                                context=self.context)
コード例 #8
0
def core_cache_view_index(request):
    """View that allows to see the cache status.

    Args:
        request:

    Returns:

    """
    context = {"object_name": "Cache"}
    error = None

    try:
        # get the active ontology
        active_ontology = query_ontology_api.get_active()

        # get the navigation from the cache
        nav_key = str(active_ontology.id)
        if nav_key in navigation_cache:
            navigation = navigation_cache.get(nav_key)
            context["navigation_id"] = str(navigation.id)
            # get the tree from the cache ### REMOVE if we don't display the tree
            tree_key = str(navigation.id)
            if tree_key in html_tree_cache:
                html_tree = html_tree_cache.get(tree_key)
                context["navigation_tree"] = html_tree
                number_cached_docs = 0
                cache_list = []
                listof_leaf = DataCached.get_all()

                for datacached in listof_leaf:
                    dict_keys_docs_id = datacached.cached_documents_dict
                    for dict_key_docid in dict_keys_docs_id:
                        key_docid_list = list(dict_key_docid.keys())
                        for key in key_docid_list:
                            if key in leaf_cache or key in link_cache:
                                number_cached_docs += 1
                    cache_list.append(datacached)
                context["nodes"] = cache_list
                context["number_cached_docs"] = number_cached_docs
    except exceptions.DoesNotExist:
        error = {
            "error": "An Ontology should be active to explore. Please contact an admin."
        }
    except Exception as e:
        error = {"error": "An error occurred when displaying the cache status."}
        logger.error("ERROR : {0}".format(str(e)))

    if error:
        context.update(error)

    assets = {}
    modals = []
    return admin_render(
        request,
        "core_explore_tree_app/admin/cache/index.html",
        assets=assets,
        context=context,
        modals=modals,
    )
コード例 #9
0
ファイル: views.py プロジェクト: usnistgov/core_composer_app
def manage_types(request):
    """View that allows type management.

    Args:
        request:

    Returns:

    """
    # get all types
    type_version_managers = type_version_manager_api.get_global_version_managers(
        request=request)
    # get buckets
    buckets = bucket_api.get_all()

    context = {
        "object_name":
        "Type",
        "available": [
            type_version_manager
            for type_version_manager in type_version_managers
            if not type_version_manager.is_disabled
        ],
        "disabled": [
            type_version_manager
            for type_version_manager in type_version_managers
            if type_version_manager.is_disabled
        ],
        "buckets":
        buckets,
    }

    assets = {
        "js": [
            {
                "path": "core_main_app/common/js/templates/list/restore.js",
                "is_raw": False,
            },
            {
                "path":
                "core_main_app/common/js/templates/list/modals/disable.js",
                "is_raw": False,
            },
            EditTemplateVersionManagerView.get_modal_js_path(),
        ],
        "css": ["core_composer_app/common/css/bucket.css"],
    }

    modals = [
        "core_main_app/admin/templates/list/modals/disable.html",
        EditTemplateVersionManagerView.get_modal_html_path(),
    ]

    return admin_render(
        request,
        "core_composer_app/admin/types/list.html",
        assets=assets,
        context=context,
        modals=modals,
    )
コード例 #10
0
    def get(request, *args, **kwargs):
        modals = [
            EditXSLTView.get_modal_html_path(),
            DeleteObjectModalView.get_modal_html_path(),
        ]

        assets = {
            "js": [
                EditXSLTView.get_modal_js_path(),
                DeleteObjectModalView.get_modal_js_path(),
            ],
        }

        context = {
            "object_name": "XSLT",
            "xslt": xslt_transformation_api.get_all(),
            "update_url": reverse("admin:core_main_app_upload_xslt"),
        }

        return admin_render(
            request,
            "core_main_app/admin/xslt/list.html",
            modals=modals,
            assets=assets,
            context=context,
        )
コード例 #11
0
def metadata_formats_view(request):
    assets = {
        "js": [
            AddObjectModalView.get_modal_js_path(),
            EditObjectModalView.get_modal_js_path(),
            DeleteObjectModalView.get_modal_js_path(),
        ],
        "css": [
            "core_oaipmh_provider_app/admin/css/registry/metadata_formats/page.css"
        ]
    }

    modals = [
        AddObjectModalView.get_modal_html_path(),
        EditObjectModalView.get_modal_html_path(),
        DeleteObjectModalView.get_modal_html_path(),
    ]

    order_field = 'metadata_prefix'
    default_metadata_formats = oai_metadata_format_api.get_all_default_metadata_format(order_by_field=order_field)
    metadata_formats = oai_metadata_format_api.get_all_custom_metadata_format(order_by_field=order_field)
    template_metadata_formats = _get_template_metadata_format(request, order_field=order_field)

    context = {
        'default_metadata_formats': default_metadata_formats,
        'metadata_formats': metadata_formats,
        'template_metadata_formats': template_metadata_formats
    }

    return admin_render(request, "core_oaipmh_provider_app/admin/registry/metadata_formats.html", assets=assets,
                        context=context, modals=modals)
コード例 #12
0
def manage_template(request):
    """ Manage exporters, Display as list

    Args:
        request:

    Returns:

    """
    schema_viewer_template_list = template_schema_viewer_api.get_all()

    context = {
        'schema_viewer_template_list': schema_viewer_template_list,
    }

    modals = []

    assets = {
        "js": [
            {
                "path": "core_schema_viewer_app/admin/list/schema_viewer.js",
                "is_raw": False
            },
        ],
        "css": []
    }

    return admin_render(request,
                        'core_schema_viewer_app/admin/list_templates.html',
                        assets=assets,
                        context=context,
                        modals=modals)
コード例 #13
0
def sets_view(request):
    assets = {
        "js": [
            {
                "path": "core_oaipmh_provider_app/admin/js/registry/sets/modals/init_select.js",
                "is_raw": False
            },
            {
                "path": "core_oaipmh_provider_app/admin/libs/fSelect/js/fSelect.js",
                "is_raw": False
            },
            AddObjectModalView.get_modal_js_path(),
            EditObjectModalView.get_modal_js_path(),
            DeleteObjectModalView.get_modal_js_path(),
        ],
        "css": [
            "core_oaipmh_provider_app/admin/libs/fSelect/css/fSelect.css",
            "core_oaipmh_provider_app/admin/css/registry/sets/add_set.css"
        ]
    }

    modals = [
        AddObjectModalView.get_modal_html_path(),
        EditObjectModalView.get_modal_html_path(),
        DeleteObjectModalView.get_modal_html_path(),
    ]

    context = {
        'sets': oai_provider_set_api.get_all(order_by_field='set_spec')
    }

    return admin_render(request, "core_oaipmh_provider_app/admin/registry/sets.html", assets=assets,
                        context=context, modals=modals)
コード例 #14
0
def get_visits_number(request):
    """View that allows to see the number of visits in the website.

    Args:
    request:

    Returns:

    """

    # Get all visits
    all_visits = visit_api.get_all_visits()
    hits = 0
    for visit in all_visits:
        sessions = visit.sessions
        # Count the number of sessions associated to the user
        hits = hits + len([v for v in sessions if v is not None])

    context = {"object_name": "Visits"}
    context["visits_hits"] = hits
    context["visits"] = all_visits

    assets = {}
    modals = []

    return admin_render(
        request,
        "ammd/admin/visit/visits_index.html",
        assets=assets,
        context=context,
        modals=modals,
    )
コード例 #15
0
def manage_templates(request):
    """View that allows template management.

    Args:
        request:

    Returns:

    """
    # get all current templates
    templates = template_version_manager_api.get_global_version_managers()

    context = {
        'object_name': 'Template',
        'available': [template for template in templates if not template.is_disabled],
        'disabled': [template for template in templates if template.is_disabled]
    }

    assets = {}
    modals = []

    return admin_render(request,
                        'core_main_app/admin/templates/list.html',
                        assets=assets,
                        context=context,
                        modals=modals)
コード例 #16
0
def manage_query_ontology(request):
    """ View that allows ontology management.

    Args:
        request:

    Returns:

    """
    # get all ontologies
    ontologies = query_ontology_api.get_all()

    context = {
        'object_name':
        'OWL files',
        'available': [
            ontology for ontology in ontologies
            if ontology.status != QueryOntologyStatus.disabled.value
        ],
        'disabled': [
            ontology for ontology in ontologies
            if ontology.status == QueryOntologyStatus.disabled.value
        ],
        'status':
        QueryOntologyStatus.__members__
    }

    assets = {
        "js": [
            {
                "path":
                'core_explore_tree_app/admin/js/query_ontology/list/activate.js',
                "is_raw": False
            },
            {
                "path":
                'core_explore_tree_app/admin/js/query_ontology/list/disable.js',
                "is_raw": False
            },
            {
                "path":
                'core_explore_tree_app/admin/js/query_ontology/list/restore.js',
                "is_raw": False
            },
            EditOntologyView.get_modal_js_path(),
            DeleteObjectModalView.get_modal_js_path(),
        ]
    }

    modals = [
        EditOntologyView.get_modal_html_path(),
        DeleteObjectModalView.get_modal_html_path(),
    ]

    return admin_render(request,
                        'core_explore_tree_app/admin/query_ontology/list.html',
                        assets=assets,
                        context=context,
                        modals=modals)
コード例 #17
0
ファイル: views.py プロジェクト: cdcs-repos/core_main_app
 def common_render(self,
                   request,
                   template_name,
                   modals=None,
                   assets=None,
                   context=None):
     return admin_render(request, template_name, modals, assets, context) if self.administration \
         else render(request, template_name, modals, assets, context)
コード例 #18
0
    def get(self, request, pk):
        """View that allows module management

        Args:
            request:
            pk:

        Returns:

        """
        assets = {
            "js": [
                {"path": "core_main_app/common/js/XMLTree.js", "is_raw": True},
                {
                    "path": "core_parser_app/common/js/module_manager.js",
                    "is_raw": False,
                },
            ],
            "css": [
                "core_main_app/common/css/XMLTree.css",
                "core_parser_app/common/css/modules.css",
            ],
        }

        modals = ["core_parser_app/common/modals/add_module.html"]

        try:
            return admin_render(
                request,
                "core_parser_app/common/module_manager.html",
                modals=modals,
                assets=assets,
                context=get_context(
                    pk,
                    self.back_to_previous_url,
                    False,
                    "Modules Manager",
                    request=request,
                ),
            )
        except Exception as e:
            return admin_render(
                request,
                "core_main_app/common/commons/error.html",
                context={"error": str(e)},
            )
コード例 #19
0
ファイル: views.py プロジェクト: cdcs-repos/core_main_app
    def post(self, request, *args, **kwargs):
        form = self.form_class(request.POST, request.FILES)
        self.context.update({'upload_form': form})

        if form.is_valid():
            return self._save_xslt(request)
        else:
            # Display error from the form
            return admin_render(request, self.template_name, context=self.context)
コード例 #20
0
def identity_view(request):
    assets = {
        "js": [
            {
                "path":
                "core_oaipmh_provider_app/admin/js/registry/identity/check_registry.js",
                "is_raw": False,
            },
            EditObjectModalView.get_modal_js_path(),
        ],
        "css": [
            "core_oaipmh_provider_app/admin/css/registry/identity/table_info.css"
        ],
    }

    modals = [EditObjectModalView.get_modal_html_path()]

    info = oai_settings_api.get()
    data_provider = {
        "id":
        info.id,
        "name":
        info.repository_name,
        "baseURL":
        request.build_absolute_uri(
            reverse("core_oaipmh_provider_app_server_index")),
        "protocol_version":
        settings.OAI_PROTOCOL_VERSION,
        "admins": (email for name, email in settings.OAI_ADMINS),
        "deleted":
        settings.OAI_DELETED_RECORD,
        "granularity":
        settings.OAI_GRANULARITY,
        "identifier_scheme":
        settings.OAI_SCHEME,
        "repository_identifier":
        info.repository_identifier,
        "identifier_delimiter":
        settings.OAI_DELIMITER,
        "sample_identifier":
        settings.OAI_SAMPLE_IDENTIFIER,
        "enable_harvesting":
        info.enable_harvesting,
    }

    context = {
        "data_provider": data_provider,
        "object_name": info.repository_name
    }

    return admin_render(
        request,
        "core_oaipmh_provider_app/admin/registry/identity.html",
        assets=assets,
        context=context,
        modals=modals,
    )
コード例 #21
0
    def post(self, request, *args, **kwargs):
        template_id = kwargs.pop("template_id")
        form = self.form_class(request.POST, request.FILES)
        self.context.update({"upload_form": form})

        if form.is_valid():
            return self._save_custom_resources(request, template_id)
        else:
            # Display error from the form
            return admin_render(request, self.template_name, context=self.context)
コード例 #22
0
def admin_home(request):
    """Admin home view.

    Args:
        request:

    Returns:

    """
    return admin_render(request, 'core_main_app/admin/dashboard.html')
コード例 #23
0
def manage_exporters(request):
    """Manage exporters, Display as list

    Args:
        request:

    Returns:

    """
    exporter_list = exporter_api.get_all()
    exporter_xslt_list = exporter_api.get_all_by_url(
        exporter_constants.XSL_URL)

    context = {
        "exporters_list": exporter_list,
        "exporter_xslt_list": exporter_xslt_list,
    }

    modals = [
        "core_exporters_app/admin/exporters/list/modals/associated_templates.html",
        "xsl/admin/exporters/list/modals/add.html",
        EditExporterView.get_modal_html_path(),
    ]

    assets = {
        "js": [
            {
                "path": "core_main_app/libs/fSelect/js/fSelect.js",
                "is_raw": False
            },
            {
                "path":
                "core_exporters_app/admin/js/exporters/list/modals/associated_templates.js",
                "is_raw": False,
            },
            {
                "path": "xsl/admin/js/exporters/list/modals/add.js",
                "is_raw": False
            },
            EditExporterView.get_modal_js_path(),
        ],
        "css": [
            "core_main_app/libs/fSelect/css/fSelect.css",
            "core_exporters_app/admin/css/exporters/list/list_exporters.css",
        ],
    }

    return admin_render(
        request,
        "core_exporters_app/admin/exporters/list_exporters.html",
        assets=assets,
        context=context,
        modals=modals,
    )
コード例 #24
0
def data_migration(request):
    """Migrate data to a new template version

    Args:
        request:

    Returns:
    """
    assets = {
        "js": [
            {
                "path":
                "core_main_app/admin/js/templates/data_migration.raw.js",
                "is_raw": True,
            },
            {
                "path": "core_main_app/admin/js/templates/data_migration.js",
                "is_raw": False,
            },
        ],
        "css": ["core_main_app/admin/css/data_migration.css"],
    }

    # get all current templates
    templates = []
    template_managers = [
        template for template in template_version_manager_api.
        get_global_version_managers(request=request)
        if not template.is_disabled
    ]

    for template_manager in template_managers:
        version_index = 1
        for version in template_manager.versions:
            templates.append({
                "id":
                version,
                "title":
                f"{template_manager.title} (version {version_index})",
            })
            version_index += 1

    context = {
        "templates": templates,
        "xslt": xslt_transformation_api.get_all()
    }

    return admin_render(
        request,
        "core_main_app/admin/templates/data_migration.html",
        assets=assets,
        context=context,
    )
コード例 #25
0
def upload_query_ontology(request):
    """Upload ontology.

    Args:
        request:

    Returns:

    """
    assets = {
        "js": [{"path": "core_main_app/common/js/backtoprevious.js", "is_raw": True}]
    }

    context = {
        "object_name": "OWL files",
        "url": reverse("admin:core_explore_tree_app_upload"),
        "redirect_url": reverse("admin:core_explore_tree_app_query_ontology"),
    }

    # method is POST
    if request.method == "POST":
        form = UploadQueryOntologyForm(request.POST, request.FILES, request=request)
        context["upload_form"] = form

        if form.is_valid():
            try:
                # save the query ontology
                _save_query_ontology(request, context)
                # redirect to the list of query ontology
                return HttpResponseRedirect(
                    reverse("admin:core_explore_tree_app_query_ontology")
                )
            except exceptions.NotUniqueError:
                context["errors"] = html_escape(
                    "An Ontology with the same name already exists. "
                    "Please choose another name."
                )
            except Exception as e:
                context["errors"] = html_escape(str(e))
    # method is GET
    else:
        # render the form to upload a query ontology
        context["upload_form"] = UploadQueryOntologyForm(request=request)

    # render the upload page
    return admin_render(
        request,
        "core_explore_tree_app/admin/query_ontology/upload.html",
        assets=assets,
        context=context,
    )
コード例 #26
0
    def get(self, request, pk):
        """ View that allows module management

        Args:
            request:
            pk:

        Returns:

        """
        assets = {
            "js": [{
                "path": 'core_main_app/common/js/XMLTree.js',
                "is_raw": True
            }, {
                "path": 'core_parser_app/common/js/module_manager.js',
                "is_raw": False
            }],
            "css": [
                'core_main_app/common/css/XMLTree.css',
                'core_parser_app/common/css/modules.css'
            ]
        }

        modals = ["core_parser_app/common/modals/add_module.html"]

        try:
            return admin_render(request,
                                'core_parser_app/common/module_manager.html',
                                modals=modals,
                                assets=assets,
                                context=get_context(pk,
                                                    self.back_to_previous_url,
                                                    False, "Modules Manager"))
        except Exception, e:
            return admin_render(request,
                                'core_main_app/common/commons/error.html',
                                context={'error': e.message})
コード例 #27
0
def add_repository(request):
    """Add new repository.

    Args:
        request:

    Returns:

    """
    context = {}
    new_form = False
    if request.method == "POST":
        form = RepositoryForm(request.POST)
        context["repository_form"] = form
        if form.is_valid():
            try:
                instance_object = api_instance.add_instance(
                    request.POST["name"],
                    request.POST["endpoint"],
                    request.POST["client_id"],
                    request.POST["client_secret"],
                    request.POST["username"],
                    request.POST["password"],
                    request.POST["timeout"],
                )
                if instance_object is not None:
                    return HttpResponseRedirect(
                        reverse(
                            "admin:core_federated_search_app_repositories"))
            except common_exception.NotUniqueError:
                context[
                    "error"] = "An instance with the same parameters already exists."
            except SSLError:
                context["error"] = "Unable to reach the remote HTTPS instance."
            except Exception as api_exception:
                context["error"] = str(api_exception)
    else:
        new_form = True

    if new_form:
        # render the form to upload a template
        context["repository_form"] = RepositoryForm()

    return admin_render(
        request,
        "core_federated_search_app/admin/repositories/add_repository.html",
        assets=None,
        context=context,
        modals=None,
    )
コード例 #28
0
def _upload_type_response(request, assets, context):
    """Render type upload response.

    Args:
        request:
        context:

    Returns:

    """
    return admin_render(request,
                        'core_composer_app/admin/types/upload.html',
                        assets=assets,
                        context=context)
コード例 #29
0
ファイル: views.py プロジェクト: cdcs-repos/core_main_app
def _upload_template_response(request, assets, context):
    """Render template upload response.

    Args:
        request:
        context:

    Returns:

    """
    return admin_render(request,
                        'core_main_app/admin/templates/upload.html',
                        assets=assets,
                        context=context)
コード例 #30
0
def manage_templates(request):
    """View that allows template management.

    Args:
        request:

    Returns:

    """
    # get all current templates
    templates = template_version_manager_api.get_global_version_managers(
        request=request)

    context = {
        "object_name":
        "Template",
        "available":
        [template for template in templates if not template.is_disabled],
        "disabled":
        [template for template in templates if template.is_disabled],
    }

    assets = {
        "js": [
            {
                "path": "core_main_app/common/js/templates/list/restore.js",
                "is_raw": False,
            },
            {
                "path":
                "core_main_app/common/js/templates/list/modals/disable.js",
                "is_raw": False,
            },
            EditTemplateVersionManagerView.get_modal_js_path(),
        ]
    }

    modals = [
        "core_main_app/admin/templates/list/modals/disable.html",
        EditTemplateVersionManagerView.get_modal_html_path(),
    ]

    return admin_render(
        request,
        "core_main_app/admin/templates/list.html",
        assets=assets,
        context=context,
        modals=modals,
    )