コード例 #1
0
ファイル: mixins.py プロジェクト: digideskio/djedi-cms
    def inject_admin_panel(self, request, response):
        user = getattr(request, 'user', None)

        # Validate user permissions
        if not has_permission(user):
            return

        # Do not inject admin panel in admin
        try:
            djedi_cms_url = reverse('admin:djedi:cms')
        except NoReverseMatch:
            raise ImproperlyConfigured('Could not find djedi in your url conf, '
                                       'enable django admin or include djedi.urls within the admin namespace.')
        else:
            admin_prefix = djedi_cms_url.strip('/').split('/')[0]
            if request.path.startswith('/' + admin_prefix):
                return

        # Do not inject admin panel on gzipped responses
        if 'gzip' in response.get('Content-Encoding', ''):
            return

        # Only inject admin panel in html pages
        if response.get('Content-Type', '').split(';')[0] not in ('text/html', 'application/xhtml+xml'):
            return

        embed = self.render_cms()
        self.body_append(response, embed)
コード例 #2
0
    def inject_admin_panel(self, request, response):
        user = getattr(request, 'user', None)

        # Validate user permissions
        if not has_permission(user):
            return

        # Do not inject admin panel in admin
        try:
            djedi_cms_url = reverse('admin:djedi:cms')
        except NoReverseMatch:
            raise ImproperlyConfigured(
                'Could not find djedi in your url conf, '
                'enable django admin or include djedi.urls within the admin namespace.'
            )
        else:
            admin_prefix = djedi_cms_url.strip('/').split('/')[0]
            if request.path.startswith('/' + admin_prefix):
                return

        # Do not inject admin panel on gzipped responses
        if 'gzip' in response.get('Content-Encoding', ''):
            return

        # Only inject admin panel in html pages
        if response.get('Content-Type',
                        '').split(';')[0] not in ('text/html',
                                                  'application/xhtml+xml'):
            return

        embed = self.render_cms()
        self.body_append(response, embed)
コード例 #3
0
def djedi_admin(context):
    output = u''

    if has_permission(context.get('request')):
        defaults = dict((node.uri.clone(version=None), node.initial)
                        for node in pipeline.history.list('get'))
        output = render_embed(nodes=defaults)

    # Clear pipeline
    pipeline.clear()

    return output
コード例 #4
0
ファイル: djedi_admin.py プロジェクト: manlan2/djedi-cms
def djedi_admin(context):
    output = u''

    if has_permission(context.get('user')):
        defaults = dict((node.uri.clone(version=None), node.initial) for node in pipeline.history.list('get'))
        output = render_to_string('djedi/cms/embed.html', {
            'json_nodes': json.dumps(defaults).replace('</', '\\x3C/'),
        })

    # Clear pipeline
    pipeline.clear()

    return output
コード例 #5
0
ファイル: djedi_tags.py プロジェクト: ZipFile/djedi-cms
def djedi_toolbar(context):
    user = context.get('user', None)

    # Validate user permissions
    if not has_permission(user) or context.get('djedi_toolbar', False):
        return ''

    context['djedi_toolbar'] = True

    defaults = dict((node.uri.clone(version=None), node.initial) for node in pipeline.history.list('get'))

    return render_to_string('djedi/cms/embed.html', {
        'json_nodes': json.dumps(defaults),
    })
コード例 #6
0
ファイル: mixins.py プロジェクト: manlan2/djedi-cms
    def inject_admin_panel(self, request, response):
        user = getattr(request, 'user', None)

        # Do not inject admin panel on gzipped responses
        if 'gzip' in response.get('Content-Encoding', ''):
            _log.debug('gzip detected, not injecting panel.')
            return

        # Only inject admin panel in html pages
        content_type = response.get('Content-Type', '').split(';')[0]
        if content_type not in ('text/html', 'application/xhtml+xml'):
            _log.debug('Non-HTML Content-Type detected, not injecting')
            return

        # Do not inject admin panel in admin
        try:
            admin_prefix = reverse('admin:index')
        except NoReverseMatch:
            _log.debug('No reverse match for "admin:index", can\'t detect '
                       'django-admin pages')
        else:
            if request.path.startswith(admin_prefix):
                _log.debug(
                    'admin page detected, not injecting panel. admin_prefix=%r',
                    admin_prefix)
                return

        try:
            djedi_cms_url = reverse('admin:djedi:cms')
        except NoReverseMatch:
            raise ImproperlyConfigured(
                'Could not find djedi in your url conf, '
                'enable django admin or include '
                'djedi.urls within the admin namespace.')
        else:
            if request.path.startswith(djedi_cms_url):
                _log.debug('djedi page detected, not injecting panel')
                return

        # Validate user permissions
        if not has_permission(user):
            _log.debug('insufficient permissions, not injecting.')
            return

        embed = self.render_cms()
        self.body_append(response, embed)
コード例 #7
0
ファイル: mixins.py プロジェクト: andreif/djedi-cms
    def inject_admin_panel(self, request, response):
        # Do not inject admin panel on gzipped responses
        if 'gzip' in response.get('Content-Encoding', ''):
            _log.debug('gzip detected, not injecting panel.')
            return

        # Only inject admin panel in html pages
        content_type = response.get('Content-Type', '').split(';')[0]
        if content_type not in ('text/html', 'application/xhtml+xml'):
            _log.debug('Non-HTML Content-Type detected, not injecting')
            return

        # Do not inject admin panel in admin
        try:
            admin_prefix = reverse('admin:index')
        except NoReverseMatch:
            _log.debug(
                'No reverse match for "admin:index", can\'t detect '
                'django-admin pages'
            )
        else:
            if request.path.startswith(admin_prefix):
                _log.debug(
                    'admin page detected, not injecting panel. admin_prefix=%r',
                    admin_prefix
                )
                return

        try:
            djedi_cms_url = reverse('admin:djedi:cms')
        except NoReverseMatch:
            raise ImproperlyConfigured('Could not find djedi in your url conf, '
                                       'enable django admin or include '
                                       'djedi.urls within the admin namespace.')
        else:
            if request.path.startswith(djedi_cms_url):
                _log.debug('djedi page detected, not injecting panel')
                return

        # Validate user permissions
        if not has_permission(request):
            _log.debug('insufficient permissions, not injecting.')
            return

        embed = self.render_cms()
        self.body_append(response, embed)