更新 .gitignore 并刷新缓存
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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
|
||||
Binary file not shown.
18
core/migrations/0004_systemconfig_sender_email.py
Normal file
18
core/migrations/0004_systemconfig_sender_email.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.1.4 on 2026-01-18 10:50
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0003_readingrecord_note'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='systemconfig',
|
||||
name='sender_email',
|
||||
field=models.EmailField(blank=True, max_length=254, null=True, verbose_name='发件人邮箱'),
|
||||
),
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,3 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
Reference in New Issue
Block a user