Exemplo n.º 1
0
def register(request, ReferenceId = None):

    if request.method == 'GET':
        member_ = models.Member()
  
        context ={}
        return render(request, 'Account/Register.html', context)
    elif request.method == 'POST':
        RegUserId = request.POST['UserId']
        RegUserName = request.POST['UserName']
        RegNickName = request.POST['NickName']
        RegIDCard = request.POST['IDCard']
        RegUserStatus = request.POST['UserStatus']
        RegBindMob = request.POST['BindMob']
        RegDepositMobile = request.POST['DepositMobile']
        # md5 for password
        RegUserPwd = request.POST['UserPwd']
        global md5_used
        if md5_used:
            RegUserPwd = hashlib.md5(RegUserPwd.encode('utf8')).hexdigest()
        RegUserPayPwd = request.POST['UserPayPwd']
        RegWeChat = request.POST['WeChat']
        RegAlipay = request.POST['Alipay']
        RegBankName = request.POST['BankName']
        RegBankAccount = request.POST['BankAccount']
        RegTrueName = request.POST['TrueName']
        RegRecName = request.POST['RecName']
        RegRecAdd = request.POST['RecAdd']
        RegRecMob = request.POST['RecMob']
        RegMark = request.POST['Mark']
        '''
        print "RegUserId:",RegUserId
        print "RegUserName:"******"RegNickName:",RegNickName
        print "RegIDCard:",RegIDCard
        print "RegUserStatus:",RegUserStatus
        print "RegBindMob:",RegBindMob
        print "RegDepositMobile:",RegDepositMobile
        print "RegUserPwd:",RegUserPwd
        print "RegUserPayPwd:",RegUserPayPwd
        print "RegWeChat:",RegWeChat
        print "RegAlipay:",RegAlipay
        print "RegBankName:",RegBankName
        print "RegBankAccount:",RegBankAccount
        print "RegTrueName:",RegTrueName
        print "RegRecName:",RegRecName
        print "RegRecAdd:",RegRecAdd
        print "RegRecMob:",RegRecMob
        print "RegMark:",RegMark
        '''
        memberobj = models.Member()
        if memberobj.register(RegUserName,RegNickName,RegDepositMobile,RegAlipay,RegBindMob,RegUserPwd,RegWeChat,RegBankName,RegBankAccount,
            RegTrueName,RegRecName,RegRecMob,RegRecAdd,RegMark,1,0) == True:
            obj = {'result':'t'}
        else:
            obj = {'result':'f',
                'msg':'用户名已经被注册'}
        code = str(json.dumps(obj))
        return HttpResponse(code)
Exemplo n.º 2
0
def MemberSave1(request):
    if request.session.get('role') == None or request.session['role'] != '1':
        return HttpResponseRedirect('/')
    RegUserId = request.POST['UserId']
    RegUserName = request.POST['UserName']
    RegNickName = request.POST['NickName']
    RegIDCard = request.POST['IDCard']
    RegUserStatus = request.POST['UserStatus']
    RegBindMob = request.POST['BindMob']
    RegDepositMobile = request.POST['DepositMobile']
    RegUserPwd = request.POST['UserPwd']
    RegUserPayPwd = request.POST['UserPayPwd']
    RegWeChat = request.POST['WeChat']
    RegAlipay = request.POST['Alipay']
    RegBankName = request.POST['BankName']
    RegBankAccount = request.POST['BankAccount']
    RegTrueName = request.POST['TrueName']
    RegRecName = request.POST['RecName']
    RegRecAdd = request.POST['RecAdd']
    RegRecMob = request.POST['RecMob']
    #RegMark = request.POST['Mark']
    print "RegUserId:", RegUserId
    print "RegUserName:"******"RegNickName:", RegNickName
    print "RegIDCard:", RegIDCard
    print "RegUserStatus:", RegUserStatus
    print "RegBindMob:", RegBindMob
    print "RegDepositMobile:", RegDepositMobile
    print "RegUserPwd:", RegUserPwd
    print "RegUserPayPwd:", RegUserPayPwd
    print "RegWeChat:", RegWeChat
    print "RegAlipay:", RegAlipay
    print "RegBankName:", RegBankName
    print "RegBankAccount:", RegBankAccount
    print "RegTrueName:", RegTrueName
    print "RegRecName:", RegRecName
    print "RegRecAdd:", RegRecAdd
    print "RegRecMob:", RegRecMob
    #print "RegMark:",RegMark
    if RegUserPwd == "":
        RegUserPwd = None

    memberobj = models.Member()
    if memberobj.fixInfo(user_id_=RegUserId,
                         pwd_=RegUserPwd,
                         bind_phone_=RegBindMob,
                         weixinId_=RegWeChat,
                         bank_=RegBankName,
                         account_=RegBankAccount,
                         card_holder_=RegTrueName,
                         receiver_=RegRecName,
                         receiver_phone_=RegRecMob,
                         receiver_addr_=RegRecAdd,
                         member_status_=RegUserStatus) == True:
        obj = {'result': 't'}
    else:
        obj = {'result': 'f', 'msg': '请稍后再试!'}
    code = str(json.dumps(obj))
    return HttpResponse(code)
