def admin_page(request, page_id): """Administration view.""" lp = get_object_or_404(LegalPage, id=page_id) if request.method == 'POST': form = LegalPageForm(request.POST, instance=lp) if form.is_valid(): form.save() return redirect('legalpages.views.admin') else: form = LegalPageForm(instance=lp) return render_to_response('legalpages/admin/edit.html', {'form': form}, RequestContext(request))
def admin(request): """Lists available pages in the administration.""" msg = '' if request.method == 'POST': form = LegalPageForm(request.POST) if form.is_valid(): form.save() form = LegalPageForm() msg = _("Legal Page created.") else: form = LegalPageForm() lps = LegalPage.objects.all() return render_to_response('legalpages/admin/list.html', { 'legalpages': lps, 'form': form, 'message': msg, 'show_delete': False }, RequestContext(request))
def admin_page(request, page_id): """Administration view.""" lp = get_object_or_404(LegalPage, id=page_id) if request.method == 'POST': if '_delete' in request.POST: lp.delete() return redirect('legalpages.views.admin') form = LegalPageForm(request.POST, instance=lp) if form.is_valid(): form.save() return redirect('legalpages.views.admin') else: form = LegalPageForm(instance=lp) return render_to_response('legalpages/admin/edit.html', { 'form': form, 'show_delete': True }, RequestContext(request))
def admin(request): """Lists available pages in the administration.""" msg = '' if request.method == 'POST': form = LegalPageForm(request.POST) if form.is_valid(): form.save() form = LegalPageForm() msg = _("Legal Page created.") else: form = LegalPageForm() lps = LegalPage.objects.all() return render_to_response('legalpages/admin/list.html', {'legalpages': lps, 'form': form, 'message': msg}, RequestContext(request))