Esempio n. 1
0
def page(request, slug="index"):
    if request.method == "GET":
        if exists(slug):
            page = get_page(slug)
            return dict(page=page,
                        edit=request.GET.get('edit', False),
                        exists=True)
        else:
            return dict(exists=False,
                        slug=slug)
    else:
        # save/create a page
        if exists(slug):
            page = get_page(slug)
            page.body = request.POST.get('body', '')
            page.title = request.POST.get('title', '')
            tags = parse_tags(request.POST.get('tags', ''))
            page.update_tags(tags)
            page.save()
            return HttpResponseRedirect(page.get_absolute_url())
        else:
            if slug == '':
                slug = request.POST.get('title').lower()
            page = create_page(slug=slug, title=request.POST.get('title', ''),
                               body=request.POST.get('body', ''),
                               tags=parse_tags(request.POST.get('tags', '')))
            return HttpResponseRedirect(page.get_absolute_url())
Esempio n. 2
0
def page_history(request, slug="index"):
    if exists(slug):
        page = get_page(slug)
        return dict(page=page)
    else:
        return HttpResponse("no such page")