diff options
Diffstat (limited to 'workshop_app/send_mails.py')
-rw-r--r-- | workshop_app/send_mails.py | 99 |
1 files changed, 72 insertions, 27 deletions
diff --git a/workshop_app/send_mails.py b/workshop_app/send_mails.py index a4bbc0b..6566041 100644 --- a/workshop_app/send_mails.py +++ b/workshop_app/send_mails.py @@ -1,4 +1,7 @@ +__author__ = "Akshen Doke" + from django.core.mail import send_mail +from textwrap import dedent from workshop_portal.settings import ( EMAIL_HOST, EMAIL_PORT, @@ -10,7 +13,7 @@ from workshop_portal.settings import ( def send_email(request, call_on, user_position=None, workshop_date=None, workshop_title=None, user_name=None, - other_email=None + other_email=None, phone_number=None ): ''' Email sending function while registration and @@ -19,21 +22,32 @@ def send_email(request, call_on, if call_on == "Registration": if user_position == "instructor": - message = "Thank You for Registering on this platform. \n \ - Since you have ask for Instructor Profile, \n \ - we will get back to you soon after verifying your \n \ - profile. \ - In case if you don\t get any response within 3days, \ - Please contact us at " + message = dedent("""\ + Thank You for Registering on this platform. + Since you have ask for Instructor Profile, + we will get back to you soon after verifying your + profile. + In case if you don\t get any response within 3days, + Please contact us at workshops@fossee.in""") send_mail( "Welcome to FOSSEE", message, EMAIL_HOST_USER, [request.user.email], fail_silently=False ) + #Send a mail to admin as well as a notification. + message = dedent("""\ + There is a Request for instructor profile on Workshop + Booking Website from {0} Please get check the profile + and get back to the user within 2days. + """.format(request.user)) + send_mail("Instructor Request", message, EMAIL_HOST_USER, + ['workshops@fossee.in'], fail_silently=False) + else: - message = "Thank You for Registering on this platform.\n \ - Rules. \n \ If you face any issue during \ - your session please contact fossee." + message = dedent("""\ + Thank You for Registering on this platform. + If you face any issue during your session please + contact us a workshops@fossee.in""") send_mail( "Welcome to FOSSEE", message, EMAIL_HOST_USER, [request.user.email], fail_silently=False @@ -41,17 +55,31 @@ def send_email(request, call_on, elif call_on == "Booking": if user_position == "instructor": - message = "You got a workshop booking request from "+user_name+" for "+workshop_title+" on "+workshop_date+" please respond." + message = dedent("""\ + You got a workshop booking request from user:{0}, email:{1}, + phone_number:{2} for workshop_title:{3} on date:{4} + please respond at the earliest""".format( + user_name, request.user.email, + request.user.profile.phone_number, + workshop_title, workshop_date + ) + ) send_mail( "Python Workshop Booking | FOSSEE", message, EMAIL_HOST_USER, [other_email], fail_silently=False ) - else: - message = "Thank You for Booking on this platform.\ - Here are your workshop details " +workshop_title+ "\ - If you face any issue during your session please contact \ - fossee." + message = dedent("""\ + Thank You for Booking on this platform. + Here are your workshop details workshop_title:{0} + workshop_date:{1}, instructor_email:{2}, + instructor phone_number:{3} + If you face any issue during your session please contact + respective instructor or fossee at workshops@fossee.in""".format( + workshop_title, workshop_date, + other_email, phone_number + ) + ) send_mail( "Python Workshop Booking | FOSSEE", message, EMAIL_HOST_USER, [request.user.email], fail_silently=False @@ -59,31 +87,48 @@ def send_email(request, call_on, elif call_on == "Booking Confirmed": if user_position == "instructor": - message = "You have confirmed the booking" + message = dedent("""\ + You have confirmed the booking on workshop_date:{0} for + workshop_title:{1} by coordinator:{2} coordinator_email:{3}, + coordinator_phone_number:{4}""" + .format(workshop_date, workshop_title, user_name, other_email, + phone_number)) send_mail("Python Workshop Booking Confirmation", message, EMAIL_HOST_USER, [request.user.email], fail_silently=False) else: - message = "Your workshop for "+workshop_date+"request has been confirmed" + message = dedent("""\ + Your workshop on {0} for {1} has been confirmed by the + instructor please get in touch with the + instructor {2} - {3} for further assistance""".format( + workshop_date, workshop_title, + request.user.email, phone_number)) send_mail("Python Workshop Booking Confirmation", message, EMAIL_HOST_USER, [other_email], fail_silently=False) elif call_on == "Booking Request Rejected": if user_position == "instructor": - message = "You have reject the booking on "+workshop_date+" for "+workshop_title - send_mail("Python Workshop Booking Rejected", message, EMAIL_HOST_USER, - [request.user.email], fail_silently=False) + message = dedent("""\ + You have reject the booking on {0} for {1} by {2}""" + .format(workshop_date, workshop_title, user_name)) + send_mail("Python Workshop Booking Rejected", message, + EMAIL_HOST_USER, [request.user.email], fail_silently=False) else: - message = "Your workshop request for "+workshop_date+" has been rejected by the instructor,\ - please try for some other day." - send_mail("Python Workshop Booking Request Rejected", message, EMAIL_HOST_USER, - [other_email], fail_silently=False) + message = dedent("""\ + Your workshop request on {0} + has been rejected by the instructor, + please try for some other day.""".format(workshop_date)) + send_mail("Python Workshop Booking Request Rejected", message, + EMAIL_HOST_USER, [other_email], fail_silently=False) elif call_on =='Workshop Deleted': - message = "You have deleted a Workshop, scheduled on "+workshop_date+"." + message = dedent("""\ + You have deleted a Workshop, scheduled on {0}, + workshop title: {1}""" + .format(workshop_date, workshop_title)) send_mail("Python Workshop Deleted", message, EMAIL_HOST_USER, [request.user.email], fail_silently=False) else: message = "Issue at Workshop Booking App please check" - send_mail("Issue At Workshop Booking App", message, EMAIL_HOST_USER, + send_mail("Issue At Workshop Booking App Mailing", message, EMAIL_HOST_USER, [doke.akshen@gmail.com, mahesh.p.gudi@gmail.com, aditya94palaparthy@gmail.com], fail_silently=False) |