feat(公开内容): 添加临时留言功能,留言保留10分钟,显示用户名、内容、时间和来源IP
This commit is contained in:
@@ -9,7 +9,8 @@ from .models import (
|
||||
TodayPlan,
|
||||
SystemConfig,
|
||||
FamilyMember,
|
||||
PublicContent
|
||||
PublicContent,
|
||||
TempMessage
|
||||
)
|
||||
|
||||
class ReadingRecordForm(forms.ModelForm):
|
||||
@@ -142,4 +143,21 @@ class TempUploadForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = PublicContent
|
||||
fields = ['title', 'file']
|
||||
fields = ['title', 'file']
|
||||
|
||||
|
||||
class TempMessageForm(forms.ModelForm):
|
||||
"""临时留言表单"""
|
||||
class Meta:
|
||||
model = TempMessage
|
||||
fields = ['username', 'content']
|
||||
widgets = {
|
||||
'username': forms.TextInput(attrs={'class': 'form-control', 'maxlength': '20', 'placeholder': '用户名(可选,最多20字节)'}),
|
||||
'content': forms.Textarea(attrs={'class': 'form-control', 'rows': 3, 'maxlength': '1000', 'placeholder': '说点什么...(最多1000字节)'}),
|
||||
}
|
||||
|
||||
def clean_content(self):
|
||||
content = self.cleaned_data.get('content', '')
|
||||
if len(content.encode('utf-8')) > 1000:
|
||||
raise forms.ValidationError("内容不能超过1000字节")
|
||||
return content
|
||||
Reference in New Issue
Block a user