Skip to content

Commit 9f5f20b

Browse files
committed
fix: 1052009
--bug=1052009 --user=王孝刚 [国际化]修改密码的验证码通知邮件未国际化 https://www.tapd.cn/57709429/s/1651094
1 parent 4ddc491 commit 9f5f20b

File tree

7 files changed

+254
-8
lines changed

7 files changed

+254
-8
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<!DOCTYPE html>
2+
<html xmlns:th="http://www.thymeleaf.org">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="description" content="email code" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
</head>
9+
<!--邮箱验证码模板-->
10+
<body>
11+
<div style="background-color: #ececec; padding: 35px">
12+
<table
13+
cellpadding="0"
14+
style="
15+
width: 800px;
16+
height: 100%;
17+
margin: 0px auto;
18+
text-align: left;
19+
position: relative;
20+
border-top-left-radius: 5px;
21+
border-top-right-radius: 5px;
22+
border-bottom-right-radius: 5px;
23+
border-bottom-left-radius: 5px;
24+
font-size: 14px;
25+
line-height: 1.5;
26+
box-shadow: rgb(153, 153, 153) 0px 0px 5px;
27+
border-collapse: collapse;
28+
background-position: initial initial;
29+
background-repeat: initial initial;
30+
background: #fff;
31+
"
32+
>
33+
<tbody>
34+
<tr>
35+
<th
36+
valign="middle"
37+
style="
38+
background: linear-gradient(
39+
90deg,
40+
#ebf1ff 24.34%,
41+
#e5fbf8 56.18%,
42+
#f2ebfe 90.18%
43+
);
44+
height: 25px;
45+
line-height: 25px;
46+
padding: 15px 35px;
47+
border-bottom-width: 1px;
48+
border-bottom-color: rgba(51, 112, 255);
49+
border-top-left-radius: 5px;
50+
border-top-right-radius: 5px;
51+
border-bottom-right-radius: 0px;
52+
border-bottom-left-radius: 0px;
53+
"
54+
>
55+
<div
56+
style="
57+
width: 230px;
58+
background: linear-gradient(180deg, #3370FF 0%, #7f3bf5 100%);
59+
-webkit-background-clip: text;
60+
font-size: 24px;
61+
-webkit-text-fill-color: transparent;
62+
font-style: normal;
63+
font-weight: 900;
64+
color: #1f2329;
65+
"
66+
>
67+
Intelligent Knowledge Q&A System
68+
</div>
69+
</th>
70+
</tr>
71+
<tr>
72+
<td style="word-break: break-all">
73+
<div
74+
style="
75+
padding: 25px 35px 40px;
76+
background-color: #fff;
77+
opacity: 0.8;
78+
"
79+
>
80+
<h2 style="margin: 5px 0px">
81+
<font color="#333333" style="line-height: 20px">
82+
<font style="line-height: 22px" size="4">
83+
84+
Dear user:</font
85+
>
86+
</font>
87+
</h2>
88+
<!-- 中文 -->
89+
<p>
90+
<font color="#ff8c00" style="font-weight: 900">${code}</font
91+
>&nbsp;&nbsp;This is your dynamic verification code. Please fill it in within 30 minutes. To protect the security of your account, please do not provide this verification code to anyone.
92+
</p>
93+
<br />
94+
95+
<div style="width: 100%; margin: 0 auto">
96+
<div
97+
style="
98+
padding: 10px 10px 0;
99+
border-top: 1px solid #ccc;
100+
color: #747474;
101+
margin-bottom: 20px;
102+
line-height: 1.3em;
103+
font-size: 12px;
104+
text-align: right;
105+
"
106+
>
107+
<p>Intelligent knowledge base project team</p>
108+
<br />
109+
<p>
110+
Please do not reply to this system email<br />
111+
</p>
112+
<!--<p>©***</p>-->
113+
</div>
114+
</div>
115+
</div>
116+
</td>
117+
</tr>
118+
</tbody>
119+
</table>
120+
</div>
121+
</body>
122+
</html>

apps/common/template/email_template.html renamed to apps/common/template/email_template_zh.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ <h2 style="margin: 5px 0px">
107107
<br />
108108
<p>
109109
此为系统邮件,请勿回复<br />
110-
Please do not reply to this system email
111110
</p>
112111
<!--<p>©***</p>-->
113112
</div>
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<!DOCTYPE html>
2+
<html xmlns:th="http://www.thymeleaf.org">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="description" content="email code" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
</head>
9+
<!--邮箱验证码模板-->
10+
<body>
11+
<div style="background-color: #ececec; padding: 35px">
12+
<table
13+
cellpadding="0"
14+
style="
15+
width: 800px;
16+
height: 100%;
17+
margin: 0px auto;
18+
text-align: left;
19+
position: relative;
20+
border-top-left-radius: 5px;
21+
border-top-right-radius: 5px;
22+
border-bottom-right-radius: 5px;
23+
border-bottom-left-radius: 5px;
24+
font-size: 14px;
25+
line-height: 1.5;
26+
box-shadow: rgb(153, 153, 153) 0px 0px 5px;
27+
border-collapse: collapse;
28+
background-position: initial initial;
29+
background-repeat: initial initial;
30+
background: #fff;
31+
"
32+
>
33+
<tbody>
34+
<tr>
35+
<th
36+
valign="middle"
37+
style="
38+
background: linear-gradient(
39+
90deg,
40+
#ebf1ff 24.34%,
41+
#e5fbf8 56.18%,
42+
#f2ebfe 90.18%
43+
);
44+
height: 25px;
45+
line-height: 25px;
46+
padding: 15px 35px;
47+
border-bottom-width: 1px;
48+
border-bottom-color: rgba(51, 112, 255);
49+
border-top-left-radius: 5px;
50+
border-top-right-radius: 5px;
51+
border-bottom-right-radius: 0px;
52+
border-bottom-left-radius: 0px;
53+
"
54+
>
55+
<div
56+
style="
57+
width: 230px;
58+
background: linear-gradient(180deg, #3370FF 0%, #7f3bf5 100%);
59+
-webkit-background-clip: text;
60+
font-size: 24px;
61+
-webkit-text-fill-color: transparent;
62+
font-style: normal;
63+
font-weight: 900;
64+
color: #1f2329;
65+
"
66+
>
67+
68+
智慧知識庫問答系統
69+
</div>
70+
</th>
71+
</tr>
72+
<tr>
73+
<td style="word-break: break-all">
74+
<div
75+
style="
76+
padding: 25px 35px 40px;
77+
background-color: #fff;
78+
opacity: 0.8;
79+
"
80+
>
81+
<h2 style="margin: 5px 0px">
82+
<font color="#333333" style="line-height: 20px">
83+
<font style="line-height: 22px" size="4">
84+
85+
尊敬的用戶:</font
86+
>
87+
</font>
88+
</h2>
89+
<!-- 中文 -->
90+
<p>
91+
<font color="#ff8c00" style="font-weight: 900">${code}</font
92+
>&nbsp;&nbsp;為您的動態驗證碼,請於30分鐘內填寫,為保障帳戶安全,請勿向任何人提供此驗證碼。
93+
</p>
94+
<br />
95+
96+
<div style="width: 100%; margin: 0 auto">
97+
<div
98+
style="
99+
padding: 10px 10px 0;
100+
border-top: 1px solid #ccc;
101+
color: #747474;
102+
margin-bottom: 20px;
103+
line-height: 1.3em;
104+
font-size: 12px;
105+
text-align: right;
106+
"
107+
>
108+
<p>智慧知識庫專案組</p>
109+
<br />
110+
<p>
111+
此為系統郵件,請勿回覆<br />
112+
</p>
113+
<!--<p>©***</p>-->
114+
</div>
115+
</div>
116+
</div>
117+
</td>
118+
</tr>
119+
</tbody>
120+
</table>
121+
</div>
122+
</body>
123+
</html>

apps/dataset/serializers/document_serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def export(self, with_valid=True):
249249
return HttpResponse(content, status=200, headers={'Content-Type': 'text/cxv',
250250
'Content-Disposition': 'attachment; filename="csv_template.csv"'})
251251
elif self.data.get('type') == 'excel':
252-
file = open(os.path.join(PROJECT_DIR, "apps", "dataset", 'template', f'csv_template_{to_locale(language)}.xlsx'), "rb")
252+
file = open(os.path.join(PROJECT_DIR, "apps", "dataset", 'template', f'excel_template_{to_locale(language)}.xlsx'), "rb")
253253
content = file.read()
254254
file.close()
255255
return HttpResponse(content, status=200, headers={'Content-Type': 'application/vnd.ms-excel',

apps/locales/en_US/LC_MESSAGES/django.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4981,7 +4981,7 @@ msgstr ""
49814981

49824982
#: .\apps\setting\models_provider\impl\volcanic_engine_model_provider\volcanic_engine_model_provider.py:115
49834983
msgid "volcano engine"
4984-
msgstr "Volcano Engine"
4984+
msgstr "Volcengine"
49854985

49864986
#: .\apps\setting\models_provider\impl\wenxin_model_provider\credential\llm.py:50
49874987
#, python-brace-format

apps/locales/zh_CN/LC_MESSAGES/django.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3698,7 +3698,7 @@ msgstr "语音合成"
36983698

36993699
#: .\apps\setting\models_provider\base_model_provider.py:156
37003700
msgid "Vision Model"
3701-
msgstr "图片理解"
3701+
msgstr "视觉模型"
37023702

37033703
#: .\apps\setting\models_provider\base_model_provider.py:157
37043704
msgid "Image Generation"

apps/users/serializers/user_serializers.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
from setting.models import Team, SystemSetting, SettingType, Model, TeamMember, TeamMemberPermission
4040
from smartdoc.conf import PROJECT_DIR
4141
from users.models.user import User, password_encrypt, get_user_dynamics_permission
42-
from django.utils.translation import gettext_lazy as _
43-
42+
from django.utils.translation import gettext_lazy as _, gettext, to_locale
43+
from django.utils.translation import get_language
4444
user_cache = cache.caches['user_cache']
4545

4646

@@ -393,8 +393,10 @@ def send(self):
393393
code = "".join(list(map(lambda i: random.choice(['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
394394
]), range(6))))
395395
# 获取邮件模板
396-
file = open(os.path.join(PROJECT_DIR, "apps", "common", 'template', 'email_template.html'), "r",
397-
encoding='utf-8')
396+
language = get_language()
397+
file = open(
398+
os.path.join(PROJECT_DIR, "apps", "common", 'template', f'email_template{to_locale(language)}.html'), "r",
399+
encoding='utf-8')
398400
content = file.read()
399401
file.close()
400402
code_cache_key = email + ":" + state

0 commit comments

Comments
 (0)