Exemplo n.º 3
0
def MemberEdit1(request):
    if request.session.get('role') == None or request.session['role'] != '1':
        return HttpResponseRedirect('/')
    reqUserId = request.GET.get('UserId')
    print "reqUserId:", reqUserId
    member_ = models.Member()
    selfinfo = member_.myInfo(int(reqUserId))
    print selfinfo.status.status_id
    context = {'selfinfo': selfinfo, 'UserId': reqUserId}
    return render(request, 'Services/MemberEdit1.html', context)
Exemplo n.º 4
0
def RecomeSave(request):
    #RegUserId = request.POST['UserId']
    RegUserName = request.POST['UserName']
    RegNickName = request.POST['NickName']
    RegDepositMobile = request.POST['DepositMobile']
    RegAlipay = request.POST['Alipay']
    RegBindMob = request.POST['BindMob']
    RegUserPwd = request.POST['UserPwd']
    RegWeChat = request.POST['WeChat']
    RegBankName = request.POST['BankName']
    RegBankAccount = request.POST['BankAccount']
    RegTrueName = request.POST['TrueName']
    RegRecName = request.POST['RecName']
    RegRecMob = request.POST['RecMob']
    RegRecAdd = request.POST['RecAdd']
    RegMark = request.POST['Mark']
    RegRefId = request.session['user_id']

    #RegMark = request.POST['Mark']
    #print "RegUserId:",RegUserId
    print "RegUserName:"******"RegNickName:", RegNickName
    print "RegDepositMobile:", RegDepositMobile
    print "RegAlipay:", RegAlipay
    print "RegBindMob:", RegBindMob
    print "RegUserPwd:", RegUserPwd
    print "RegWeChat:", RegWeChat
    print "RegBankName:", RegBankName
    print "RegBankAccount:", RegBankAccount
    print "RegTrueName:", RegTrueName
    print "RegRecName:", RegRecName
    print "RegRecMob:", RegRecMob
    print "RegRecAdd:", RegRecAdd
    print 'RegMark:', RegMark
    print 'RegRefId:', RegRefId
    memobj = models.Member()
    service_id = memobj.myInfo(RegRefId).service_id
    flag=memobj.register(RegUserName,RegNickName,RegDepositMobile,RegAlipay,RegBindMob,RegUserPwd,RegWeChat,RegBankName,\
         RegBankAccount,RegTrueName,RegRecName,RegRecMob,RegRecAdd,RegMark,service_id,RegRefId)
    #register(self,user,nickname_,delegation_phone_,delegation_info_,\
    #    bind_phone_,pwd,weixinId,bank_,account_,cardHolder,receiver_,reciever_phone_,\
    #  receiver_addr_,order_Memo_,serviceid,referenceid):

    #print "RegMark:",RegMark
    if RegUserPwd == "":
        RegUserPwd = None

    if flag:
        print '推荐成功'
        obj = {'result': 't'}
    else:
        obj = {'result': 'f', 'msg': '请稍后再试!'}
    code = str(json.dumps(obj))
    print code
    return HttpResponse(code)
