Beispiel #1
0
def edit(request, name):
    """Allows users to edit wiki pages."""
    try:
        page = Page.objects.get(name=name)
    except Page.DoesNotExist:
        page = None

    if request.method == 'POST':
        form = PageForm(request.POST)
        if form.is_valid():
            if not page:
                page = Page()
            page.name = form.cleaned_data['name']
            page.content = form.cleaned_data['content']

            page.save()
            return HttpResponseRedirect('../../%s/' % page.name)
    else:
        if page:
            form = PageForm(initial=page.__dict__)
        else:
            form = PageForm(initial={'name': name})

    return render_to_response('wiki/edit.html', {
        'form': form, 
        'admin': is_admin(request),
        'user': get_user(request),
        'navbar':Page.objects.get(name='NavBar'),
    })
Beispiel #2
0
def edit(request, name):
    """Allows users to edit wiki pages."""
    try:
        page = Page.objects.get(name=name)
    except Page.DoesNotExist:
        page = None

    if request.method == "POST":
        form = PageForm(request.POST)
        if form.is_valid():
            if not page:
                page = Page()
            page.name = form.cleaned_data["name"]
            page.content = form.cleaned_data["content"]

            page.save()
            return HttpResponseRedirect("../../%s/" % page.name)
    else:
        if page:
            form = PageForm(initial=page.__dict__)
        else:
            form = PageForm(initial={"name": name})

    return render_to_response(
        "wiki/edit.html",
        {
            "form": form,
            "admin": is_admin(request),
            "user": get_user(request),
            "navbar": Page.objects.get(name="NavBar"),
        },
    )
Beispiel #3
0
def view(request, name):
    """Shows a single wiki page."""
    try:
        page = Page.objects.get(name=name)
    except Page.DoesNotExist:
        page = Page(name=name)

    return render_to_response('wiki/view.html', {
        'page': page, 
        'admin': is_admin(request),
        'user': get_user(request),
        'navbar':Page.objects.get(name='NavBar'),
    })
Beispiel #4
0
def view(request, name):
    """Shows a single wiki page."""
    try:
        page = Page.objects.get(name=name)
    except Page.DoesNotExist:
        page = Page(name=name)

    return render_to_response(
        "wiki/view.html",
        {
            "page": page,
            "admin": is_admin(request),
            "user": get_user(request),
            "navbar": Page.objects.get(name="NavBar"),
        },
    )