Skip to content

Commit

Permalink
update 2023 groups
Browse files Browse the repository at this point in the history
  • Loading branch information
RTXUX committed Oct 9, 2023
1 parent c7be2d6 commit b1b9dc0
Show file tree
Hide file tree
Showing 12 changed files with 193 additions and 7 deletions.
4 changes: 2 additions & 2 deletions frontend/auth_providers/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class ExternalGetCodeView(BaseGetCodeView):

def send(self, identity, code):
use_smtp = settings.EXTERNAL_LOGINS[self.provider]['use_smtp']
url = settings.EXTERNAL_LOGINS[self.provider]['url']
key = settings.EXTERNAL_LOGINS[self.provider]['key']
url = settings.EXTERNAL_LOGINS[self.provider].get('url', "")
key = settings.EXTERNAL_LOGINS[self.provider].get('key', "")

if settings.DEBUG or use_smtp:
EmailMessage(
Expand Down
24 changes: 24 additions & 0 deletions frontend/auth_providers/gdou.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 = 'gdou'
group = 'gdou'


class GetCodeView(ExternalGetCodeView):
provider = 'gdou'
duration = timedelta(hours=1)
validate_identity = DomainEmailValidator(['stu.gdou.edu.cn'])


urlpatterns = [
path('gdou/login/', LoginView.as_view()),
path('gdou/get_code/', GetCodeView.as_view()),
]
24 changes: 24 additions & 0 deletions frontend/auth_providers/gdut.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 = 'gdut'
group = 'gdut'


class GetCodeView(ExternalGetCodeView):
provider = 'gdut'
duration = timedelta(hours=1)
validate_identity = DomainEmailValidator(['mail2.gdut.edu.cn'])


urlpatterns = [
path('gdut/login/', LoginView.as_view()),
path('gdut/get_code/', GetCodeView.as_view()),
]
24 changes: 24 additions & 0 deletions frontend/auth_providers/gzhu.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 = 'gzhu'
group = 'gzhu'


class GetCodeView(ExternalGetCodeView):
provider = 'gzhu'
duration = timedelta(hours=1)
validate_identity = DomainEmailValidator(['e.gzhu.edu.cn'])


urlpatterns = [
path('gzhu/login/', LoginView.as_view()),
path('gzhu/get_code/', GetCodeView.as_view()),
]
24 changes: 24 additions & 0 deletions frontend/auth_providers/shu.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 UserRegexAndDomainEmailValidator
from .external import ExternalLoginView, ExternalGetCodeView


class LoginView(ExternalLoginView):
template_context = {'provider_name': '上海大学'}
provider = 'shu'
group = 'shu'


class GetCodeView(ExternalGetCodeView):
provider = 'shu'
duration = timedelta(hours=1)
validate_identity = UserRegexAndDomainEmailValidator('shu.edu.cn', r'^(?:[a-z]|_|-|\d){3,50}$')


urlpatterns = [
path('shu/login/', LoginView.as_view()),
path('shu/get_code/', GetCodeView.as_view()),
]
24 changes: 24 additions & 0 deletions frontend/auth_providers/sustech.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 = 'sustech'
group = 'sustech'


class GetCodeView(ExternalGetCodeView):
provider = 'sustech'
duration = timedelta(hours=1)
validate_identity = DomainEmailValidator(['sustech.edu.cn', 'mail.sustech.edu.cn'])


urlpatterns = [
path('sustech/login/', LoginView.as_view()),
path('sustech/get_code/', GetCodeView.as_view()),
]
24 changes: 24 additions & 0 deletions frontend/auth_providers/xmut.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 = 'xmut'
group = 'xmut'


class GetCodeView(ExternalGetCodeView):
provider = 'xmut'
duration = timedelta(hours=1)
validate_identity = DomainEmailValidator(['s.xmut.edu.cn'])


urlpatterns = [
path('xmut/login/', LoginView.as_view()),
path('xmut/get_code/', GetCodeView.as_view()),
]
7 changes: 6 additions & 1 deletion frontend/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@
<li class="pure-menu-item"><a href="/accounts/hit/login/" class="pure-menu-link">哈尔滨工业大学</a></li>
<li class="pure-menu-item"><a href="/accounts/nudt/login/" class="pure-menu-link">国防科技大学</a></li>
<li class="pure-menu-item"><a href="/accounts/fdu/login/" class="pure-menu-link">复旦大学</a></li>
<li class="pure-menu-item"><a href="/accounts/ouc/login/" class="pure-menu-link">中国海洋大学</a></li>
<li class="pure-menu-item"><a href="/accounts/tongji/login/" class="pure-menu-link">同济大学</a></li>
<li class="pure-menu-item"><a href="/accounts/gdou/login/" class="pure-menu-link">广东海洋大学</a></li>
<li class="pure-menu-item"><a href="/accounts/gdut/login/" class="pure-menu-link">广东工业大学</a></li>
<li class="pure-menu-item"><a href="/accounts/gzhu/login/" class="pure-menu-link">广州大学</a></li>
<li class="pure-menu-item"><a href="/accounts/sustech/login/" class="pure-menu-link">南方科技大学</a></li>
<li class="pure-menu-item"><a href="/accounts/xmut/login/" class="pure-menu-link">厦门理工学院</a></li>
<li class="pure-menu-item"><a href="/accounts/shu/login/" class="pure-menu-link">上海大学</a></li>
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover">
<a href="#" class="pure-menu-link">其他选手</a>
<ul class="pure-menu-children">
Expand Down
7 changes: 6 additions & 1 deletion frontend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@
path('accounts/', include('frontend.auth_providers.hit')),
path('accounts/', include('frontend.auth_providers.nudt')),
path('accounts/', include('frontend.auth_providers.fdu')),
path('accounts/', include('frontend.auth_providers.ouc')),
path('accounts/', include('frontend.auth_providers.tongji')),
path('accounts/', include('frontend.auth_providers.gdou')),
path('accounts/', include('frontend.auth_providers.gdut')),
path('accounts/', include('frontend.auth_providers.gzhu')),
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.sms')),
path('accounts/', include('allauth.socialaccount.providers.google.urls')),
path('accounts/', include('allauth.socialaccount.providers.microsoft.urls')),
Expand Down
14 changes: 12 additions & 2 deletions server/user/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ class User:
'hit': '哈尔滨工业大学',
'nudt': '国防科技大学',
'fdu': '复旦大学',
'ouc': '中国海洋大学',
'tongji': '同济大学',
'gdou': '广东海洋大学',
'gdut': '广东工业大学',
'gzhu': '广州大学',
'sustech': '南方科技大学',
'xmut': '厦门理工学院',
'shu': '上海大学',
'other': '其他选手',
'banned': '已封禁',
}
Expand All @@ -78,8 +83,13 @@ class User:
'hit': ['nickname', 'name', 'sno', 'campus'],
'nudt': ['nickname', 'name', 'email'],
'fdu': ['nickname', 'name', 'sno'],
'ouc': ['nickname', 'name', 'sno'],
'tongji': ['nickname', 'name', 'sno', 'school', 'major'],
'gdou': ['nickname', 'name', 'sno'],
'gdut': ['nickname', 'name', 'sno'],
'gzhu': ['nickname', 'name', 'sno'],
'sustech': ['nickname', 'name', 'sno'],
'xmut': ['nickname', 'name', 'sno'],
'shu': ['nickname', 'name', 'sno'],
'other': ['nickname'],
'banned': ['nickname'],
}
Expand Down
17 changes: 17 additions & 0 deletions server/user/migrations/0015_update_groups_2023.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.5 on 2023-10-09 07:42

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('user', '0014_user_suspicious_ddl_userlog_suspicious_ddl'),
]

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', '查看上海大学个人信息')]},
),
]
7 changes: 6 additions & 1 deletion server/user/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ class Meta:
('view_hit', '查看哈尔滨工业大学个人信息'),
('view_nudt', '查看国防科技大学个人信息'),
('view_fdu', '查看复旦大学个人信息'),
('view_ouc', '查看中国海洋大学个人信息'),
('view_tongji', '查看同济大学个人信息'),
('view_gdou', '查看广东海洋大学个人信息'),
('view_gdut', '查看广东工业大学个人信息'),
('view_gzhu', '查看广州大学个人信息'),
('view_sustech', '查看南方科技大学个人信息'),
('view_xmut', '查看厦门理工学院个人信息'),
('view_shu', '查看上海大学个人信息'),
]


Expand Down

0 comments on commit b1b9dc0

Please sign in to comment.