Пример #1
0
def viewDetails(request, username):
    sessionManager = SessionManager(request)
    if sessionManager.isAdministrator():  # 如果是管理员登陆
        Authority = 'Admin'
    else:  # 如果是客户登陆
        Authority = 'Customer'
    if sessionManager.isLogouted():
        return HttpResponseRedirect(url_login)
    if not sessionManager.isAdministrator():
        return HttpResponseRedirect(url_index)
    userList = PersonalInformation.objects.filter(username=username)
    detailflag = 'true'
    return render(request, 'personalinformation.html', {"user_list": userList,'Authority': Authority, 'detailflag': detailflag})
Пример #2
0
def viewMemeberList(request):
    sessionManager = SessionManager(request)
    if sessionManager.isAdministrator():  # 如果是管理员登陆
        Authority = 'Admin'
    else:  # 如果是客户登陆
        Authority = 'Customer'
    if sessionManager.isLogouted():
        return HttpResponseRedirect(url_login)
    if not sessionManager.isAdministrator():
        return HttpResponseRedirect(url_index)
    userList = PersonalInformation.objects.all()
    detailflag = 'false'
    return render(request, 'personalinformation.html', {'user_list': userList, 'Authority': Authority,
                                                        'detailflag': detailflag })
Пример #3
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
    })
Пример #4
0
def reAddCourse(request, coursename):  # 执行重新上架操作
    sessionManager = SessionManager(request)
    if not sessionManager.isAdministrator():
        return HttpResponseRedirect(url_index)
    P = Course.objects.get(coursename=coursename)  # 先获取当前课程信息
    P.setCourseFlag(True)  # 重新上架课程
    return render(request, 'successfulUI.html', locals())
Пример #5
0
def DelCourse(request, coursename):  # 执行下架操作
    sessionManager = SessionManager(request)
    if not sessionManager.isAdministrator():
        return HttpResponseRedirect(url_index)
    P = Course.objects.get(coursename=coursename)  # 先获取当前课程信息
    P.setCourseFlag(False)  # 下架课程
    Authority = 'Admin'
    return render(request, 'successfulUI.html', locals())
Пример #6
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
    })  # 渲染页面
Пример #7
0
def buycourse(request):
    sessionManager = SessionManager(request)
    if sessionManager.isLogouted():
        return HttpResponseRedirect(url_login)
    if not sessionManager.isAdministrator():
        return HttpResponseRedirect(url_index)
    temp = CourseForm()
    Authority = 'Admin'
    return render(request, 'buycourserightnow.html', {
        "Authority": Authority,
        'temp': temp
    })
Пример #8
0
def purchaseCourse(request):
    sessionManager = SessionManager(request)
    if sessionManager.isLogouted():
        return HttpResponseRedirect(url_login)
    if sessionManager.isAdministrator():
        return HttpResponseRedirect(url_login)
    Authority = 'Customer'
    course_list = Course.objects.filter(course_flag=True)
    return render(request, 'purchaseCourse.html', {
        "Authority": Authority,
        'course_list': course_list
    })
Пример #9
0
def loginedIndex(request):  # 客户登陆过后显示的首界面
    sessionManager = SessionManager(request)
    if sessionManager.isLogouted():
        return HttpResponseRedirect(url_index)
    if sessionManager.isAdministrator():
        Authority = 'Admin'
        return render(request, 'AdminIndex.html',
                      {"Authority": Authority})  # 渲染页面,传递参数
    else:
        Authority = 'Customer'
        return render(request, 'CustomerIndex.html',
                      {"Authority": Authority})  # 渲染页面,传递参数
Пример #10
0
def viewCourse(request):  # 查看课程信息
    sessionManager = SessionManager(request)
    if sessionManager.isAdministrator():  #如果是管理员登陆
        courses = Course.objects.all()  # 查询全部课程信息
        Authority = 'Admin'

    else:  #如果是客户登陆
        courses = Course.objects.filter(course_flag=True)  # 查询在使用的课程信息
        Authority = 'Customer'

    return render(request, 'coursemessageUI.html', {
        'order': courses,
        'Authority': Authority
    })
Пример #11
0
def vipDetails(request, username):
    sessionManager = SessionManager(request)
    if sessionManager.isAdministrator():  # 如果是管理员登陆
        Authority = 'Admin'
    elif sessionManager.isTrainer():
        Authority = 'Trainer'
    else:  # 如果是客户登陆
        Authority = 'Customer'
    userList = PersonalInformation.objects.filter(username=username)
    detailflag = 'true'
    return render(request, 'vipInformations.html', {
        "user_list": userList,
        'Authority': Authority,
        'detailflag': detailflag
    })
