Commit Graph

70 Commits

Author SHA1 Message Date
625f2466e5 refactor: 统一用户名的 ks 班级前缀处理
同一个剥前缀函数在 submission 和 flowchart 的管理端各有一份逐字相同的
拷贝,conf 里还有一份内联写法,合并到 utils/shortcuts.strip_class_prefix。

改名是因为原名 get_real_name 和 UserProfile.real_name 字段、以及三个
serializer 里的同名方法都容易混。

行为上修了两处:

- 剥前缀改用 removeprefix,不再按长度硬切。班级号对不上时原样返回,
  旧写法会从中间截出乱码(ks999王五 配 class_name=251 会切成「王五」)
- get_class_name 的正则从 \d+ 收紧到 \d{3,4},与前端
  ButtonWithSearch 的 /^ks\d{3,4}/ 对齐。旧的贪婪匹配在姓名部分是纯
  数字时会吃掉整串(ks251001 返回 251001 而不是 251)。顺带 re.search
  换成 re.match,外层的 startswith 判断并进正则

正常数据(ks251张三、ks2510李四)新旧结果一致,已逐例对拍。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 23:58:13 -06:00
927f235537 refactor: 移除邮件功能
发信能力整体下线,唯一的调用方(忘记密码)前端也从来没接过。

- utils/shortcuts.py 删 send_email,连带四个 django.core.mail 相关 import
- account/tasks.py 整个删除,里面只有 send_email_async 一个 actor
- 删 ApplyResetPasswordAPI / ResetPasswordAPI 及其路由、serializer,
  User.reset_password_token 和 reset_password_token_expire_time 两个
  字段(account/0010)
- 删 SMTPAPI / SMTPTestAPI 及其路由、三个 SMTP serializer、
  SysOptions.smtp_config
- account/templates/reset_password_email.html

options/0003 数据迁移删掉库里的 smtp_config 行:_init_option 会为每个
OptionKey 建行,key 从代码里去掉后它会变成孤儿,而且配过 SMTP 的话
value 里存着明文密码。

保留 ResetUserPasswordAPI(管理端直接重置密码,不发信,前端在用)和
User.email(注册要填)。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 23:17:48 -06:00
989b33d827 refactor: 移除 2FA 功能与三个冗余依赖
2FA 早已是死代码:TOTP 相关端点标注为前端未调用,前端唯一的
two_factor_auth 是硬编码 false,没有任何入口能打开它。

- 删除 TwoFactorAuthAPI、CheckTFARequiredAPI、_totp* 辅助函数、
  TwoFactorAuthCodeSerializer 及各 serializer 的 tfa_code 字段
- 删除管理端写 two_factor_auth/tfa_token 的分支。登录已不再校验
  TOTP,若保留写入路径,置 True 会变成静默的安全降级
- 删除 User.two_factor_auth / tfa_token 字段(迁移 0009)
- 移除 django-dbconn-retry:仅挂在 INSTALLED_APPS,代码零引用。
  DATABASES 未配置 CONN_MAX_AGE(默认 0),本就没有持久连接需要
  重连修复。要开持久连接用 Django 自带的 CONN_HEALTH_CHECKS
- requests 换成 httpx(openai 已经引入):删除废弃的
  ReleaseNotesAPI,judge dispatcher 显式传 timeout=None 以保持
  requests 原本的无超时行为,判题请求是同步等结果的

