diff options
-rw-r--r-- | news/views.py | 8 | ||||
-rw-r--r-- | todolists/views.py | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/news/views.py b/news/views.py index cfa2bcd7..25f77350 100644 --- a/news/views.py +++ b/news/views.py @@ -1,6 +1,6 @@ from django.http import HttpResponse, HttpResponseRedirect, Http404 from django.shortcuts import get_object_or_404 -from django.contrib.auth.decorators import user_passes_test +from django.contrib.auth.decorators import permission_required from django.contrib.auth.models import User from django import forms from archweb_dev.main.utils import render_response @@ -15,7 +15,7 @@ def list(request): news = News.objects.order_by('-postdate', '-id') return render_response(request, 'news/list.html', {'news':news}) -@user_passes_test(lambda u: u.has_perm('news.add_news')) +@permission_required('news.add_news') def add(request): try: m = User.objects.get(username=request.user.username) @@ -40,7 +40,7 @@ def add(request): form = forms.FormWrapper(manipulator, data, errors) return render_response(request, 'news/add.html', {'form': form}) -@user_passes_test(lambda u: u.has_perm('news.delete_news')) +@permission_required('news.delete_news') def delete(request, newsid): news = get_object_or_404(News, id=newsid) #if news.author.id != request.user.id: @@ -50,7 +50,7 @@ def delete(request, newsid): return HttpResponseRedirect('/news/') return render_response(request, 'news/delete.html') -@user_passes_test(lambda u: u.has_perm('news.change_news')) +@permission_required('news.change_news') def edit(request, newsid): try: m = User.objects.get(username=request.user.username) diff --git a/todolists/views.py b/todolists/views.py index 3a96dc87..2a7d1f09 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -1,6 +1,6 @@ from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import get_object_or_404 -from django.contrib.auth.decorators import user_passes_test +from django.contrib.auth.decorators import permission_required from django.contrib.auth.models import User from archweb_dev.main.utils import render_response from archweb_dev.main.models import Todolist, TodolistPkg, Package @@ -32,7 +32,7 @@ def list(request): list=l.id,complete=False).count() == 0 return render_response(request, 'todolists/list.html', {'lists':lists}) -@user_passes_test(lambda u: u.has_perm('todolists.add_todolist')) +@permission_required('todolists.add_todolist') def add(request): if request.POST: try: |