user messages work
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from django.contrib.staticfiles import finders
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
import os
|
||||
import time
|
||||
import gc
|
||||
@@ -112,17 +112,22 @@ def send_template_email(from_email, to_email, subject,
|
||||
else:
|
||||
emailbounced = False
|
||||
|
||||
try:
|
||||
usr = User.objects.get(email=to_email)
|
||||
umsg = UserMessage(
|
||||
receiver = usr.rower,
|
||||
datetime = timezone.now(),
|
||||
text = text_content,
|
||||
subject=subject,
|
||||
)
|
||||
umsg.save()
|
||||
except User.DoesNotExist:
|
||||
pass
|
||||
for recipient in to_email:
|
||||
try:
|
||||
soup = BeautifulSoup(html_content)
|
||||
|
||||
s2 = soup.body
|
||||
|
||||
usr = User.objects.get(email=recipient)
|
||||
umsg = UserMessage(
|
||||
receiver = usr.rower,
|
||||
datetime = timezone.now(),
|
||||
text = '{text}'.format(text=s2),
|
||||
subject=subject,
|
||||
)
|
||||
umsg.save()
|
||||
except User.DoesNotExist:
|
||||
pass
|
||||
|
||||
if not emailbounced:
|
||||
res = msg.send()
|
||||
|
||||
Reference in New Issue
Block a user