Erste lauffähige Version
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
from django import forms
|
||||
|
||||
from .models import LetterTemplate, MailMergeJob
|
||||
|
||||
|
||||
class LetterTemplateForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = LetterTemplate
|
||||
fields = ["name", "description", "file"]
|
||||
widgets = {
|
||||
"description": forms.Textarea(attrs={"rows": 3}),
|
||||
}
|
||||
|
||||
def clean_file(self):
|
||||
f = self.cleaned_data["file"]
|
||||
if not f.name.lower().endswith(".docx"):
|
||||
raise forms.ValidationError("Nur .docx-Dateien sind erlaubt.")
|
||||
if f.size > 10 * 1024 * 1024:
|
||||
raise forms.ValidationError("Datei zu groß (max. 10 MB).")
|
||||
return f
|
||||
|
||||
|
||||
class MailMergeJobForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = MailMergeJob
|
||||
fields = ["template", "recipients_csv"]
|
||||
|
||||
def clean_recipients_csv(self):
|
||||
f = self.cleaned_data["recipients_csv"]
|
||||
if not f.name.lower().endswith(".csv"):
|
||||
raise forms.ValidationError("Nur .csv-Dateien sind erlaubt.")
|
||||
if f.size > 20 * 1024 * 1024:
|
||||
raise forms.ValidationError("Datei zu groß (max. 20 MB).")
|
||||
return f
|
||||
Reference in New Issue
Block a user