Exemplo n.º 1
0
def trouble_report(request, **kwargs):
    '''故障处理报告:超级管理员才能看到'''
    # 分页
    base_url = reverse('report', kwargs=kwargs)
    data_count = Trouble.objects.all().count()
    trouble_list = Trouble.objects.filter().order_by('status').only(
        'id', 'title', 'status', 'ctime', 'processer')
    page_obj = Pagination(data_count, request.GET.get('p'))
    data = trouble_list[page_obj.start():page_obj.end()]
    page_str = page_obj.page_str(base_url)
    return render(request, 'backend_trouble_report.html', {
        'data': data,
        'page_str': page_str,
    })
Exemplo n.º 2
0
def trouble_list(request, **kwargs):
    '''显示报障单'''
    # 分页
    current_user = request.session.get('username')
    base_url = reverse('trouble', kwargs=kwargs)
    data_count = Trouble.objects.filter(user__username=current_user).count()
    trouble_list = Trouble.objects.filter(
        user__username=current_user).order_by('status').only(
            'id', 'title', 'status', 'ctime', 'processer')
    page_obj = Pagination(data_count, request.GET.get('p'))
    data = trouble_list[page_obj.start():page_obj.end()]
    page_str = page_obj.page_str(base_url)
    return render(request, 'backend_trouble_list.html', {
        'title': '后台管理',
        'data': data,
        'page_str': page_str,
    })