Пример #1
0

def list_pages_ajax(request, invalid_move=False):
    """Render pages table for ajax function."""
    language = get_language_from_request(request)
    pages = Page.objects.filter(parent__isnull=True)
    context = {
        'invalid_move': invalid_move,
        'language': language,
        'pages': pages,
    }
    return "admin/pages/page/change_list_table.html", context


list_pages_ajax = staff_member_required(list_pages_ajax)
list_pages_ajax = auto_render(list_pages_ajax)


@csrf_exempt
def modify_content(request, page_id, content_type, language_id):
    """Modify the content of a page."""
    page = get_object_or_404(Page, pk=page_id)
    perm = PagePermission(request.user).check('change',
                                              page=page,
                                              lang=language_id,
                                              method='POST')
    if perm and request.method == 'POST':
        content = request.POST.get('content', False)
        if not content:
            raise Http404
        page = Page.objects.get(pk=page_id)
Пример #2
0
        return HttpResponse(unicode(page.status))
    raise Http404
change_status = staff_member_required(change_status)

def list_pages_ajax(request, invalid_move=False):
    """Render pages table for ajax function."""
    language = get_language_from_request(request)
    pages = Page.objects.filter(parent__isnull=True)
    context = {
        'invalid_move':invalid_move,
        'language': language,
        'pages': pages,
    }
    return "admin/pages/page/change_list_table.html", context
list_pages_ajax = staff_member_required(list_pages_ajax)
list_pages_ajax = auto_render(list_pages_ajax)

@csrf_exempt
def modify_content(request, page_id, content_type, language_id):
    """Modify the content of a page."""
    page = get_object_or_404(Page, pk=page_id)
    perm = PagePermission(request.user).check('change', page=page,
            lang=language_id, method='POST')
    if perm and request.method == 'POST':
        content = request.POST.get('content', False)
        if not content:
            raise Http404
        page = Page.objects.get(pk=page_id)
        if settings.PAGE_CONTENT_REVISION:
            Content.objects.create_content_if_changed(page, language_id,
                                                      content_type, content)
Пример #3
0
    
    template_name = current_page.get_template()
    
    if request.is_ajax():
        template_name = "body_%s" % template_name

    if current_page:
        context['current_page'] = current_page

    if settings.PAGE_EXTRA_CONTEXT:
        context.update(settings.PAGE_EXTRA_CONTEXT())

    if delegation and current_page.delegate_to:
        urlconf = get_urlconf(current_page.delegate_to)
        result = resolve('/', urlconf)
        if len(result):
            view, args, kwargs = result
            kwargs['current_page'] = current_page
            kwargs['path'] = path
            kwargs['lang'] = lang
            kwargs['pages_navigation'] = pages_navigation
            return view(
                request,
                *args,
                **kwargs
            )

    return template_name, context

details = auto_render(details)
Пример #4
0
    destination = request.REQUEST.get('next', request.META.get('HTTP_REFERER', '/admin/pages/page/%s/' % page_id))
    return HttpResponseRedirect(destination)
delete_content = staff_member_required(delete_content)
    
    
def traduction(request, page_id, language_id):
    """Traduction helper."""
    page = Page.objects.get(pk=page_id)
    context = {}
    lang = language_id
    placeholders = get_placeholders(page.get_template())
    if Content.objects.get_content(page, language_id, "title") is None:
        language_error = True
    return 'pages/traduction_helper.html', locals()
traduction = staff_member_required(traduction)
traduction = auto_render(traduction)

def get_content(request, page_id, content_id):
    """Get the content for a particular page"""
    content_instance = get_object_or_404(Content, pk=content_id)
    return HttpResponse(content_instance.body)
get_content = staff_member_required(get_content)
get_content = auto_render(get_content)

def sub_menu(request, page_id):
    """Render the children of the requested page with the sub_menu
    template."""
    page = Page.objects.get(id=page_id)
    pages = page.children.all()
    has_permission = page.has_page_permission(request)
    page_languages = settings.PAGE_LANGUAGES
Пример #5
0
from django.template import RequestContext
from pages.testproj.documents.models import Document
from pages.http import auto_render

def document_view(request, *args, **kwargs):
    context = RequestContext(request, kwargs)
    if kwargs.get('current_page', False):
        documents = Document.objects.filter(page=kwargs['current_page'])
        context['documents'] = documents
    if kwargs.has_key('document_id'):
        document = Document.objects.get(pk=int(kwargs['document_id']))
        context['document'] = document
    context['in_document_view'] = True
    return 'pages/examples/index.html', context

document_view = auto_render(document_view)
Пример #6
0
from django.template import RequestContext
from pages.testproj.documents.models import Document
from pages.http import auto_render


def document_view(request, *args, **kwargs):
    context = RequestContext(request, kwargs)
    if kwargs.get('current_page', False):
        documents = Document.objects.filter(page=kwargs['current_page'])
        context['documents'] = documents
    if kwargs.has_key('document_id'):
        document = Document.objects.get(pk=int(kwargs['document_id']))
        context['document'] = document
    context['in_document_view'] = True
    return 'pages/examples/index.html', context


document_view = auto_render(document_view)