Exemplo n.º 1
0
def xgqk_list_role(request):
    qs = PwkxgLog.objects.order_by("-xgsj")
    xzdm = getxzcode(request)[0]
    xzmc = getxzcode(request)[1]
    if xzdm is None:
        # 返回一个空值
        qs = qs.none()
    else:
        # 乡镇用户登录
        if xzdm:
            qs = qs.filter(xz=xzmc)
    return qs
Exemplo n.º 2
0
def zzjz_list_role(request):
    qs = ZzjzLog.objects.order_by("-rq")
    xzdm = getxzcode(request)[0]
    xzmc = getxzcode(request)[1]
    if xzdm is None:
        # 返回一个空值
        qs = qs.none()
    else:
        # 乡镇用户登录
        if xzdm:
            qs = qs.filter(xz=xzdm)
    return qs
Exemplo n.º 3
0
def unreadMessageV(request):
    mList = readableMessage(request)
    xzcode = getxzcode(request)
    if xzcode[0]:
        xz = "1"
    else:
        xz = "0"
    return render(request, "pwk/messageInbox.html", {
        "messageList": mList,
        "xz": xz
    })
Exemplo n.º 4
0
def zzqk_list_role(request):
    qs = ZzqkLog.objects
    xzdm = getxzcode(request)[0]
    if xzdm is None:
        # 返回一个空值
        qs = qs.none()
    else:
        # 乡镇用户登录
        if xzdm:
            qs = qs.filter(xz=xzdm)
    return qs
Exemplo n.º 5
0
def modifyQuery(request):
    page = request.GET.get('page')
    form = ModifyQueryForm(request.POST or None)
    xzChoice(request, form)
    xgLog = xgqk_list_role(request)
    if request.method == "POST" and form.is_valid():
        query_dict = form.cleaned_data
        pwkmc = query_dict["pwkmc"]
        xz = query_dict["xz"]
        start_date = query_dict["start_date"]
        end_date = query_dict['end_date']
        if pwkmc:
            xgLog = xgLog.filter(pwkmc=pwkmc)
        if xz:
            xgLog = xgLog.filter(xz=xzcode2name(xz))
        if start_date:
            xgLog = xgLog.filter(xgsj__gte=start_date)
        if end_date:
            xgLog = xgLog.filter(xgsj__lte=end_date)
        request.session["xgLog"] = xgLog
        request.session["xgForm"] = form
    else:
        if not request.session.get("xgLog") or not page:
            request.session["xgLog"]=xgLog
            request.session["xgForm"] = form
    # 处理分页

    xglist = request.session["xgLog"]
    total = len(xglist)
    form = request.session["xgForm"]
    paginator = Paginator(xglist, 10)

    try:
        xglist_p = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        xglist_p = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        xglist_p = paginator.page(paginator.num_pages)
    # 把分页的结果返回

    xzcode = getxzcode(request)
    if xzcode[0]:
        xz="1"
    else:
        xz="0"
    return render(request, "pwk/xgLog.html", {
        "xglist": xglist_p,
        "total": total,
        "form": form,
        "xz":xz,
    })
Exemplo n.º 6
0
def dthlChoice(request, form):
    hl_choice = [("", "排入河流--全部")]
    hlmcs = get_pwkQuery_set(request).values("prhlmc")
    for item in hlmcs:
        newItem = (item["prhlmc"], item["prhlmc"])
        if newItem in hl_choice:
            pass
        else:
            hl_choice.append(newItem)
    form.fields['prhlmc'].choices = hl_choice
    # 处理乡镇的内容
    xzqhdm = getxzcode(request)

    if xzqhdm[0]:
        xz = []
        xz.append(xzqhdm)
        form.fields['xz'].choices = xz
Exemplo n.º 7
0
def qrModify(request):
    xzdm = getxzcode(request)[0]
    message=""
    qrqk=""
    qrms=""
    id=""
    if xzdm:
        message="只有区县用户才能确认修改信息!"
    else:
        xgLogId=request.GET.get("id")
        id=xgLogId
        qrqk=request.GET.get("qrqk")
        qr_message=request.GET.get("message")
        qrms=qr_message
        if xgLogId:
            xgLog = xgqk_list_role(request)
            xgLog=xgLog.filter(id=xgLogId)
            if xgLog:
                xglog=xgLog[0]
                xglog.qrxgbj=qrqk
                xglog.qrms=qr_message
                xglog.save()
                if qrqk == "1":
                    savePwk(xglog)
                    sendMessage(request, xglog, "接受")
                else:
                    pwk=PwkInfo.objects.get(id=xglog.pwkid)
                    print(pwk)
                    if pwk:
                        pwk.qrqk=False
                        pwk.save()
                    sendMessage(request, xglog, "拒绝")
                message="确认修改成功!"
            else:
                message="无此记录"
        else:
            message="无此修改记录"
    ret={"message":message,
         "qrqk":qrqk,
         "qrms":qrms,
         "id":id
        }
    return JsonResponse(ret,safe=True)
Exemplo n.º 8
0
 def formfield_for_choice_field(self, db_field, request, **kwargs):
     xz = getxzcode(request)
     if db_field.name == "xz":
         if xz[0]:
             # 乡镇用户
             kwargs['choices'] = (xz, )
     if db_field.name == "prhlmc":
         if xz[0]:
             # 乡镇用户
             hls = PwkInfo.objects.filter(
                 xz=xz[0]).values("prhlmc").distinct()
             hlList = []
             for item in hls:
                 hlList.append((
                     item["prhlmc"],
                     item["prhlmc"],
                 ))
             kwargs['choices'] = hlList
     return super(PwkAdmin,
                  self).formfield_for_choice_field(db_field, request,
                                                   **kwargs)
Exemplo n.º 9
0
def sypwk(request):
    # 增加权限,只有区县的才能确认
    userRole = getxzcode(request)

    message = ""
    status = ""
    if not userRole[0]:
        # 为区县用户可以修改
        id = request.GET['id']
        pwk = get_pwkQuery_set(request).get(id=id)
        if pwk.syPwkbz and pwk.syPwkbz == "是":
            pwk.syPwkbz = "否"
            status = "否"
        else:
            pwk.syPwkbz = "是"
            status = "是"
        pwk.save()
        message = pwk.pwkmc + "修改成为:" + status + " 溯源排污口."

    else:
        message = "只有区县用户才能操作!"
    outString = {"message": message, "status": status}
    return JsonResponse(outString, safe=False)
Exemplo n.º 10
0
def qrpwk(request):
    # 增加权限,只有区县的才能确认
    userRole = getxzcode(request)

    message = ""
    status = ""
    if not userRole[0]:
        # 为区县用户可以修改
        id = request.GET['id']
        pwk = get_pwkQuery_set(request).get(id=id)
        if pwk.qrqk:
            pwk.qrqk = 0
            status = "未确认"
        else:
            pwk.qrqk = 1
            status = "已确认"
        pwk.save()
        message = pwk.pwkmc + "修改成为:" + status + "."

    else:
        message = "只有区县用户才能操作!"
    outString = {"message": message, "status": status}
    return JsonResponse(outString, safe=False)