1 6 11 12 14 15 16 17 18 19 20 21 22 24 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 55 56 58 59 60 61 62 63 64 65 68 70 71 72 75 77 78 79 80 81 82 83 84 |
# -*- coding: utf-8 -*-
#from pages.admin.utils import set_body_pagelink, delete_body_pagelink_by_language
""" Switch the status of a page. """ if request.method == 'POST': page = Page.objects.get(pk=page_id) page.status = int(request.POST['status']) page.save() return HttpResponse(unicode(page.status)) raise Http404
"""Modify the content of a page.""" if 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_id, content) else: Content.objects.set_or_create_content(page, language_id, content_id, content) page.invalidate() # to update last modification date page.save()
return HttpResponse('ok') raise Http404
page = get_object_or_404(Page, pk=page_id) for c in Content.objects.filter(page=page,language=language_id): c.delete()
destination = request.REQUEST.get('next', request.META.get('HTTP_REFERER', '/admin/pages/page/%s/' % page_id)) return HttpResponseRedirect(destination)
"""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()
"""Get the content for a particular page""" content_instance = get_object_or_404(Content, pk=content_id) return HttpResponse(content_instance.body)
"""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 return "admin/pages/page/sub_menu.html", locals()
|