예제 #1
0
def _bind_template_xslt(template_id, list_xslt, default_detail_xslt,
                        list_detail_xslt):
    """Bind the registry template with the XSLTs.

    Args:
        template_id: Registry template id.
        list_xslt: List XSLT.
        default_detail_xslt: Detail XSLT.
        list_detail_xslt:

    Returns:

    """
    from core_main_app.components.template_xsl_rendering import (
        api as template_xsl_rendering_api, )

    try:
        template_xsl_rendering_api.get_by_template_id(template_id)
    except exceptions.DoesNotExist:
        template_xsl_rendering_api.add_or_delete(
            template_id=template_id,
            list_xslt=list_xslt,
            default_detail_xslt=default_detail_xslt,
            list_detail_xslt=list_detail_xslt,
        )
    except Exception as e:
        raise Exception("Impossible to bind the template with XSLTs : " +
                        str(e))
예제 #2
0
    def _save_template_xslt(self, request):
        """Save a template xslt rendering.

        Args:
            request: Request.

        """
        try:
            # Get the list xslt instance
            try:
                list_xslt = xslt_transformation_api.get_by_id(request.POST.get('list_xslt'))
            except (Exception, exceptions.DoesNotExist):
                list_xslt = None
            # Get the detail xslt instance
            try:
                detail_xslt = xslt_transformation_api.get_by_id(request.POST.get('detail_xslt'))
            except (Exception, exceptions.DoesNotExist):
                detail_xslt = None

            template_xsl_rendering_api.add_or_delete(template_xsl_rendering_id=request.POST.get('id'),
                                                     template_id=request.POST.get('template'),
                                                     list_xslt=list_xslt, detail_xslt=detail_xslt)

            template = template_api.get(request.POST.get('template'))
            # Get template information (version)
            version_manager = version_manager_api.get_from_version(template)
            return HttpResponseRedirect(reverse(self.save_redirect, args=[version_manager.id]))
        except Exception, e:
            self.context.update({'errors': html_escape(e.message)})
            return self.rendering(request, self.template_name, context=self.context)
예제 #3
0
    def _save_template_xslt(self, request):
        """Save a template xslt rendering.

        Args:
            request: Request.

        """
        try:
            # Get the list xslt instance
            try:
                list_xslt = xslt_transformation_api.get_by_id(
                    request.POST.get("list_xslt"))
            except (Exception, exceptions.DoesNotExist):
                list_xslt = None

            # Get the list detail xslt instance
            try:
                list_detail_xslt = xslt_transformation_api.get_by_id_list(
                    request.POST.getlist("list_detail_xslt"))
            except (Exception, exceptions.DoesNotExist):
                list_detail_xslt = None

            # Get the default detail xslt instance
            try:
                default_detail_xslt = xslt_transformation_api.get_by_id(
                    request.POST.get("default_detail_xslt"))
            except (Exception, exceptions.DoesNotExist):
                default_detail_xslt = None

            template_xsl_rendering_api.add_or_delete(
                template_xsl_rendering_id=request.POST.get("id"),
                template_id=request.POST.get("template"),
                list_xslt=list_xslt,
                default_detail_xslt=default_detail_xslt,
                list_detail_xslt=list_detail_xslt,
            )

            template = template_api.get(request.POST.get("template"),
                                        request=request)
            # Get template information (version)
            version_manager = version_manager_api.get_from_version(
                template, request=request)
            return HttpResponseRedirect(
                reverse(self.save_redirect, args=[version_manager.id]))
        except Exception as e:
            self.context.update({"errors": html_escape(str(e))})
            return self.rendering(request,
                                  self.template_name,
                                  context=self.context)
예제 #4
0
def _bind_template_xslt(template_id, list_xslt, detail_xslt):
    """ Bind the registry template with the XSLTs.

    Args:
        template_id: Registry template id.
        list_xslt: List XSLT.
        detail_xslt: Detail XSLT.

    Returns:

    """
    try:
        template_xsl_rendering_api.get_by_template_id(template_id)
    except exceptions.DoesNotExist:
        template_xsl_rendering_api.add_or_delete(template_id=template_id,
                                                 list_xslt=list_xslt,
                                                 detail_xslt=detail_xslt)
    except Exception, e:
        raise Exception('Impossible to bind the template with XSLTs : ' +
                        e.message)