File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -3214,6 +3214,7 @@ def validate_report_has_been_processed(self, field):
32143214class TemplateEmailFilesUploadForm (StripWhitespaceForm ):
32153215 def __init__ (self , * args , template , ** kwargs ):
32163216 self .existing_file_names = InsensitiveSet (file .filename for file in template .existing_files )
3217+ self .placeholders_in_subject = InsensitiveSet (UtilsField (template .subject ).placeholders )
32173218 super ().__init__ (* args , ** kwargs )
32183219
32193220 allowed_file_formats = {
@@ -3253,6 +3254,12 @@ def validate_file(self, field):
32533254 if field .data .filename in self .existing_file_names :
32543255 raise ValidationError (f"Your template already has a file called ‘{ field .data .filename } ’" )
32553256
3257+ if field .data .filename in self .placeholders_in_subject :
3258+ raise ValidationError (
3259+ f"You cannot put a file in the subject of a template "
3260+ "– remove ((field.data.filename)) or rename your file"
3261+ )
3262+
32563263
32573264class TemplateEmailFileLinkTextForm (StripWhitespaceForm ):
32583265 link_text = GovukTextInputField ("Link text (optional)" )
You can’t perform that action at this time.
0 commit comments