Ejemplo n.º 1
0
 def render_toolbar(self, request):
     from cms.plugin_pool import plugin_pool
     from cms.utils.admin import get_admin_menu_item_context
     """
     Renders the Toolbar.
     """
     auth = request.user.is_staff or request.user.is_superuser
     edit = request.session.get('cms_edit', False) and auth
     page = request.current_page
     move_dict = []
     if edit and page:
         template = get_template_from_request(request)
         placeholders = get_placeholders(template)
         for placeholder in placeholders:
             d = {}
             name = cms_settings.CMS_PLACEHOLDER_CONF.get(
                 "%s %s" % (page.get_template(), placeholder),
                 {}).get("name", None)
             if not name:
                 name = cms_settings.CMS_PLACEHOLDER_CONF.get(
                     placeholder, {}).get("name", None)
             if not name:
                 name = title(placeholder)
             else:
                 name = _(name)
             d['name'] = name
             plugins = plugin_pool.get_all_plugins(placeholder, page)
             d['plugins'] = []
             for p in plugins:
                 d['plugins'].append(p.value)
             d['type'] = placeholder
             move_dict.append(d)
         data = safe(simplejson.dumps(move_dict))
     else:
         data = {}
     if auth and page:
         context = get_admin_menu_item_context(request,
                                               page,
                                               filtered=False)
     else:
         context = {}
     context.update({
         'auth': auth,
         'page': page,
         'templates': cms_settings.CMS_TEMPLATES,
         'auth_error': not auth and 'cms_username' in request.POST,
         'placeholder_data': data,
         'edit': edit,
         'moderator': cms_settings.CMS_MODERATOR,
         'CMS_MEDIA_URL': cms_settings.CMS_MEDIA_URL,
     })
     #from django.core.context_processors import csrf
     #context.update(csrf(request))
     return render_to_string('cms/toolbar/toolbar.html', context,
                             RequestContext(request))
Ejemplo n.º 2
0
 def render_toolbar(self, request):
     from cms.plugin_pool import plugin_pool
     from cms.utils.admin import get_admin_menu_item_context
     """
     Renders the Toolbar.
     """
     auth = request.user.is_staff or request.user.is_superuser
     edit = request.session.get('cms_edit', False) and auth
     page = request.current_page
     move_dict = []
     if edit and page:
         template = get_template_from_request(request)
         placeholders = get_placeholders(template)
         for placeholder in placeholders:
             d = {}
             name = cms_settings.CMS_PLACEHOLDER_CONF.get("%s %s" % (page.get_template(), placeholder), {}).get("name", None)
             if not name:
                 name = cms_settings.CMS_PLACEHOLDER_CONF.get(placeholder, {}).get("name", None)
             if not name:
                 name = title(placeholder)
             else:
                 name = _(name)
             d['name'] = name
             plugins = plugin_pool.get_all_plugins(placeholder, page)
             d['plugins'] = []
             for p in plugins:
                 d['plugins'].append(p.value)
             d['type'] = placeholder
             move_dict.append(d)
         data = safe(simplejson.dumps(move_dict))
     else:
         data = {}
     if auth and page:
         context = get_admin_menu_item_context(request, page, filtered=False)
     else:
         context = {}
     context.update({
         'auth':auth,
         'page':page,
         'templates': cms_settings.CMS_TEMPLATES,
         'auth_error':not auth and 'cms_username' in request.POST,
         'placeholder_data':data,
         'edit':edit,
         'moderator': cms_settings.CMS_MODERATOR,
         'CMS_MEDIA_URL': cms_settings.CMS_MEDIA_URL,
     })
     #from django.core.context_processors import csrf
     #context.update(csrf(request))
     return render_to_string('cms/toolbar/toolbar.html', context, RequestContext(request))
Ejemplo n.º 3
0
    def get_context(self, context, page):
        request = context['request']

        if 'cl' in context:
            filtered = context['cl'].is_filtered()
        elif 'filtered' in context:
            filtered = context['filtered']

        language = context['preview_language']
        # following function is newly used for getting the context per item (line)
        # if something more will be required, then get_admin_menu_item_context
        # function have to be updated.
        # This is done because item can be reloaded after some action over ajax.
        context.update(get_admin_menu_item_context(request, page, filtered, language))
        return context
Ejemplo n.º 4
0
    def get_context(self, context, page):
        request = context["request"]

        if context.has_key("cl"):
            filtered = context["cl"].is_filtered()
        elif context.has_key("filtered"):
            filtered = context["filtered"]
        language = context["preview_language"]

        # following function is newly used for getting the context per item (line)
        # if something more will be required, then get_admin_menu_item_context
        # function have to be updated.
        # This is done because item can be reloaded after some action over ajax.
        context.update(get_admin_menu_item_context(request, page, filtered, language))
        return context
Ejemplo n.º 5
0
    def get_context(self, context, page):
        request = context['request']

        if context.has_key("cl"):
            filtered = context['cl'].is_filtered()
        elif context.has_key('filtered'):
            filtered = context['filtered']

        # following function is newly used for getting the context per item (line)
        # if something more will be required, then get_admin_menu_item_context
        # function have to be updated.
        # This is done because item can be reloaded after some action over ajax.
        context.update(get_admin_menu_item_context(request, page, filtered))

        # this here is just context specific for menu rendering - items itself does
        # not use any of following variables
        #context.update({
        #    'no_children': no_children,
        #})
        return context
Ejemplo n.º 6
0
 def get_context(self, context, page):
     request = context['request']
     
     if context.has_key("cl"):
         filtered = context['cl'].is_filtered()
     elif context.has_key('filtered'):
         filtered = context['filtered']
     
     # following function is newly used for getting the context per item (line)
     # if something more will be required, then get_admin_menu_item_context
     # function have to be updated. 
     # This is done because item can be reloaded after some action over ajax.
     context.update(get_admin_menu_item_context(request, page, filtered))
     
     # this here is just context specific for menu rendering - items itself does
     # not use any of following variables
     #context.update({
     #    'no_children': no_children,
     #})
     return context
Ejemplo n.º 7
0
def show_admin_menu(context, page):  # , no_children=False):
    """Render the admin table of pages"""
    request = context["request"]

    if context.has_key("cl"):
        filtered = context["cl"].is_filtered()
    elif context.has_key("filtered"):
        filtered = context["filtered"]

    # following function is newly used for getting the context per item (line)
    # if something more will be required, then get_admin_menu_item_context
    # function have to be updated.
    # This is done because item can be reloaded after some action over ajax.
    context.update(get_admin_menu_item_context(request, page, filtered))

    # this here is just context specific for menu rendering - items itself does
    # not use any of following variables
    # context.update({
    #    'no_children': no_children,
    # })
    return context