8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 03:13:12 +00:00

Du coup on a plus besoin du history de users.

This commit is contained in:
LEVY-FALK Hugo 2017-12-27 22:47:18 +01:00 committed by root
parent e9e26144d6
commit e24bba8bb8

View file

@ -762,95 +762,6 @@ def index_serviceusers(request):
)
@login_required
def history(request, object_name, object_id):
""" Affichage de l'historique : (acl, argument)
user : self or cableur, userid,
ban : self or cableur, banid,
whitelist : self or cableur, whitelistid,
school : cableur, schoolid,
listright : cableur, listrightid """
if object_name == 'user':
try:
object_instance = User.objects.get(pk=object_id)
except User.DoesNotExist:
messages.error(request, "Utilisateur inexistant")
return redirect(reverse('users:index'))
if not object_instance.can_view(request.user)[0]:
messages.error(request, "Vous ne pouvez pas afficher ce menu")
return redirect(reverse(
'users:profil',
kwargs={'userid':str(request.user.id)}
))
elif object_name == 'serviceuser' and request.user.has_perms(('cableur',)):
try:
object_instance = ServiceUser.objects.get(pk=object_id)
except ServiceUser.DoesNotExist:
messages.error(request, "User service inexistant")
return redirect(reverse('users:index'))
elif object_name == 'ban':
try:
object_instance = Ban.objects.get(pk=object_id)
except Ban.DoesNotExist:
messages.error(request, "Bannissement inexistant")
return redirect(reverse('users:index'))
if not request.user.has_perms(('cableur',)) and\
object_instance.user != request.user:
messages.error(request, "Vous ne pouvez pas afficher les bans\
d'un autre user que vous sans droit cableur")
return redirect(reverse(
'users:profil',
kwargs={'userid':str(request.user.id)}
))
elif object_name == 'whitelist':
try:
object_instance = Whitelist.objects.get(pk=object_id)
except Whitelist.DoesNotExist:
messages.error(request, "Whitelist inexistant")
return redirect(reverse('users:index'))
if not request.user.has_perms(('cableur',)) and\
object_instance.user != request.user:
messages.error(request, "Vous ne pouvez pas afficher les\
whitelist d'un autre user que vous sans droit cableur")
return redirect(reverse(
'users:profil',
kwargs={'userid':str(request.user.id)}
))
elif object_name == 'school' and request.user.has_perms(('cableur',)):
try:
object_instance = School.objects.get(pk=object_id)
except School.DoesNotExist:
messages.error(request, "Ecole inexistante")
return redirect(reverse('users:index'))
elif object_name == 'listright' and request.user.has_perms(('cableur',)):
try:
object_instance = ListRight.objects.get(pk=object_id)
except ListRight.DoesNotExist:
messages.error(request, "Droit inexistant")
return redirect(reverse('users:index'))
else:
messages.error(request, "Objet inconnu")
return redirect(reverse('users:index'))
options, _created = GeneralOption.objects.get_or_create()
pagination_number = options.pagination_number
reversions = Version.objects.get_for_object(object_instance)
paginator = Paginator(reversions, pagination_number)
page = request.GET.get('page')
try:
reversions = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
reversions = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
reversions = paginator.page(paginator.num_pages)
return render(
request,
're2o/history.html',
{'reversions': reversions, 'object': object_instance}
)
@login_required
def mon_profil(request):
""" Lien vers profil, renvoie request.id à la fonction """