summaryrefslogtreecommitdiff
path: root/workshop_app
diff options
context:
space:
mode:
Diffstat (limited to 'workshop_app')
-rw-r--r--workshop_app/send_mails.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/workshop_app/send_mails.py b/workshop_app/send_mails.py
index a704ee1..d4a11b7 100644
--- a/workshop_app/send_mails.py
+++ b/workshop_app/send_mails.py
@@ -3,6 +3,8 @@ __author__ = "Akshen Doke"
import hashlib
import logging
import logging.config
+import os
+
import yaml
import re
from django.core.mail import send_mail
@@ -225,7 +227,10 @@ def send_email( request, call_on,
format(workshop_date)
msg = EmailMultiAlternatives(subject, message, SENDER_EMAIL, [request.user.email])
attachment_paths = path.join(settings.MEDIA_ROOT, workshop_title.replace(" ","_"))
- files = listdir(attachment_paths)
+ if os.path.exists(attachment_paths):
+ files = listdir(attachment_paths)
+ else:
+ files = []
for f in files:
attachment = open(path.join(attachment_paths, f), 'rb')
part = MIMEBase('application', 'octet-stream')
@@ -257,7 +262,10 @@ def send_email( request, call_on,
format(workshop_date)
msg = EmailMultiAlternatives(subject, message, SENDER_EMAIL, [other_email])
attachment_paths = path.join(settings.MEDIA_ROOT, workshop_title.replace(" ","_"))
- files = listdir(attachment_paths)
+ if os.path.exists(attachment_paths):
+ files = listdir(attachment_paths)
+ else:
+ files = []
for f in files:
attachment = open(path.join(attachment_paths, f), 'rb')
part = MIMEBase('application', 'octet-stream')
@@ -392,7 +400,7 @@ def send_email( request, call_on,
workshop_date, new_workshop_date))
logging.info("Workshop Date Changed Done by {0} from {1} to {2}"
- .format(request.user.email,
+ .format(request.user.email,
new_workshop_date, workshop_date))
try:
send_mail(
@@ -419,7 +427,7 @@ def send_email( request, call_on,
try:
send_mail(
- "FOSSEE Python Workshop Date Changed",
+ "FOSSEE Python Workshop Date Changed",
message, SENDER_EMAIL,
[other_email], fail_silently=True
)