Exemplo n.º 5
0
def GetMap(request):
    if request.session.get('role') == None or request.session['role'] != '1':
        return HttpResponseRedirect('/')
    serviceid = request.session['service_id']
    reqUid = request.POST.get('Uid')
    reqstep = request.POST.get('step')

    print "reqUid:", reqUid
    print "reqstep:", reqstep
    memlist = []
    res = []
    memobj = models.Member()
    if reqUid == None:
        # memlist = memobj.myMemberNet(
        # 	userOrServiceid_=serviceid,
        # 	role_="0",
        # 	pageNum=1
        # 	)
        servicemem = models.Service.GetServiceName(servcie_id_=serviceid)
        resmem = {
            "UserId": 0,
            "text": servicemem.service_name,
            "parentId": 0,
            "type": "folder",
            "step": 1,
            "Level": 1,
            "Sort": 0,
            "UserName": ""
        }
        res.append(resmem)
    else:
        memlist = memobj.myMemberNet(
            userOrServiceid_=reqUid,
            role_="0",  # here we find referenceid = userid  so keep role_ = "0"
            pageNum=1)
    for member in memlist:
        # print "================="
        # print member.user_id
        # print member.user_name
        # print member.reference_id
        # print member.service_id
        resmem = {
            "UserId": member.user_id,
            "text": member.user_name,
            "parentId": member.reference_id,
            "type": "folder",
            "step": 1,
            "Level": 1,
            "Sort": 0,
            "UserName": member.user_name
        }
        res.append(resmem)

    code = str(json.dumps(res))
    return HttpResponse(code)
Exemplo n.º 6
0
def SetAudit1(request):
    if request.session.get('role') == None or request.session['role'] != '1':
        return HttpResponseRedirect('/')

    serviceid = request.session['service_id']
    reqUserId = request.POST.get('UserId')
    print "reqUserId:", reqUserId
    member_ = models.Member()
    if member_.confirmMember(user_id_=reqUserId,
                             service_id_=serviceid) == True:

        return render(request, 'Services/SetAudit.html', context)
Exemplo n.º 7
0
def MyDataUpdate(request):
    user_id = request.session["user_id"]
    RegUserName = request.POST['UserName']
    RegNickName = request.POST['NickName']
    RegDepositMobile = request.POST['DepositMobile']
    RegAlipay = request.POST['Alipay']
    RegBindMob = request.POST['BindMob']
    RegUserPwd = request.POST['UserPwd']
    RegWeChat = request.POST['WeChat']
    RegBankName = request.POST['BankName']
    RegBankAccount = request.POST['BankAccount']
    RegTrueName = request.POST['TrueName']
    RegRecName = request.POST['RecName']
    RegRecMob = request.POST['RecMob']
    RegRecAdd = request.POST['RecAdd']

    #RegMark = request.POST['Mark']
    #print "RegUserId:",RegUserId
    print "RegUserName:"******"RegNickName:", RegNickName
    print "RegDepositMobile:", RegDepositMobile
    print "RegAlipay:", RegAlipay
    print "RegBindMob:", RegBindMob
    print "RegUserPwd:", RegUserPwd
    print "RegWeChat:", RegWeChat
    print "RegBankName:", RegBankName
    print "RegBankAccount:", RegBankAccount
    print "RegTrueName:", RegTrueName
    print "RegRecName:", RegRecName
    print "RegRecMob:", RegRecMob
    print "RegRecAdd:", RegRecAdd
    memobj = models.Member()
    #fixInfo(self,user_id_,pwd_=None,bind_phone_=None,weixinId_=None,bank_=None,account_=None,card_holder_=None,\
    #          receiver_=None,receiver_phone_=None,receiver_addr_=None,member_status_ =None):
    flag = memobj.fixInfo(user_id, RegUserPwd, RegBindMob, RegWeChat,
                          RegBankName, RegBankAccount, RegTrueName, RegRecName,
                          RegRecMob, RegRecAdd)
    #register(self,user,nickname_,delegation_phone_,delegation_info_,\
    #    bind_phone_,pwd,weixinId,bank_,account_,cardHolder,receiver_,reciever_phone_,\
    #  receiver_addr_,order_Memo_,serviceid,referenceid):

    #print "RegMark:",RegMark
    if RegUserPwd == "":
        RegUserPwd = None

    if flag:
        print '修改成功'
        obj = {'result': 't'}
    else:
        obj = {'result': 'f', 'msg': '请稍后再试!'}
    code = str(json.dumps(obj))
    print code
    return HttpResponse(code)
