2015-03-02 08:52:07 +00:00
|
|
|
from django.shortcuts import render
|
2015-03-03 09:34:09 +00:00
|
|
|
from django.http import HttpResponseRedirect
|
|
|
|
from django.core.urlresolvers import reverse
|
2015-03-02 08:52:07 +00:00
|
|
|
from django.contrib.auth.models import User
|
|
|
|
|
|
|
|
|
|
|
|
def users(request):
|
|
|
|
"""
|
|
|
|
:param request:
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
|
2015-03-03 09:34:09 +00:00
|
|
|
if not request.user.is_authenticated():
|
|
|
|
return HttpResponseRedirect(reverse('index'))
|
|
|
|
|
|
|
|
if not request.user.is_superuser:
|
|
|
|
return HttpResponseRedirect(reverse('index'))
|
|
|
|
|
2015-03-02 08:52:07 +00:00
|
|
|
users = User.objects.filter(is_staff=False, is_superuser=False)
|
|
|
|
|
|
|
|
return render(request, 'users.html', locals())
|
|
|
|
|
|
|
|
def user(request, user_id):
|
|
|
|
"""
|
|
|
|
:param request:
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
|
2015-03-03 09:34:09 +00:00
|
|
|
if not request.user.is_authenticated():
|
|
|
|
return HttpResponseRedirect(reverse('index'))
|
|
|
|
|
|
|
|
if not request.user.is_superuser:
|
|
|
|
return HttpResponseRedirect(reverse('index'))
|
|
|
|
|
2015-03-02 08:52:07 +00:00
|
|
|
user = User.objects.get(id=user_id)
|
|
|
|
|
|
|
|
return render(request, 'user.html', locals())
|