依赖净减 5 个:otpauth、qrcode、requests、charset-normalizer、
django-dbconn-retry

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 23:00:45 -06:00
3a9ab83ba5 style: ruff format 全仓库
行宽 180 下把历史遗留的折行表达式合并,无语义改动。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-05 04:45:26 -06:00
57c0572fd9 async 2026-05-26 21:25:26 -06:00
028ea6e5f9 fmt 2026-04-23 13:57:56 -06:00
a32a8606fe add class username 2026-01-19 17:10:50 +08:00
4168d41a16 删除无用代码并且新增流程图相关内容 2025-10-11 23:29:56 +08:00
0f3f2d256f 实时修改设置 2025-10-11 13:30:54 +08:00
e8942b2645 fix 2025-10-04 12:11:13 +08:00
45d727a9e0 删掉旧的数据库迁移文件 2025-06-14 17:08:52 +08:00
b53d761f49 添加一言 2025-05-10 21:53:57 +08:00
1fd36ef617 fix 2025-04-14 14:29:05 +08:00
8ed6b319c5 班级抽签 2025-04-14 14:19:26 +08:00
9a90b82364 fix 2024-11-15 22:03:19 +08:00
593cd4b782 添加班级列表 2024-11-15 21:34:29 +08:00
yuetsh
c497d511dc refactor 2024-07-01 12:17:43 +08:00
yuetsh
5a8fb8d81a remove pytz 2024-06-11 15:07:48 +08:00
6cf7087339 update Django to v5 2024-06-05 17:40:45 +08:00
Beichi-CHs
af641dd421 fix useless escape symbol 2021-11-19 00:26:42 +08:00
Beichi-CHs
d4b3a42f94 fix flake8 standard problems 2021-11-18 12:56:16 +08:00
virusdefender
eab80024a8 修复 JudgeServer task_number 并发更新的问题 2019-04-03 12:07:59 +08:00
virusdefender
a52f383930 将编译选项修改为数据库存储 2019-01-05 14:12:17 +08:00
zema1
8ee1b514e3 Fixed problems in dispatcher, fixed testcase download error 2018-08-21 15:22:35 +08:00
virusdefender
fea77ce92b smtp账户不一定是邮箱 2018-05-17 01:22:05 +08:00
virusdefender
c9563506ef disable update json cache 2018-05-05 22:42:03 +08:00
virusdefender
3bb3becfcf alter to text field 2018-05-01 12:56:23 +08:00
virusdefender
443fc22699 fix exception class 2018-04-24 07:06:33 +08:00
virusdefender
1a84ecffad fix xx object has no attribute 'smtp_error' 2018-03-18 18:22:58 +08:00
virusdefender
0e83a920b2 fix ip header 2018-01-06 23:58:33 +08:00
zema1
b388c5dd03 add dashboard api 2018-01-04 19:43:18 +08:00
zema1
914c4727fc add new version api 2018-01-04 19:43:18 +08:00
virusdefender
8454b36792 fix permission 2018-01-04 19:39:24 +08:00
zema1
6faf824cd4 adjust test_case api 2017-12-27 20:12:38 +08:00
virusdefender
a5fea0c653 update xss filter 2017-12-24 15:34:22 +08:00
virusdefender
03cf356bab add judge server is_disabled field 2017-12-24 14:49:23 +08:00
virusdefender
290be9f8bc service url now is required 2017-12-24 12:08:56 +08:00
virusdefender
872e7407cf add smtp test function 2017-12-24 11:34:40 +08:00
zema1
2cca83aebf test_case prune api
fix tests
2017-12-23 22:11:37 +08:00
virusdefender
df50662b97 fix tests 2017-12-09 22:42:54 +08:00
virusdefender
7c819ae208 fix ip header 2017-12-06 11:10:57 +08:00
zema1
ee89df9ff2 去除不必要的serializer 2017-12-01 17:19:31 +08:00
zema1
5d03ec5aab add pick one api 2017-10-21 20:39:39 +08:00
zema1
d8bf33a12d fix tests 2017-10-21 10:51:35 +08:00
zema1
080ecf1bcf migrate to postgres json field 2017-10-11 21:43:29 +08:00
virusdefender
a324d55364 tiny work 2017-10-02 05:16:14 +08:00
virusdefender
9990cf647a 使用 SysOptions 2017-10-02 03:54:34 +08:00
zema1
2a91fd5e9f fix bugs due to problem id 2017-09-29 21:58:20 +08:00
zema1
e9c7344815 adjust account fields, cache the website_config 2017-09-22 16:41:29 +08:00
zemal
0e96b7c2a8 更换cache使用方式 2017-08-15 20:32:14 +08:00