Exemplo n.º 8
0
def ViewReCome(request):
    if request.session.get('role') == None or request.session['role'] != '1':
        return HttpResponseRedirect('/')
    reqUserId = request.GET.get('UserId')
    print "reqUserId:", reqUserId
    member_ = models.Member()
    selfinfo = member_.myInfo(reqUserId)
    print "selfinfo:", selfinfo
    context = {
        'selfinfo': selfinfo,
    }
    return render(request, 'Services/ViewReCome.html', context)
Exemplo n.º 9
0
def MyData(request):
    if request.session['role'] != '0':
        return HttpResponseRedirect('/')
    username = request.session['username']
    user_id = request.session['user_id']
    memobj = models.Member()
    meminfo = memobj.myInfo(user_id)
    if meminfo.status_id == 1:
        modifiable = '1'
    else:
        modifiable = '0'
    print modifiable

    context = {}
    context['username'] = username
    context['modifiable'] = modifiable
    context['meminfo'] = meminfo
    return render(request, 'Member/MyData.html', context)
Exemplo n.º 10
0
def Recome(request):
    if request.session['role'] != '0':
        return HttpResponseRedirect('/')
    username = request.session['username']
    user_id = request.session['user_id']
    memobj = models.Member()
    service_id = memobj.myInfo(user_id).service_id
    print 'user_id=' + str(user_id)
    print 'service_id=' + str(service_id)
    serviceobj = models.Service()
    service_info = serviceobj.getServiceInfo(service_id)
    ser_acc_obj = models.ServiceAccount()
    service_account_list = ser_acc_obj.comBankAll(service_id)
    infolist = []
    for service_account in service_account_list:
        account={'bank':service_account.bank+'('+service_info.service_area+')','bank_account':service_account.bank_account,'holder':service_account.card_holder,\
         'phone':service_account.phone+'('+service_info.service_area+')'}
        infolist.append(account)
    context = {'username': username, 'infolist': infolist}
    return render(request, 'Member/Recome.html', context)
Exemplo n.º 11
0
def DashBoard(request):
    if request.session['role'] != '0':
        return HttpResponseRedirect('/')
    user_id = request.session['user_id']
    print user_id
    memberobj = models.Member()
    myinfo = memberobj.myInfo(user_id)
    print myinfo.user_name
    print myinfo.nickname
    #print myinfo.status_id
    memstatus = models.MemberStatus()
    status_desc = memstatus.getStatusDesc(myinfo.status_id).status_desc
    print status_desc
    print str(myinfo.register_time)[0:19]
    print str(myinfo.confirm_time)[0:19]
    context = {'user_id':user_id,'user_name':myinfo.user_name,'nickname':myinfo.nickname,'status_desc':status_desc,'count':5,\
                 'regist_time':str(myinfo.register_time)[0:19],'confirm_time':str(myinfo.confirm_time)[0:19],"mem_status":str(myinfo.status_id)}
    print "status_id" + str(myinfo.status_id)
    print "status_id", context["mem_status"]
    return render(request, 'Member/DashBoard.html', context)
Exemplo n.º 12
0
def GetMap(request):
    reqUid = request.POST.get('Uid')
    reqstep = request.POST.get('step')

    print "get in get map"
    print "reqUid:", reqUid
    print "reqstep:", reqstep
    memlist = []
    res = []
    memobj = models.Member()
    serviceid = 1
    if reqUid == None:
        username = request.session['username']
        reqstep = 0
        memlist = []
        mem = memobj.getUser(username)
        memlist.append(mem)
    else:
        if int(reqstep) < 3:
            memlist = memobj.myMemberNet(userOrServiceid_=reqUid,
                                         role_="0",
                                         pageNum=1)
        else:
            memlist = {}
    for member in memlist:
        resmem = {
            "UserId": member.user_id,
            "text": member.nickname,
            "parentId": member.reference_id,
            "type": "folder",
            "step": int(reqstep) + 1,
            "Level": 1,
            "Sort": 0,
            "UserName": member.user_name
        }
        res.append(resmem)

    code = str(json.dumps(res))
    #print code
    return HttpResponse(code)
Exemplo n.º 13
0
def ReConsumeSave(request):
    mark = request.POST['Mark']
    username = request.session["username"]
    #createOrder(self,service_id_,user_id_,order_price_,order_type_,order_memo_,order_status_="未发货"):
    print "mark", mark
    orderobj = models.OrderForm()
    memobj = models.Member()
    user = memobj.GetUser(username)
    print user.nickname
    flag = orderobj.createOrder(service_id_=user.service_id,
                                user_id_=user.user_id,
                                order_price_=1500 * 0.8,
                                order_type_='1',
                                order_memo_=mark)
    context = {}
    if flag:
        obj = {'result': 't'}
        code = str(json.dumps(obj))
    else:
        obj = {'result': 'f', 'msg': '申请加单失败'}
        code = str(json.dumps(obj))
    return HttpResponse(code)
