diff options
author | Mahesh Gudi | 2017-08-10 17:04:56 +0530 |
---|---|---|
committer | GitHub | 2017-08-10 17:04:56 +0530 |
commit | 021b3b64d70eb4b9bc4024fbfa5a2cb286d87043 (patch) | |
tree | e736661a95aef46008a4b4b6711c2f8db94c08ba | |
parent | f4c8daa3fd37f36f98466a75b37b30cf79389726 (diff) | |
parent | a6e7d96ca959fe8292c20877ddead0981687c49f (diff) | |
download | workshop_booking-021b3b64d70eb4b9bc4024fbfa5a2cb286d87043.tar.gz workshop_booking-021b3b64d70eb4b9bc4024fbfa5a2cb286d87043.tar.bz2 workshop_booking-021b3b64d70eb4b9bc4024fbfa5a2cb286d87043.zip |
Merge pull request #18 from Akshen/testing
Adds Workshop Reminder Mail
-rw-r--r-- | workshop_app/reminder_script.py | 85 | ||||
-rw-r--r-- | workshop_app/reminder_script.sh | 11 |
2 files changed, 96 insertions, 0 deletions
diff --git a/workshop_app/reminder_script.py b/workshop_app/reminder_script.py new file mode 100644 index 0000000..9b3f059 --- /dev/null +++ b/workshop_app/reminder_script.py @@ -0,0 +1,85 @@ +import django +import os +import sys +import datetime as dt +from textwrap import dedent +from django.core.mail import send_mail +from time import sleep + +#Setting Up Django Environment Using Existing settings +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "workshop_portal.settings") +base_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.append(base_path) +django.setup() +#Importing required email credentials +from workshop_portal.settings import ( + EMAIL_HOST, + EMAIL_PORT, + EMAIL_HOST_USER, + EMAIL_HOST_PASSWORD, + EMAIL_USE_TLS, + PRODUCTION_URL, + SENDER_EMAIL, + ADMIN_EMAIL + ) +from workshop_app.models import * +from datetime import datetime, date + + +def send_email(): + tomorrow = date.today() + dt.timedelta(days=2) + upcoming_requested_workshops = RequestedWorkshop.objects.filter( + requested_workshop_date=tomorrow, + status='ACCEPTED' + ) + + upcoming_proposed_workshops = ProposeWorkshopDate.objects.filter( + proposed_workshop_date=tomorrow, + status='ACCEPTED' + ) + for w in upcoming_proposed_workshops: + message = dedent("""\ + Dear {0}, + + This is to remind you that + you have a workshop on {1}, + for {2}. + + Create Course and Quiz for your workshop. + + Get in touch with your coordinator so that participants + can be instructed for enrollment. + + Thank You. + """.format(w.proposed_workshop_instructor.get_full_name(), + w.proposed_workshop_date, w.proposed_workshop_title)) + send_mail( + "Gentle Reminder about workshop on {0}" + .format(w.proposed_workshop_date),message, SENDER_EMAIL, + [w.proposed_workshop_instructor.email], fail_silently=False + ) + + for w in upcoming_requested_workshops: + message = dedent("""\ + Dear {0}, + + This is to remind you that + you have a workshop on {1}, + for {2}. + + Create Course and Quiz for your workshop. + + Get in touch with your coordinator so that participants + can be instructed for enrollment. + + Thank You. + """.format(w.requested_workshop_instructor.get_full_name(), + w.requested_workshop_date, w.requested_workshop_title)) + send_mail( + "Gentle Reminder about workshop on {0}" + .format(w.requested_workshop_date),message, SENDER_EMAIL, + [w.requested_workshop_instructor.email], fail_silently=False + ) + + +send_email()
\ No newline at end of file diff --git a/workshop_app/reminder_script.sh b/workshop_app/reminder_script.sh new file mode 100644 index 0000000..bba493f --- /dev/null +++ b/workshop_app/reminder_script.sh @@ -0,0 +1,11 @@ +path=$1 #command line argument to virtual environment + +DIR="$( cd "$( dirname "$0" )" && pwd )" +cd $DIR + +#Activate virtual environment +source $1bin/activate +#Run script to send reminder mails +python reminder_script.py +#Deactivate Virtual environment +deactivate
\ No newline at end of file |