You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.8 KiB
58 lines
1.8 KiB
from django.template.loader import get_template
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
|
class RequestNotifiable(object):
|
|
MAIL_CATEGORY = 'Request'
|
|
|
|
SLUG_NOTIFICATION = 'notification'
|
|
SLUG_RESPONSE = 'response'
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(RequestNotifiable, self).__init__(*args, **kwargs)
|
|
|
|
def get_mail_template(self, **kwargs):
|
|
return None
|
|
# return MailTemplate.objects.filter(**kwargs).first()
|
|
|
|
def send_request_notification(self, context):
|
|
"""
|
|
:param context
|
|
:param template_path string:
|
|
:return None:
|
|
"""
|
|
notification = self.get_mail_template(
|
|
slug=self.SLUG_NOTIFICATION,
|
|
)
|
|
|
|
kwargs = {
|
|
'subject': _('New contact us request'),
|
|
'message': get_template('contact_us/contact_email_notification.html').template.source,
|
|
}
|
|
if not notification:
|
|
kwargs.update({
|
|
'name': 'Admin notification',
|
|
'slug': self.SLUG_NOTIFICATION,
|
|
'num_of_retries': 3,
|
|
'is_html': True
|
|
})
|
|
# MailTemplate.objects.create(**kwargs)
|
|
else:
|
|
notification.subject = kwargs.get('subject')
|
|
notification.message = kwargs.get('message')
|
|
notification.save()
|
|
|
|
# send_db_mail(
|
|
# self.SLUG_NOTIFICATION,
|
|
# context.get('recipients'),
|
|
# context.get('subject'),
|
|
# context.get('context'),
|
|
# from_email=context.get('from_email', tuple()),
|
|
# bcc=context.get('bcc', tuple()),
|
|
# files=context.get('files', tuple()),
|
|
# send_at_date=context.get('send_at_date'),
|
|
# retry=True,
|
|
# retry_delay=300,
|
|
# max_retries=3,
|
|
# use_celery=celery_supported()
|
|
# )
|
|
|