Exemplo n.º 14
0
def AdviceSub(request):
    title = request.POST['title']
    info = request.POST['info']
    user_id = request.session['user_id']

    memobj = models.Member()
    advobj = models.Advice()
    service_id = memobj.myInfo(user_id).service_id
    print service_id
    print title
    print info
    flag = advobj.send_advice(user_id, title, info, service_id)
    print 'flag=', flag
    if flag:
        print "success"
        obj = {'result': 't'}
    else:
        print "failed"
        obj = {'result': 'f', 'msg': '请稍后再试!'}
    code = str(json.dumps(obj))
    print code
    return HttpResponse(code)
Exemplo n.º 15
0
def MemberList(request):
    if request.session.get('role') == None or request.session['role'] != '1':
        return HttpResponseRedirect('/')
    serviceid = request.session['service_id']
    sesserviceid = request.session.get('service_id')
    reqUserInfo = request.GET.get('UserInfo')
    reqUserStatus = request.GET.get('UserStatus')
    reqorderby = request.GET.get('orderby')
    reqregfrom = request.GET.get('regfrom')
    reqregStart = request.GET.get('regStart')
    reqregEnd = request.GET.get('regEnd')
    reqsubStart = request.GET.get('subStart')
    reqsubEnd = request.GET.get('subEnd')

    kreqUserInfo = reqUserInfo
    kreqUserStatus = reqUserStatus
    kreqorderby = reqorderby
    kreqregfrom = reqregfrom
    kreqregStart = reqregStart
    kreqregEnd = reqregEnd
    kreqsubStart = reqsubStart
    kreqsubEnd = reqsubEnd

    curpage = request.GET.get('p')
    if reqUserInfo == "" or reqUserInfo == "None":
        reqUserInfo = None
    if reqUserStatus == "0" or reqUserStatus == "None":
        reqUserStatus = None
    if reqorderby == None or reqorderby == "None":
        reqorderby = "0"
    if reqregfrom == None or reqregfrom == "None":
        reqregfrom = "0"
    if reqregStart == "" or reqregStart == "None":
        reqregStart = None
    if reqregEnd == "" or reqregEnd == "None":
        reqregEnd = None
    if reqsubStart == "" or reqsubStart == "None":
        reqsubStart = None
    if reqsubEnd == "" or reqsubEnd == "None":
        reqsubEnd = None
    if curpage == None or curpage == '':
        curpage = "1"
    if reqUserStatus != None:
        kreqUserStatus = int(reqUserStatus)
    else:
        kreqUserStatus = reqUserStatus
    curpage = int(curpage)
    if curpage <= 0:
        curpage = 1

    print "sesserviceid:", sesserviceid
    print "reqUserInfo:", reqUserInfo
    print "reqUserStatus:", kreqUserStatus
    print "reqorderby:", reqorderby
    print "reqregfrom:", reqregfrom
    print "reqregStart:", reqregStart
    print "reqregEnd:", reqregEnd
    print "reqsubStart:", reqsubStart
    print "reqsubEnd:", reqsubEnd

    member_ = models.Member()
    memberlist, pagenum, totalnum = member_.MemberList(
        service_id_=serviceid,
        user_or_phone_=reqUserInfo,
        member_status_=kreqUserStatus,
        time_order_=reqorderby,
        reg_way=reqregfrom,
        reg_start_time_=reqregStart,
        reg_end_time_=reqregEnd,
        conf_start_time_=reqsubStart,
        conf_end_time_=reqsubEnd,
        pageNum=curpage)
    ######################################################
    prevpage = (1 if curpage - 1 < 1 else curpage - 1)
    nextpage = (pagenum if curpage + 1 > pagenum else curpage + 1)
    interval = 5
    firstshowpage = (curpage - 1) / interval * interval + 1
    lastshowpage = (firstshowpage + interval
                    if firstshowpage + interval < pagenum else pagenum + 1)
    pageshowlist = range(firstshowpage, lastshowpage)

    if firstshowpage == 1:
        preomit = False
        prevomitpage = 1  #useless here
    else:
        preomit = True
        prevomitpage = (1 if firstshowpage - 3 < 1 else firstshowpage - 3)

    if lastshowpage >= pagenum + 1:
        nextomit = False
        nextomitpage = pagenum  #useless here
    else:
        nextomit = True
        nextomitpage = (pagenum
                        if lastshowpage + 2 > pagenum else lastshowpage + 2)
    ######################################################
    context = {
        'memberlist': memberlist,
        'reqUserInfo': reqUserInfo,
        'reqUserStatus': reqUserStatus,
        'reqorderby': reqorderby,
        'reqregfrom': reqregfrom,
        'reqregStart': reqregStart,
        'reqregEnd': reqregEnd,
        'reqsubStart': reqsubStart,
        'reqsubEnd': reqsubEnd,
        'reference_name': "",
        'pagenum': pagenum,
        'totalnum': totalnum,
        'pageshowlist': pageshowlist,
        'prevpage': prevpage,
        'curpage': curpage,
        'preomit': preomit,
        'nextomit': nextomit,
        'prevomitpage': prevomitpage,
        'nextomitpage': nextomitpage,
        'nextpage': nextpage
    }
    return render(request, 'Services/MemberList.html', context)
