Пример #1
0
def completeInformation(request):
    sessionManager = SessionManager(request)
    if sessionManager.isAdministrator():  # 如果是管理员登录
        Authority = 'Admin'
    else:
        if sessionManager.isTrainer():  #教练登录
            Authority = 'Trainer'
        else:  # 如果是客户登陆
            Authority = 'Customer'
    # if sessionManager.isLogouted():
    #     return HttpResponseRedirect(url_login)
    if request.method == 'POST':
        completeForm = CompleteForm(request.POST)
        if completeForm.is_valid():
            identity = request.POST.get('identity')
            name = completeForm.cleaned_data.get('name')
            age = completeForm.cleaned_data.get('age')
            profession = completeForm.cleaned_data.get('profession')
            phoneNumber = completeForm.cleaned_data.get('phoneNumber')
            sex = completeForm.cleaned_data.get('sex')
            birthday = completeForm.cleaned_data.get('birthday')
            height = completeForm.cleaned_data.get('height')
            weight = completeForm.cleaned_data.get('weight')
            bust = completeForm.cleaned_data.get('bust')
            waistline = completeForm.cleaned_data.get('waistline')
            hipline = completeForm.cleaned_data.get('hipline')
            shoulderwidth = completeForm.cleaned_data.get('shoulderwidth')

            username = sessionManager.getUsername()
            personalInformation = PersonalInformation.objects.get(
                username=username)
            personalInformation.setIdentity(identity)
            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(url_index_logined)
    else:
        username = sessionManager.getUsername()
        user = PersonalInformation.objects.get(username=username)
        completeForm = CompleteForm(instance=user)
    return render(request, 'completeinformation.html', {
        'completeForm': completeForm,
        'Authority': Authority
    })  # 渲染页面
Пример #2
0
def viewCourseDetails(request, coursename):  # 显示课程的详细信息
    sessionManager = SessionManager(request)
    if sessionManager.isAdministrator():  #如果是管理员登陆
        courses = Course.objects.get(
            coursename=coursename)  # 查询当前课程信息,为了后面显示详细信息
        detailcourse = BuyRecord.objects.filter(
            coursename=coursename)  # 查询这个课程的所有订单(包括付钱和没付钱的)
        Authority = 'Admin'

    else:  #如果是客户或教练登录
        username = sessionManager.getUsername()  # 获取当前登录的用户名字
        courses = Course.objects.get(
            coursename=coursename)  # 查询当前课程信息,为了后面显示详细信息
        if sessionManager.isTrainer():  #如果是教练
            Authority = 'Trainer'

        else:
            Authority = 'Customer'
        detailcourse = BuyRecord.objects.filter(username=username,
                                                coursename=coursename)
    # 查询这个用户关于这门课的订单状态(付钱和没付钱的)
    return render(request, 'detailmessageUI.html', {
        'Authority': Authority,
        'courses': courses,
        'order1': detailcourse
    })
Пример #3
0
def uncustomercourse(request):  # 向页面输出当前用户未支付的订单信息
    username = SessionManager.getUsername(request)  # 获取当前登录的用户名字
    user = BuyRecord.objects.filter(username=username,
                                    pay_flag=False,
                                    valid=True)  # 获取当前用户未支付的课程信息
    Authority = 'Customer'
    return render(request, 'uncustomercourseUI.html', {
        'order': user,
        'Authority': Authority
    })  # 渲染页面 按照课程名排序
Пример #4
0
def forgetPassword(request):
    sessionManager = SessionManager(request)
    if sessionManager.isLogined():
        if sessionManager.isAdministrator():
            return HttpResponseRedirect(url_index_logined)
        return HttpResponseRedirect(url_index_logined)
    if sessionManager.getUsername() is None:
        return HttpResponseRedirect(url_forget_password_login)
    if request.method == 'POST':
        forgetPasswordForm = ForgetPasswordForm(request.POST)
        if forgetPasswordForm.is_valid():
            username = sessionManager.getUsername()
            newPassword = forgetPasswordForm.cleaned_data.get('newPassword')
            user = Customer.objects.get(username=username)
            user.setPassword(newPassword)
            return HttpResponseRedirect(url_login)
    else:
        forgetPasswordForm = ForgetPasswordForm()
    return render(request, 'forgetPasswordUI.html',
                  {'forgetPasswordForm': forgetPasswordForm})
Пример #5
0
def UserCourseUsed(request):
    sessionManager = SessionManager(request)
    username = sessionManager.getUsername()
    if request.method == 'POST':
        coursename = request.POST.get('coursename')
        if coursename == 'all':
            user_list = CourseUsedRecord.objects.filter(username=username)
            used_times = 0
        else:
            user_list = CourseUsedRecord.objects.filter(username=username,
                                                        coursename=coursename)
            used_times = CourseUsedRecord.objects.filter(
                username=username, coursename=coursename).count()
    return render(request, 'UserCourseUsedRecord.html', locals())
Пример #6
0
def changePassword(request):
    sessionManager = SessionManager(request)
    if sessionManager.isLogouted():
        return HttpResponseRedirect(url_login)
    if sessionManager.isAdministrator():
        return HttpResponseRedirect(url_index_logined)
    if request.method == 'POST':
        changePasswordForm = ChangePasswordForm(request.POST)
        changePasswordForm.username = sessionManager.getUsername()
        if changePasswordForm.is_valid():
            username = changePasswordForm.username
            user = Customer.objects.get(username=username)
            newPassword = changePasswordForm.cleaned_data.get('newPassword')
            user.setPassword(newPassword)
            sessionManager.setLogout()
            return HttpResponseRedirect(url_login)  # 跳转登录页面
    else:
        changePasswordForm = ChangePasswordForm()
    return render(request, "ChangePasswordUI.html",
                  {'changePasswordForm': changePasswordForm})
Пример #7
0
def purchase(request):
    sessionManager = SessionManager(request)
    if sessionManager.isLogouted():
        return HttpResponseRedirect(url_login)
    if sessionManager.isAdministrator():
        return HttpResponseRedirect(url_index)
    if request.method == 'POST':
        username_now = sessionManager.getUsername()
        course = request.POST.get('course_name', '')
        amounttemp = request.POST.get('quantity', '')
        if course and amounttemp:
            course_temp = Course.objects.get(coursename=course)
            idtemp = BuyRecord.objects.order_by('-number')
            numbertemp = idtemp[0].getNumber() + 1
            temp = int(amounttemp)
            p = BuyRecord()
            p.number = numbertemp
            p.username = username_now
            p.price = temp * course_temp.getCoursePrice()
            p.coursename = course_temp.getCourseName()
            p.amount = temp
            p.setPayFlag(False)
            return HttpResponse("添加成功")
    return HttpResponse("添加失败")
Пример #8
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())  # 返回修改成功信息