summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshen2017-08-10 16:53:51 +0530
committerAkshen2017-08-10 16:55:15 +0530
commita6e7d96ca959fe8292c20877ddead0981687c49f (patch)
treee736661a95aef46008a4b4b6711c2f8db94c08ba
parentcc29473b5330976ed11b86094ce65e297e08063a (diff)
downloadworkshop_booking-a6e7d96ca959fe8292c20877ddead0981687c49f.tar.gz
workshop_booking-a6e7d96ca959fe8292c20877ddead0981687c49f.tar.bz2
workshop_booking-a6e7d96ca959fe8292c20877ddead0981687c49f.zip
Updates Reminder Script
-rw-r--r--workshop_app/reminder_script.py4
-rw-r--r--workshop_app/reminder_script.sh2
-rw-r--r--workshop_app/script.py92
-rw-r--r--workshop_app/script.sh5
4 files changed, 2 insertions, 101 deletions
diff --git a/workshop_app/reminder_script.py b/workshop_app/reminder_script.py
index 71ff671..9b3f059 100644
--- a/workshop_app/reminder_script.py
+++ b/workshop_app/reminder_script.py
@@ -27,7 +27,7 @@ from datetime import datetime, date
def send_email():
- tomorrow = date.today() + dt.timedelta(days=5)
+ tomorrow = date.today() + dt.timedelta(days=2)
upcoming_requested_workshops = RequestedWorkshop.objects.filter(
requested_workshop_date=tomorrow,
status='ACCEPTED'
@@ -38,7 +38,6 @@ def send_email():
status='ACCEPTED'
)
for w in upcoming_proposed_workshops:
- sleep(1)
message = dedent("""\
Dear {0},
@@ -61,7 +60,6 @@ def send_email():
)
for w in upcoming_requested_workshops:
- sleep(1)
message = dedent("""\
Dear {0},
diff --git a/workshop_app/reminder_script.sh b/workshop_app/reminder_script.sh
index ee656fd..bba493f 100644
--- a/workshop_app/reminder_script.sh
+++ b/workshop_app/reminder_script.sh
@@ -1,4 +1,4 @@
-path=$1 #command line argument
+path=$1 #command line argument to virtual environment
DIR="$( cd "$( dirname "$0" )" && pwd )"
cd $DIR
diff --git a/workshop_app/script.py b/workshop_app/script.py
deleted file mode 100644
index 0d9179e..0000000
--- a/workshop_app/script.py
+++ /dev/null
@@ -1,92 +0,0 @@
-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
-class ReminderEmail():
- """docstring for ReminderEmail"""
-
- def fetch(self):
- self.tomorrow = date.today() + dt.timedelta(days=3)
- self.upcoming_requested_workshops = RequestedWorkshop.objects.filter(
- requested_workshop_date=self.tomorrow,
- status='ACCEPTED'
- )
-
- self.upcoming_proposed_workshops = ProposeWorkshopDate.objects.filter(
- proposed_workshop_date=self.tomorrow,
- status='ACCEPTED'
- )
-
- def send_email(self):
- for w in self.upcoming_proposed_workshops:
- sleep(1)
- 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 self.upcoming_requested_workshops:
- sleep(1)
- 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
- )
-
-if __name__ == '__main__':
- reminderObj = ReminderEmail()
- reminderObj.fetch()
- reminderObj.send_email() \ No newline at end of file
diff --git a/workshop_app/script.sh b/workshop_app/script.sh
deleted file mode 100644
index cf9a544..0000000
--- a/workshop_app/script.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-DIR="$( cd "$( dirname "$0" )" && pwd )"
-cd $DIR
-source ../../workshop_env/bin/activate
-python script.py
-deactivate \ No newline at end of file