Exemplo n.º 16
0
def MemberSave(request):
    if request.session.get('role') == None or request.session['role'] != '1':
        return HttpResponseRedirect('/')
    serviceid = request.session['service_id']
    RegUserId = request.POST['UserId']
    RegUserName = request.POST['UserName']
    RegNickName = request.POST['NickName']
    RegIDCard = request.POST['IDCard']
    RegUserStatus = request.POST['UserStatus']
    RegBindMob = request.POST['BindMob']
    RegDepositMobile = request.POST['DepositMobile']
    RegUserPwd = request.POST['UserPwd']
    RegUserPayPwd = request.POST['UserPayPwd']
    RegWeChat = request.POST['WeChat']
    RegAlipay = request.POST['Alipay']
    RegBankName = request.POST['BankName']
    RegBankAccount = request.POST['BankAccount']
    RegTrueName = request.POST['TrueName']
    RegRecName = request.POST['RecName']
    RegRecAdd = request.POST['RecAdd']
    RegRecMob = request.POST['RecMob']
    RegMark = request.POST['Mark']
    print "RegUserId:", RegUserId
    print "RegUserName:"******"RegNickName:", RegNickName
    print "RegIDCard:", RegIDCard
    print "RegUserStatus:", RegUserStatus
    print "RegBindMob:", RegBindMob
    print "RegDepositMobile:", RegDepositMobile
    print "RegUserPwd:", RegUserPwd
    print "RegUserPayPwd:", RegUserPayPwd
    print "RegWeChat:", RegWeChat
    print "RegAlipay:", RegAlipay
    print "RegBankName:", RegBankName
    print "RegBankAccount:", RegBankAccount
    print "RegTrueName:", RegTrueName
    print "RegRecName:", RegRecName
    print "RegRecAdd:", RegRecAdd
    print "RegRecMob:", RegRecMob
    print "RegMark:", RegMark
    memberobj = models.Member()
    if memberobj.register(user=RegUserName,
                          nickname_=RegNickName,
                          delegation_phone_=RegDepositMobile,
                          delegation_info_=RegAlipay,
                          bind_phone_=RegBindMob,
                          pwd=RegUserPwd,
                          weixinId=RegWeChat,
                          bank_=RegBankName,
                          account_=RegBankAccount,
                          cardHolder=RegTrueName,
                          receiver_=RegRecName,
                          reciever_phone_=RegRecMob,
                          receiver_addr_=RegRecAdd,
                          order_Memo_=RegMark,
                          serviceid=serviceid,
                          referenceid=0) == True:
        obj = {'result': 't'}
    else:
        obj = {'result': 'f', 'msg': '用户名已经被注册'}
    code = str(json.dumps(obj))
    return HttpResponse(code)
