Skip to content

Commit

Permalink
add nyist
Browse files Browse the repository at this point in the history
  • Loading branch information
RTXUX committed Oct 14, 2023
1 parent 708de8e commit 9733bee
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 0 deletions.
24 changes: 24 additions & 0 deletions frontend/auth_providers/nyist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from datetime import timedelta

from django.urls import path

from .base import DomainEmailValidator
from .external import ExternalLoginView, ExternalGetCodeView


class LoginView(ExternalLoginView):
template_context = {'provider_name': '南阳理工学院'}
provider = 'nyist'
group = 'nyist'


class GetCodeView(ExternalGetCodeView):
provider = 'nyist'
duration = timedelta(hours=1)
validate_identity = DomainEmailValidator('nyist.edu.cn')


urlpatterns = [
path('nyist/login/', LoginView.as_view()),
path('nyist/get_code/', GetCodeView.as_view()),
]
1 change: 1 addition & 0 deletions frontend/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ <h2>协办单位选手</h2>
<a class="pure-button" href="/accounts/sustech/login/">南方科技大学</a>
<a class="pure-button" href="/accounts/xmut/login/">厦门理工学院</a>
<a class="pure-button" href="/accounts/shu/login/">上海大学</a>
<a class="pure-button" href="/accounts/nyist/login/">南阳理工学院</a>
</div>
<h2>其他选手</h2>
<div class="group">
Expand Down
1 change: 1 addition & 0 deletions frontend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
path('accounts/', include('frontend.auth_providers.sustech')),
path('accounts/', include('frontend.auth_providers.xmut')),
path('accounts/', include('frontend.auth_providers.shu')),
path('accounts/', include('frontend.auth_providers.nyist')),
path('accounts/', include('frontend.auth_providers.sms')),
path('accounts/', include('allauth.socialaccount.providers.google.urls')),
path('accounts/', include('allauth.socialaccount.providers.microsoft.urls')),
Expand Down
1 change: 1 addition & 0 deletions server/user/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class User:
'sustech': ['nickname', 'name', 'sno'],
'xmut': ['nickname', 'name', 'sno'],
'shu': ['nickname', 'name', 'sno'],
'nyist': ['nickname', 'name', 'sno'],
'other': ['nickname'],
'banned': ['nickname'],
}
Expand Down
17 changes: 17 additions & 0 deletions server/user/migrations/0016_add_nyist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.5 on 2023-10-14 13:15

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('user', '0015_update_groups_2023'),
]

operations = [
migrations.AlterModelOptions(
name='user',
options={'default_permissions': (), 'permissions': [('full', '管理个人信息'), ('view', '查看个人信息'), ('view_ustc', '查看中国科学技术大学个人信息'), ('view_zju', '查看浙江大学个人信息'), ('view_jlu', '查看吉林大学个人信息'), ('view_nuaa', '查看南京航空航天大学个人信息'), ('view_neu', '查看东北大学个人信息'), ('view_sysu', '查看中山大学个人信息'), ('view_xidian', '查看西安电子科技大学个人信息'), ('view_hit', '查看哈尔滨工业大学个人信息'), ('view_nudt', '查看国防科技大学个人信息'), ('view_fdu', '查看复旦大学个人信息'), ('view_tongji', '查看同济大学个人信息'), ('view_gdou', '查看广东海洋大学个人信息'), ('view_gdut', '查看广东工业大学个人信息'), ('view_gzhu', '查看广州大学个人信息'), ('view_sustech', '查看南方科技大学个人信息'), ('view_xmut', '查看厦门理工学院个人信息'), ('view_shu', '查看上海大学个人信息'), ('view_nyist', '查看南阳理工学院个人信息')]},
),
]
1 change: 1 addition & 0 deletions server/user/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Meta:
('view_sustech', '查看南方科技大学个人信息'),
('view_xmut', '查看厦门理工学院个人信息'),
('view_shu', '查看上海大学个人信息'),
('view_nyist', '查看南阳理工学院个人信息'),
]


Expand Down

0 comments on commit 9733bee

Please sign in to comment.