更新 .gitignore 并刷新缓存
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import re
|
||||
from django import forms
|
||||
from django.utils import timezone
|
||||
from .models import (
|
||||
@@ -60,6 +61,7 @@ class TodayPlanForm(forms.ModelForm):
|
||||
|
||||
class SystemConfigForm(forms.ModelForm):
|
||||
"""系统配置表单"""
|
||||
|
||||
class Meta:
|
||||
model = SystemConfig
|
||||
fields = ['smtp_server', 'smtp_port', 'smtp_username', 'smtp_password', 'sender_email', 'send_time', 'recipient_email']
|
||||
@@ -71,4 +73,22 @@ class SystemConfigForm(forms.ModelForm):
|
||||
'sender_email': forms.EmailInput(attrs={'class': 'form-control', 'placeholder': '请输入发件人邮箱'}),
|
||||
'send_time': forms.TimeInput(attrs={'type': 'time', 'class': 'form-control'}),
|
||||
'recipient_email': forms.EmailInput(attrs={'class': 'form-control', 'placeholder': '请输入收件人邮箱'}),
|
||||
}
|
||||
}
|
||||
|
||||
def clean_sender_email(self):
|
||||
sender_email = self.cleaned_data.get('sender_email')
|
||||
if sender_email:
|
||||
email_pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
|
||||
if not re.match(email_pattern, sender_email):
|
||||
logger.warning(f"发件人邮箱格式不正确: {sender_email}")
|
||||
raise forms.ValidationError("请输入有效的邮箱地址,格式如:example@domain.com")
|
||||
return sender_email
|
||||
|
||||
def clean_recipient_email(self):
|
||||
recipient_email = self.cleaned_data.get('recipient_email')
|
||||
if recipient_email:
|
||||
email_pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
|
||||
if not re.match(email_pattern, recipient_email):
|
||||
logger.warning(f"收件人邮箱格式不正确: {recipient_email}")
|
||||
raise forms.ValidationError("请输入有效的邮箱地址,格式如:example@domain.com")
|
||||
return recipient_email
|
||||
Reference in New Issue
Block a user