Пример #12
0
def vipInformation(request):
    sessionManager = SessionManager(request)
    if sessionManager.isAdministrator():  # 如果是管理员登录
        Authority = 'Admin'
    else:
        if sessionManager.isTrainer():  #教练登录
            Authority = 'Trainer'
        else:  # 如果是客户登录
            Authority = 'Customer'
    userList = PersonalInformation.objects.all()
    detailflag = 'false'
    return render(request, 'vipInformations.html', {
        'user_list': userList,
        'Authority': Authority,
        'detailflag': detailflag
    })  # 渲染页面
Пример #13
0
def showtherecord(request):
    sessionManager = SessionManager(request)
    if sessionManager.isLogouted():
        return HttpResponseRedirect(url_login)
    if not sessionManager.isAdministrator():
        return HttpResponseRedirect(url_index)
    Authority = 'Admin'  #表示是管理员身份
    localflag = 'True'  #表示是否在主订单节面,作用实现html文件的复用,下同
    iterable = 'True'  #record_list是否可以迭代
    record_list = BuyRecord.objects.filter(valid=True)
    return render(
        request, 'showrecord.html', {
            "Authority": Authority,
            'record_list': record_list,
            'localflag': localflag,
            'iterable': iterable
        })
Пример #14
0
def detailrecord(request, recordid):
    sessionManager = SessionManager(request)
    if sessionManager.isLogouted():
        return HttpResponseRedirect(url_login)
    if not sessionManager.isAdministrator():
        return HttpResponseRedirect(url_index)
    Authority = 'Admin'
    localflag = 'False'
    iterable = 'False'
    record_list = BuyRecord.objects.get(number=recordid)
    return render(
        request, 'showrecord.html', {
            "Authority": Authority,
            'item': record_list,
            "localflag": localflag,
            'iterable': iterable
        })
Пример #15
0
def makerecord(request, cord):
    sessionManager = SessionManager(request)
    if sessionManager.isLogouted():
        return HttpResponseRedirect(url_login)
    if not sessionManager.isAdministrator():
        return HttpResponseRedirect(url_index)
    item = BuyRecord.objects.get(number=cord)
    item.setPayFlag(True)
    Authority = 'Admin'
    localflag = 'False'
    iterable = 'False'
    return render(
        request, 'showrecord.html', {
            "Authority": Authority,
            'item': item,
            'localflag': localflag,
            'iterable': iterable
        })
Пример #16
0
def addCourse(request):  # 管理员增加课程信息
    sessionManager = SessionManager(request)
    if not sessionManager.isAdministrator():
        return HttpResponseRedirect(url_index)
    if request.method == 'POST':
        addcourseForm = AddCourseForm(request.POST)
        if addcourseForm.is_valid():
            coursename = addcourseForm.cleaned_data.get('coursename')
            courseintroduction = addcourseForm.cleaned_data.get(
                'courseintroduction')
            courseprice = addcourseForm.cleaned_data.get('courseprice')
            course = Course()
            course.create(coursename, courseintroduction, courseprice)
            return HttpResponseRedirect(url_course_view_course)
    else:
        addcourseForm = AddCourseForm()
        Authority = 'Admin'
        return render(request, 'addcourseUI.html', locals())
Пример #17
0
def forgetPasswordLogin(request):
    sessionManager = SessionManager(request)
    if sessionManager.isLogined():
        if sessionManager.isAdministrator():
            return HttpResponseRedirect(url_index_logined)
        return HttpResponseRedirect(url_index_logined)
    if request.method == 'POST':
        usernameForm = UsernameForm(request.POST)
        if usernameForm.is_valid():
            username = usernameForm.cleaned_data.get('username')
            user = Customer.objects.get(username=username)
            if user.isAdministrator():
                return HttpResponseRedirect(url_index)
            sessionManager.setUsername(username)
            return HttpResponseRedirect(url_forget_password)
    else:
        usernameForm = UsernameForm()
    return render(request, 'forgetPasswordUI.html',
                  {'usernameForm': usernameForm})
Пример #18
0
def ModCourse(request, coursename):  # 修改课程信息界面
    sessionManager = SessionManager(request)
    if not sessionManager.isAdministrator():
        return HttpResponseRedirect(url_index)
    if request.method == 'POST':  # 如果请求为表单提交
        modcourseForm = ModCourseForm(request.POST)  # 获取表单内容
        if modcourseForm.is_valid():  # 解析表单
            courseintroduction = modcourseForm.cleaned_data[
                'courseintroduction']
            courseprice = modcourseForm.cleaned_data['courseprice']
            R = Course.objects.get(coursename=coursename)  # 查询当前修改信息的课程对象
            R.setCourseIntroduction(courseintroduction)
            R.setCoursePrice(courseprice)
            return HttpResponseRedirect(
                url_course_view_course)  # 写成功之后,跳转到查看课程
    else:
        r = Course.objects.get(coursename=coursename)  # 查询当前课程的信息
        modcourseForm = ModCourseForm(instance=r)  # 创建表单
        return render(request, 'modcourseUI.html', locals())
Пример #19
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})
Пример #20
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})
Пример #21
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("添加失败")