diff --git a/app/urls.py b/app/urls.py index cd8968d6b..5e14be527 100644 --- a/app/urls.py +++ b/app/urls.py @@ -26,7 +26,6 @@ # path("requestLoginOrg/", views.requestLoginOrg, name="requestLoginOrg"), # 已废弃 path("welcome/", views.homepage, name="welcome"), path("freshman/", views.freshman, name="freshman"), - path("register/", views.authRegister, name="register"), path("agreement/", views.userAgreement, name="userAgreement"), path("shiftAccount/", views.shiftAccount, name="shiftAccount"), # path("org/", views.org, name="org"), diff --git a/app/views.py b/app/views.py index 0db53b341..36aeb9a22 100644 --- a/app/views.py +++ b/app/views.py @@ -1117,7 +1117,7 @@ def _create_freshman_account(sid: str, email: str = None): current = "创建用户" user = User.objects.create_user( username=sid, name=name, - usertype=User.Type.PERSON, + usertype=User.Type.STUDENT, password=password ) current = "创建个人账号" @@ -1278,48 +1278,6 @@ def userAgreement(request: UserRequest): dict(request=request, bar_display=bar_display)) -@deprecated -@logger.secure_view() -def authRegister(request: HttpRequest): - if not request.user.is_superuser: - return HttpResponseRedirect("/index/") - - if request.method == "POST" and request.POST: - keys = ["name", "password", "snum", "email", "password2", "syear", "sgender"] - values = [request.POST[key] for key in keys] - name, password, sno, email, password2, stu_grade, gender = values - if password != password2: - return render(request, "index.html") - - failed = False - failed |= gender not in ['男', '女'] - failed |= SQ.sfilter(NaturalPerson.person_id, sno).exists() - failed |= NaturalPerson.objects.filter(email=email).exists() - if failed: - return render(request, "auth_register_boxed.html") - - # OK! - try: - user = User.objects.create_user( - username=sno, name=name, - usertype=User.Type.PERSON, - password=password - ) - person = NaturalPerson.objects.create( - user, - stu_id_dbonly=sno, - name=name, - email=email, - stu_grade=stu_grade, - gender=NaturalPerson.Gender.MALE if gender == '男' - else NaturalPerson.Gender.FEMALE, - ) - except: - return HttpResponseRedirect("/admin/") - return HttpResponseRedirect("/index/") - return render(request, "auth_register_boxed.html") - - @login_required(redirect_field_name="origin") @utils.check_user_access(redirect_url="/logout/") @logger.secure_view() diff --git a/static/assets/js/dorm_forcement.js b/static/assets/js/dorm_forcement.js index 5dc2bd44a..c6ef819e9 100644 --- a/static/assets/js/dorm_forcement.js +++ b/static/assets/js/dorm_forcement.js @@ -1,9 +1,10 @@ +const user_agreement_path = '/agreement' const dorm_path = '/dormitory/agreement'; const query_path = '/dormitory/agreement-query-fixme'; -function currentIsDormPage() { +function skipThisPage() { var current_url = window.location.pathname; - return current_url.includes(dorm_path); + return current_url.includes(dorm_path) || current_url.includes(user_agreement_path); } function getAgreementState() { @@ -21,8 +22,8 @@ function getAgreementState() { }); } -$(function() { - if (!currentIsDormPage()) { +$(function () { + if (!skipThisPage()) { getAgreementState().then(signed => { if (!signed) { window.location.href = dorm_path;