Commit 5187dbe3 authored by Fardale's avatar Fardale
Browse files

[WebNews] Ajout vérification droit cableur

parent dfd2be39
# -*- coding: utf-8 -*-
from django.shortcuts import render
from django.http import HttpResponse
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import redirect
from django.contrib import messages
from django.contrib.auth.decorators import login_required
......@@ -32,8 +32,18 @@ def handle_nntp_exception(func):
return redirect("news:index", permanent=False,)
return _decorected
def restricted_access(func):
def _decorected(request, *args, **kwargs):
if not request.user.has_perm('auth.crans_cableur'):
messages.error(request, u""" Accès interdit, droits insuffisants """ )
return HttpResponseRedirect("/")
return func(request, *args, **kwargs)
return _decorected
# Afficher les différents newsgroups, les news groups à afficher sont configurable
# dans settings.py en définissant NEWS_SERVER
@restricted_access
@login_required
@handle_nntp_exception
def index(request):
......@@ -41,6 +51,7 @@ def index(request):
lasts = gestion_nntp.get_last_messages()
return render(request, "news/index.html", {"groups":groups,
"lasts":lasts,})
@restricted_access
@login_required
@handle_nntp_exception
def group(request, group, page=1):
......@@ -58,6 +69,7 @@ def group(request, group, page=1):
"max_page": max_page,
"group":group,})
@restricted_access
@login_required
@handle_nntp_exception
def message(request, group, page, message_number):
......@@ -65,6 +77,7 @@ def message(request, group, page, message_number):
"group":group,
"page":page})
@restricted_access
@login_required
@handle_nntp_exception
def source(request, group, message_number):
......@@ -74,6 +87,7 @@ def source(request, group, message_number):
return response
@restricted_access
@login_required
@handle_nntp_exception
def attachment(request, group, message_number, attachment):
......@@ -82,6 +96,7 @@ def attachment(request, group, message_number, attachment):
response['Content-Disposition'] = 'inline; filename="%s"' % part.get_filename()
return response
@restricted_access
@login_required
@handle_nntp_exception
def new_message(request, group):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment