|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
from django.shortcuts import render |
|
|
|
|
from django.contrib.auth import authenticate, login |
|
|
|
|
from django.http.response import JsonResponse |
|
|
|
|
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage |
|
|
|
|
|
|
|
|
|
from .forms import UserRegForm |
|
|
|
|
from apps.user.models import MyUser |
|
|
|
@ -69,3 +70,51 @@ def ajax_login_data(request): |
|
|
|
|
json_dict['code'] = '1004' |
|
|
|
|
json_dict['msg'] = '用户名密码为空' |
|
|
|
|
return JsonResponse(json_dict) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def index(request): |
|
|
|
|
if request.method == "GET": |
|
|
|
|
level = request.GET.get("level") |
|
|
|
|
truename = request.GET.get("truename", "") |
|
|
|
|
status = request.GET.get("status") |
|
|
|
|
|
|
|
|
|
search_dict = dict() |
|
|
|
|
if level: |
|
|
|
|
search_dict["level"] = level |
|
|
|
|
if truename: |
|
|
|
|
search_dict["truename"] = truename |
|
|
|
|
if status: |
|
|
|
|
search_dict["status"] = status |
|
|
|
|
|
|
|
|
|
datas = MyUser.objects.filter(**search_dict).order_by("-id") |
|
|
|
|
|
|
|
|
|
page_size = 5 # 每页显示的行数 |
|
|
|
|
try: |
|
|
|
|
if not request.GET.get("page"): |
|
|
|
|
current_page = 1 |
|
|
|
|
current_page = int(request.GET.get("page")) |
|
|
|
|
except: |
|
|
|
|
current_page = 1 |
|
|
|
|
|
|
|
|
|
paginator = Paginator(datas, page_size) |
|
|
|
|
try: |
|
|
|
|
users = paginator.page(current_page) |
|
|
|
|
except PageNotAnInteger: |
|
|
|
|
users = paginator.page(1) |
|
|
|
|
except EmptyPage: |
|
|
|
|
users = paginator.page(1) |
|
|
|
|
context = { |
|
|
|
|
'level': level, |
|
|
|
|
'truename': truename, |
|
|
|
|
'status': status, |
|
|
|
|
'users': users |
|
|
|
|
} |
|
|
|
|
print(context) |
|
|
|
|
return render(request, 'user/index.html', context=context) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def delete(request, _id): |
|
|
|
|
obj = MyUser.objects.filter(id=_id) |
|
|
|
|
obj.delete() |
|
|
|
|
json_dict = dict(code=200, msg='删除数据成功') |
|
|
|
|
return JsonResponse(json_dict) |
|
|
|
|