示例#1
0
def customercourse(request):  # 向页面输出当前用户已支付的订单信息
    username = SessionManager.getUsername(request)  #获取当前登录的用户名字
    user = BuyRecord.objects.filter(username=username,
                                    pay_flag=True,
                                    valid=True)  #获取当前用户已经支付的课程信息
    return render(request, 'customercourseUI.html',
                  {'order': user})  # 渲染页面 按照课程名排序
示例#2
0
def completeinformation(request):  #用户点击提交完善的个人信息
    if request.method == 'POST':  # 如果请求为表单提交
        completeForm = CompleteForm(request.POST)  # 获取表单内容
        if completeForm.is_valid():  # 解析表单
            name = FormsManager.getData(completeForm, 'name')
            age = FormsManager.getData(completeForm, 'age')
            profession = FormsManager.getData(completeForm, 'profession')
            phoneNumber = FormsManager.getData(completeForm, 'phoneNumber')
            sex = FormsManager.getData(completeForm, 'sex')
            birthday = FormsManager.getData(completeForm, 'birthday')
            height = FormsManager.getData(completeForm, 'height')
            weight = FormsManager.getData(completeForm, 'weight')
            bust = FormsManager.getData(completeForm, 'bust')
            waistline = FormsManager.getData(completeForm, 'waistline')
            hipline = FormsManager.getData(completeForm, 'hipline')
            shoulderwidth = FormsManager.getData(completeForm, 'shoulderwidth')

            #判断数据是否正确

            #正确过后写数据库
            username = SessionManager.getUsername(request)
            personalInformation = PersonalInformationDB.objects.get(
                username=username)

            personalInformation.setName(name)
            personalInformation.setAge(age)
            personalInformation.setProfession(profession)
            personalInformation.setPhoneNumber(phoneNumber)
            personalInformation.setSex(sex)
            personalInformation.setBirthday(birthday)
            personalInformation.setHeight(height)
            personalInformation.setWeight(weight)
            personalInformation.setBust(bust)
            personalInformation.setWaistline(waistline)
            personalInformation.setHipline(hipline)
            personalInformation.setShoulderwidth(shoulderwidth)

            return HttpResponseRedirect("/customerloginedindex/")  # 跳转登陆后首页

    else:
        usernamedd = SessionManager.getUsername(request)
        userid = PersonalInformationDB.objects.filter(username=usernamedd)
        if userid:
            completeForm = CompleteForm(instance=userid[0])
        else:
            completeForm = CompleteForm()  # 创建表单
    return render(request, 'completeinformationUI.html', locals())  # 渲染页面
示例#3
0
文件: views.py 项目: Littlle/AmyYoga
def forgetPassword(request):
    if SessionManager.isAdministrator(request):
        return HttpResponse("管理员禁止使用修改密码功能")  #不修改
    if SessionManager.getUsername(request) is None:
        return HttpResponseRedirect("/forgetpasswordlogin/")
    #如果method是post(发布
    if request.method == 'POST':
        forgetPasswordForm = ForgetPasswordForm(request.POST)
        #如果更改密码 有效
        if forgetPasswordForm.is_valid():
            username = SessionManager.getUsername(request)
            newPassword = FormsManager.getData(forgetPasswordForm,
                                               'newPassword')
            user = UserDB.objects.get(username=username)
            user.setPassword(newPassword)
            return HttpResponseRedirect("/login/")  #跳转登录页面
    else:
        forgetPasswordForm = ForgetPasswordForm()

    return render(request, 'forgetPasswordUI.html', locals())
示例#4
0
文件: views.py 项目: Littlle/AmyYoga
def changePassword(request):
    if SessionManager.isAdministrator(request):
        return HttpResponse("管理员禁止使用修改密码功能")  # 不修改
    if SessionManager.isLogouted(request):
        return HttpResponseRedirect("/forgetpassword/")
    if request.method == 'POST':
        changePasswordForm = ChangePasswordForm(request.POST)
        changePasswordForm.username = SessionManager.getUsername(request)
        if changePasswordForm.is_valid():
            oldPassword = FormsManager.getData(changePasswordForm,
                                               'oldPassword')
            username = changePasswordForm.username
            user = UserDB.objects.get(username=username)
            newPassword = FormsManager.getData(changePasswordForm,
                                               'newPassword')
            user.setPassword(newPassword)
            SessionManager.setLogout(request)
            return HttpResponseRedirect("/login/")  #跳转登录页面
    else:
        changePasswordForm = ChangePasswordForm()
    return render(request, "ChangePasswordUI.html", locals())
示例#5
0
def cancelorder(request, number):  #取消订单
    username = SessionManager.getUsername(request)  # 获取当前登录的用户名字
    Q = BuyRecord.objects.get(username=username, number=number)  #获取当前用户点击的订单对象
    Q.setValid(False)  #将找到的对象相应的位置为false,表明当前订单为取消状态
    return render(request, 'successUI.html', locals())  # 返回修改成功信息