Add blacklist to site
This commit is contained in:
parent
44e73ca790
commit
be3be2ac74
1
.blacklist
Normal file
1
.blacklist
Normal file
@ -0,0 +1 @@
|
|||||||
|
mchretien@forum.dk
|
||||||
@ -8,15 +8,24 @@ from templated_email import send_templated_mail
|
|||||||
logger = get_task_logger(__name__)
|
logger = get_task_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
COTACT_FORM_TEMPLATE = 'storefront/contact_form'
|
CONTACT_FORM_TEMPLATE = 'storefront/contact_form'
|
||||||
|
|
||||||
|
|
||||||
@shared_task(name='contact_form_email')
|
@shared_task(name='contact_form_email')
|
||||||
def contact_form_email(formdata):
|
def contact_form_email(formdata):
|
||||||
send_templated_mail(
|
with open(f'{settings.BASE_DIR.parent}/.blacklist') as blacklist:
|
||||||
template_name=COTACT_FORM_TEMPLATE,
|
if formdata.get('email_address') not in blacklist.read():
|
||||||
from_email=settings.DEFAULT_FROM_EMAIL,
|
send_templated_mail(
|
||||||
recipient_list=[settings.DEFAULT_CONTACT_EMAIL],
|
template_name=CONTACT_FORM_TEMPLATE,
|
||||||
context=formdata
|
from_email=settings.DEFAULT_FROM_EMAIL,
|
||||||
)
|
recipient_list=[settings.DEFAULT_CONTACT_EMAIL],
|
||||||
|
context=formdata
|
||||||
|
)
|
||||||
|
|
||||||
logger.info(f"Contact form email sent from {formdata['email_address']}")
|
logger.info(
|
||||||
|
f"Contact form email sent from {formdata['email_address']}"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.warn(
|
||||||
|
f"{formdata['email_address']} tried to send an email but was on the blacklist"
|
||||||
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user