Exemple #1
0
def course(request):  # 课程相关
    sessionManager = SessionManager(request)
    if sessionManager.isLogined():  # 如果是登陆状态,那么对应页面就应该显示登出
        status = 'LOGIN'
    else:  # 如果是未登录状态,那么对应页面就应该显示登陆或者注册
        status = 'LOGOUT'
    return render(request, 'course.html', {"status": status})
Exemple #2
0
def teacherteam(request):  # 师资团队页面
    sessionManager = SessionManager(request)
    if sessionManager.isLogined():  #如果是登陆状态,那么对应页面就应该显示登出
        status = 'LOGIN'
    else:  #如果是未登录状态,那么对应页面就应该显示登陆或者注册
        status = 'LOGOUT'
    return render(request, 'teacherteam.html', {"status": status})
Exemple #3
0
def yoga(request):  # 瑜伽科普
    sessionManager = SessionManager(request)
    if sessionManager.isLogined():  #如果是登陆状态,那么对应页面就应该显示登出
        status = 'LOGIN'
    else:  #如果是未登录状态,那么对应页面就应该显示登陆或者注册
        status = 'LOGOUT'
    return render(request, 'yoga.html', {"status": status})
Exemple #4
0
def register(request):  #用户注册
    sessionManager = SessionManager(request)
    if sessionManager.isLogined():
        return HttpResponseRedirect(url_index_logined)
    if request.method == 'POST':
        registerForm = RegisterForm(request.POST)
        if registerForm.is_valid():
            username = registerForm.cleaned_data.get('username')
            password = registerForm.cleaned_data.get('password')
            phoneNumber = registerForm.cleaned_data.get('phoneNumber')
            birthday = registerForm.cleaned_data.get('birthday')
            identity = request.POST.get('identity')

            #Customer.objects.create(username=username, password=password)
            if identity == 'customer':
                Customer.objects.create(username=username,
                                        password=password,
                                        identitySignal=1)
            elif identity == 'trainer':
                Customer.objects.create(username=username,
                                        password=password,
                                        identitySignal=2)

            personalInformation = PersonalInformation.objects.create(
                username=username)
            personalInformation.setIdentity(identity)
            personalInformation.setPhoneNumber(phoneNumber)
            personalInformation.setBirthday(birthday)
            return HttpResponseRedirect(url_login)
    else:
        registerForm = RegisterForm()
    return render(request, "RegisterUI.html", {'registerForm': registerForm})
Exemple #5
0
def index(request):  # 首页页面
    sessionManager = SessionManager(request)
    if sessionManager.isLogined():  #如果是登陆状态,那么对应页面就应该显示登出
        status = 'LOGIN'
    else:  #如果是未登录状态,那么对应页面就应该显示登陆或者注册
        status = 'LOGOUT'
    return render(request, 'Index.html', {"status": status})  # 渲染页面
Exemple #6
0
def login(request):
    sessionManager = SessionManager(request)
    if request.method == 'POST':
        loginForm = LoginForm(request.POST)
        if loginForm.is_valid():
            username = loginForm.cleaned_data.get('username')
            password = loginForm.cleaned_data.get('password')
            user = Customer.objects.get(username=username)
            sessionManager.setLogin(username)
            return HttpResponseRedirect(url_index_logined)
    else:
        if sessionManager.isLogined():
            return HttpResponseRedirect(url_index)
        else:
            loginForm = LoginForm()
    return render(request, 'loginUI.html', {'loginForm': loginForm})
Exemple #7
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})
Exemple #8
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})
Exemple #9
0
def logout(request):
    sessionManager = SessionManager(request)
    if sessionManager.isLogined():
        sessionManager.setLogout()
    return HttpResponseRedirect(url_index)