Exemplo n.º 17
0
def MyRecomeAll(request):
    if request.session['role'] != '0':
        return HttpResponseRedirect('/')
    user_id = request.session['user_id']
    username = request.session['username']
    memobj = models.Member()
    type = request.GET.get('type')
    print 'type:', type
    if type == None:
        type = '1'
    print 'type:', type
    curpage = request.GET.get('p')
    if curpage == None:
        curpage = '1'
    curpage = int(curpage)
    if curpage <= 0:
        curpage = 1
    print 'cur=' + str(curpage)
    if type == '0':
        reclist, pagenum, totalnum = memobj.myIndirectRef(user_id, curpage)
    else:
        reclist, pagenum, totalnum = memobj.myReference(user_id, curpage)

    print pagenum, totalnum
    prevpage = (1 if curpage - 1 < 1 else curpage - 1)
    nextpage = (pagenum if curpage + 1 > pagenum else curpage + 1)
    interval = 5
    firstshowpage = (curpage - 1) / interval * interval + 1
    lastshowpage = (firstshowpage + interval
                    if firstshowpage + interval < pagenum else pagenum + 1)
    pageshowlist = range(firstshowpage, lastshowpage)

    if firstshowpage == 1:
        preomit = False
        prevomitpage = 1  #useless here
    else:
        preomit = True
        prevomitpage = (1 if firstshowpage - 3 < 1 else firstshowpage - 3)

    if lastshowpage >= pagenum + 1:
        nextomit = False
        nextomitpage = pagenum  #useless here
    else:
        nextomit = True
        nextomitpage = (pagenum
                        if lastshowpage + 2 > pagenum else lastshowpage + 2)

    context = {
        'pagenum': pagenum,
        'totalnum': totalnum,
        'pageshowlist': pageshowlist,
        'prevpage': prevpage,
        'curpage': curpage,
        'preomit': preomit,
        'nextomit': nextomit,
        'prevomitpage': prevomitpage,
        'nextomitpage': nextomitpage,
        'nextpage': nextpage
    }
    context['username'] = username
    context['type'] = type
    context['reclist'] = reclist
    #	member_ = models.Member()
    #	list ,maxPage = member_.myReference(1,1)
    #print list
    #print "最多",maxPage
    return render(request, 'Member/MyRecomeAll.html', context)
Exemplo n.º 18
0
def RecomeList(request):
    if request.session['role'] != '0':
        return HttpResponseRedirect('/')
    username = request.session['username']
    user_id = request.session['user_id']
    memobj = models.Member()
    curpage = request.GET.get('p')
    if curpage == None:
        curpage = '1'
    curpage = int(curpage)
    if curpage <= 0:
        curpage = 1
    print 'cur=' + str(curpage)
    reflist, pagenum, totalnum = memobj.myReference(user_id, curpage)
    refInfolist = []
    for ref in reflist:
        print ref.user_id
        refcount = memobj.myReference(ref.user_id)[2]
        refInfo = {
            'nickname': ref.nickname,
            'bind_phone': ref.bind_phone,
            'regist_time': ref.register_time,
            'confirm_time': ref.confirm_time,
            'ref_num': refcount
        }
        refInfolist.append(refInfo)
    print pagenum, totalnum
    prevpage = (1 if curpage - 1 < 1 else curpage - 1)
    nextpage = (pagenum if curpage + 1 > pagenum else curpage + 1)
    interval = 5
    firstshowpage = (curpage - 1) / interval * interval + 1
    lastshowpage = (firstshowpage + interval
                    if firstshowpage + interval < pagenum else pagenum + 1)
    pageshowlist = range(firstshowpage, lastshowpage)

    if firstshowpage == 1:
        preomit = False
        prevomitpage = 1  #useless here
    else:
        preomit = True
        prevomitpage = (1 if firstshowpage - 3 < 1 else firstshowpage - 3)

    if lastshowpage >= pagenum + 1:
        nextomit = False
        nextomitpage = pagenum  #useless here
    else:
        nextomit = True
        nextomitpage = (pagenum
                        if lastshowpage + 2 > pagenum else lastshowpage + 2)

    context = {
        'pagenum': pagenum,
        'totalnum': totalnum,
        'pageshowlist': pageshowlist,
        'prevpage': prevpage,
        'curpage': curpage,
        'preomit': preomit,
        'nextomit': nextomit,
        'prevomitpage': prevomitpage,
        'nextomitpage': nextomitpage,
        'nextpage': nextpage
    }
    #context = {'username':username}
    context['username'] = username
    context['refInfolist'] = refInfolist

    return render(request, 'Member/RecomeList.html', context)