Example #1
0
def create_page(request):

    "Create a page for the board."

    if request.method == 'POST':

        form = PageForm(request.POST)

        if form.is_valid():

            page = form.save(commit=False)

            page.board = request.board

            page.save()

            request.user.message_set.create(message = "Page %s has been created." % page.title)

            return HttpResponseRedirect(reverse("zobpress_job_board_page", args =[page.page_slug]))

    else:

        form = PageForm()

    return render_to_response('zobpress/create_page.html', {'form': form}, RequestContext(request))
Example #2
0
def edit_page(request, page_slug):

    page = get_object_or_404(Page, page_slug = page_slug)

    form = PageForm(instance = page)

    if request.method == 'POST':

        if request.POST.get('delete',''):

            page.delete()

            messages.success(request,'%s page has been permanently deleted'%page)

            return redirect(create_page)

        else:

            form = PageForm(data = request.POST, instance = page)

            if form.is_valid():

                form.save()

                request.user.message_set.create(message = "Page %s has been edited." % page.title)

                return HttpResponseRedirect(reverse("zobpress_job_board_page", args =[page.page_slug]))

    payload = {"form": form}

    return render_to_response("zobpress/edit_page.html", payload, RequestContext(request))