Merge pull request #4177 from MaximilianKrambach/email

add a validation error for false template invitation email properties (server)
This commit is contained in:
Finn Stutzenstein 2019-01-25 20:08:36 +01:00 committed by GitHub
commit 2c7e181f38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -232,10 +232,20 @@ class User(RESTModelMixin, PermissionsMixin, AbstractBaseUser):
"password": self.default_password, "password": self.default_password,
} }
) )
try:
message = message.format(**message_format) message = message.format(**message_format)
except KeyError as err:
raise ValidationError(
{"detail": f"Invalid property {err}."}
)
subject_format = format_dict({"event_name": config["general_event_name"]}) subject_format = format_dict({"event_name": config["general_event_name"]})
try:
subject = subject.format(**subject_format) subject = subject.format(**subject_format)
except KeyError as err:
raise ValidationError(
{"detail": f"Invalid property {err}."}
)
# Create an email and send it. # Create an email and send it.
email = mail.EmailMessage( email = mail.EmailMessage(