summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--static/recurrence/js/recurrence-widget.js2
-rwxr-xr-xworkshop_app/data/instructions-for-coordinators.pdfbin0 -> 36506 bytes
-rwxr-xr-xworkshop_app/data/instructions-for-participants.pdfbin0 -> 51627 bytes
-rwxr-xr-xworkshop_app/data/schedule.pdfbin0 -> 32900 bytes
-rw-r--r--workshop_app/forms.py2
-rw-r--r--workshop_app/send_mails.py323
-rw-r--r--workshop_app/views.py19
-rw-r--r--workshop_portal/settings.py7
8 files changed, 270 insertions, 83 deletions
diff --git a/static/recurrence/js/recurrence-widget.js b/static/recurrence/js/recurrence-widget.js
index caceae6..817add8 100644
--- a/static/recurrence/js/recurrence-widget.js
+++ b/static/recurrence/js/recurrence-widget.js
@@ -782,7 +782,7 @@ recurrence.widget.RuleForm.prototype = {
'span', {'class': 'recurrence-label'},
recurrence.display.labels.every);
var interval_label2 = recurrence.widget.e(
- 'span', {'class': 'laebl'},
+ 'span', {'class': 'label'},
recurrence.display.timeintervals_plural[this.rule.freq]);
var interval_container = recurrence.widget.e(
'div', {'class': 'interval'},
diff --git a/workshop_app/data/instructions-for-coordinators.pdf b/workshop_app/data/instructions-for-coordinators.pdf
new file mode 100755
index 0000000..7601616
--- /dev/null
+++ b/workshop_app/data/instructions-for-coordinators.pdf
Binary files differ
diff --git a/workshop_app/data/instructions-for-participants.pdf b/workshop_app/data/instructions-for-participants.pdf
new file mode 100755
index 0000000..93a3e5d
--- /dev/null
+++ b/workshop_app/data/instructions-for-participants.pdf
Binary files differ
diff --git a/workshop_app/data/schedule.pdf b/workshop_app/data/schedule.pdf
new file mode 100755
index 0000000..203f5e0
--- /dev/null
+++ b/workshop_app/data/schedule.pdf
Binary files differ
diff --git a/workshop_app/forms.py b/workshop_app/forms.py
index 158e9fa..86336f0 100644
--- a/workshop_app/forms.py
+++ b/workshop_app/forms.py
@@ -46,7 +46,7 @@ class UserRegistrationForm(forms.Form):
position = forms.ChoiceField(help_text='Instructors, please wait \
for our admin approval, if your instructor \
account is not activated in 7 days, please\
- mail us at python[at]fossee[dot]in',
+ mail us at workshops[at]fossee[dot]in',
choices=position_choices
)
diff --git a/workshop_app/send_mails.py b/workshop_app/send_mails.py
index 6566041..add55a6 100644
--- a/workshop_app/send_mails.py
+++ b/workshop_app/send_mails.py
@@ -10,11 +10,60 @@ from workshop_portal.settings import (
EMAIL_USE_TLS
)
-def send_email(request, call_on,
+
+def send_smtp_email(request=None, subject=None, message=None,
user_position=None, workshop_date=None,
workshop_title=None, user_name=None,
- other_email=None, phone_number=None
- ):
+ other_email=None, phone_number=None,
+ institute=None, attachment=None):
+ '''
+ Send email using SMTPLIB
+ '''
+
+ from smtplib import SMTP
+ from email.mime.multipart import MIMEMultipart
+ from email.mime.text import MIMEText
+ from email.mime.base import MIMEBase
+ from email import encoders
+
+ msg = MIMEMultipart()
+ msg['From'] = EMAIL_HOST_USER
+ msg['To'] = other_email
+ msg['Subject'] = subject
+ body = message
+ msg.attach(MIMEText(body, 'plain'))
+
+ if attachment:
+ from django.conf import settings
+ from os import listdir
+ files = listdir(settings.MEDIA_ROOT)
+
+ for f in files:
+ attachment = open(f, 'rb')
+ part = MIMEBase('application', 'octet-stream')
+ part.set_payload((attachment).read())
+ encoders.encode_base64(part)
+ part.add_header('Content-Disposition', "attachment; filename= %s " % f)
+ msg.attach(part)
+
+
+ server = SMTP(EMAIL_HOST, EMAIL_PORT)
+ server.ehlo()
+ server.starttls()
+ server.ehlo()
+ server.esmtp_features['auth']='LOGIN DIGEST-MD5 PLAIN'
+ server.login(EMAIL_HOST_USER, EMAIL_HOST_PASSWORD)
+ text = msg.as_string()
+ server.sendmail(EMAIL_HOST_USER, other_email, text)
+ server.close()
+
+
+def send_email( request, call_on,
+ user_position=None, workshop_date=None,
+ workshop_title=None, user_name=None,
+ other_email=None, phone_number=None,
+ institute=None
+ ):
'''
Email sending function while registration and
booking confirmation.
@@ -23,112 +72,238 @@ def send_email(request, call_on,
if call_on == "Registration":
if user_position == "instructor":
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
+ Your request as an Instructor at FOSSEE, IIT Bombay
+ has been received. You will be notified via email on
+ approval of the same within 3 working days.
+
+ In case of queries regarding the same revert to this
+ email.""")
+
+ try:
+ send_mail(
+ "Instructor Registration - FOSSEE, IIT Bombay", message,
+ EMAIL_HOST_USER, [request.user.email], fail_silently=False
)
+ except Exception:
+ send_smtp_email(request=request,
+ subject="Instructor Registration - FOSSEE, IIT Bombay",
+ message=message, other_email=request.user.email,
+ )
+
- #Send a mail to admin as well as a notification.
+ #Send a mail to admin as well.
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)
+ A new instructor request has been received.
+
+ Instructor name:{0}
+ Instructor email:{1}
+
+ Please verify the profile and mail the user within 2
+ working days.""".format(request.user, request.user.email))
+
+ try:
+ send_mail("New Instructor Registration - FOSSEE, IIT Bombay",
+ message, EMAIL_HOST_USER, ['workshops@fossee.in'],
+ fail_silently=False)
+ except Exception:
+ send_smtp_email(request=request,
+ subject="Instructor Registration - FOSSEE, IIT Bombay",
+ message=message, other_email='workshops@fossee.in',
+ )
else:
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,
+ Thank you for registering as a coordinator with us.
+ Your request as a coordinator has been accepted. You
+ may now proceed to book your dates for the workshop(s).
+
+ In case of queries regarding workshop booking(s),
+ revert to this email.""")
+
+ try:
+ send_mail(
+ "Coordinator Registration at FOSSEE, IIT Bombay", message, EMAIL_HOST_USER,
[request.user.email], fail_silently=False
)
+ except Exception:
+ send_smtp_email(request=request,
+ subject="Coordinator Registration - FOSSEE, IIT Bombay",
+ message=message, other_email=request.user.email,
+ )
elif call_on == "Booking":
if user_position == "instructor":
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(
+ Coordinator name:{0}
+ Coordinator email: {1}
+ Contact number:{2}
+ Institute:{3}
+ Workshop date:{4}
+ Workshop title:{5}
+
+ You may accept or reject this booking
+ workshop.fossee.in .""".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
+ request.user.profile.institute,
+ workshop_date, workshop_title
+ ))
+
+ try:
+ send_mail(
+ "New FOSSEE Workshop booking on {0}".format(workshop_date),
+ message, EMAIL_HOST_USER, [other_email],
+ fail_silently=False
+ )
+ except Exception:
+ send_smtp_email(request=request,
+ subject="New FOSSEE Workshop booking on {0}"
+ .format(workshop_date),
+ message=message, other_email=other_email,
)
else:
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,
+ Thank You for New FOSSEE Workshop booking.
+
+ Workshop date:{0}
+ Workshop title:{1}
+
+ Your request has been received and is awaiting instructor
+ approval/disapproval. You will be notified about the status
+ via email and on your workshops.fossee.in
+
+ In case of queries regarding workshop booking(s), revert
+ to this email.""".format(
+ workshop_date, workshop_title
+ ))
+
+ try:
+ send_mail(
+ "Pending Request for New FOSSEE Workshop booking on {0}"
+ .format(workshop_date), message, EMAIL_HOST_USER,
[request.user.email], fail_silently=False
)
+ except Exception:
+ send_smtp_email(request=request,
+ subject="Pending Request for New FOSSEE Workshop booking \
+ on {0}".format(workshop_date),
+ message=message, other_email=request.user.email,
+ )
elif call_on == "Booking Confirmed":
if user_position == "instructor":
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)
+ Coordinator name:{0}
+ Coordinator email: {1}
+ Contact number:{2}
+ Institute:{3}
+ Workshop date:{4}
+ Workshop title:{5}
+
+ You have accepted this booking. Detailed instructions have
+ been sent to the coordinator. """.format(user_name, user_name,
+ phone_number, institute, workshop_date, workshop_title))
+
+ send_smtp_email(request=request,
+ subject="FOSSEE Workshop booking confirmation on {0}".
+ format(workshop_date), message=message,
+ other_email=request.user.email, attachment=1
+ )
else:
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)
+ Instructor name:{0}
+ Instructor email: {1}
+ Contact number:{2}
+ Workshop date:{3}
+ Workshop title:{4}
+
+ Your workshop booking has been accepted. Detailed
+ instructions are attached below.
+
+ In case of queries regarding the workshop
+ instructions/schedule revert to this email.""".format(
+ request.user.username, request.user.email,
+ phone_number, workshop_date, workshop_title
+ ))
+
+ send_smtp_email(request=request,
+ subject="FOSSEE Workshop booking confirmation on {0}".
+ format(workshop_date), message=message,
+ other_email=other_email, attachment=1
+ )
elif call_on == "Booking Request Rejected":
if user_position == "instructor":
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)
+ Coordinator name:{0}
+ Coordinator email: {1}
+ Contact number:{2}
+ Institute:{3}
+ Workshop date:{4}
+ Workshop title:{4}
+
+ You have rejected this booking. The coordinator has
+ been notified.""".format(user_name, other_email,
+ phone_number, institute,
+ workshop_date, workshop_title))
+
+ try:
+ send_mail("FOSSEE Workshop booking rejected for{0}"
+ .format(workshop_date), message, EMAIL_HOST_USER,
+ [request.user.email], fail_silently=False)
+ except Exception:
+ send_smtp_email(request=request,
+ subject="FOSSEE Workshop booking rejected for {0}".
+ format(workshop_date), message=message,
+ other_email=request.user.email
+ )
else:
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)
+ Workshop date:{0}
+ Workshop title:{1}
+
+ We regret to inform you that your workshop booking
+ has been rejected due to unavailability of the
+ instructor. You may try booking other available
+ slots workshops.fossee.in """
+ .format(workshop_date, workshop_title))
+
+ try:
+ send_mail("FOSSEE Workshop booking rejected for {0}".
+ format(workshop_date), message, EMAIL_HOST_USER,
+ [other_email], fail_silently=False)
+ except Exception:
+ send_smtp_email(request=request,
+ subject="FOSSEE Workshop booking rejected for {0}".
+ format(workshop_date), message=message,
+ other_email=other_email
+ )
elif call_on =='Workshop Deleted':
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)
+ You have deleted a Workshop.
+
+ Workshop date:{0}
+ Workshop title:{1}"""
+ .format(workshop_date, workshop_title))
+ try:
+ send_mail("FOSSEE workshop deleted for {0}".format(workshop_date),
+ message, EMAIL_HOST_USER, [request.user.email],
+ fail_silently=False)
+ except Exception:
+ send_smtp_email(request=request,
+ subject="FOSSEE Workshop deleted for {0}".
+ format(workshop_date), message=message,
+ other_email=request.user.email
+ )
else:
message = "Issue at Workshop Booking App please check"
- send_mail("Issue At Workshop Booking App Mailing", message, EMAIL_HOST_USER,
+ try:
+ 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)
+ except Exception:
+ send_smtp_email(request=request,
+ subject="Issue at Workshop Booking App please check",
+ message=message, other_email='doke.akshen@gmail.com'
+ )
diff --git a/workshop_app/views.py b/workshop_app/views.py
index 326da9d..f5d1b60 100644
--- a/workshop_app/views.py
+++ b/workshop_app/views.py
@@ -31,7 +31,7 @@ def index(request):
user = request.user
if user.is_authenticated():
- if user.profile.position == 'instructor':
+ if user.groups.filter(name='instructor').count() > 0:
return redirect('/manage/')
return redirect('/book/')
return render(request, "workshop_app/index.html")
@@ -39,14 +39,14 @@ def index(request):
def is_instructor(user):
'''Check if the user is having instructor rights'''
- return True if user.profile.position == 'instructor' else False
+ return True if user.groups.filter(name='instructor').count() > 0 else False
def user_login(request):
'''User Login'''
user = request.user
if user.is_authenticated():
- if user.profile.position == 'instructor':
+ if user.groups.filter(name='instructor').count() > 0:
return redirect('/manage/')
return redirect('/book/')
@@ -55,7 +55,7 @@ def user_login(request):
if form.is_valid():
user = form.cleaned_data
login(request, user)
- if user.profile.position == 'instructor':
+ if user.groups.filter(name='instructor').count() > 0:
return redirect('/manage/')
return redirect('/book/')
else:
@@ -106,7 +106,7 @@ def user_register(request):
def book(request):
user = request.user
if user.is_authenticated():
- if user.profile.position == 'instructor':
+ if user.groups.filter(name='instructor').count() > 0:
return redirect('/manage/')
workshop_details = Workshop.objects.all()
@@ -372,6 +372,7 @@ def my_workshops(request):
cmail = workshop_status.requested_workshop_coordinator.email
cname = workshop_status.requested_workshop_coordinator.username
cnum = workshop_status.requested_workshop_coordinator.profile.phone_number
+ cinstitute = workshop_status.requested_workshop_coordinator.profile.institute
inum = request.user.profile.phone_number
wtitle = workshop_status.requested_workshop_title.course_name
@@ -382,7 +383,8 @@ def my_workshops(request):
workshop_title=wtitle,
user_name=str(cname),
other_email=cmail,
- phone_number=cnum
+ phone_number=cnum,
+ institute=cinstitute
)
#For Coordinator
@@ -445,6 +447,8 @@ def my_workshops(request):
wtitle = workshop_status.requested_workshop_title.course_name
cmail = workshop_status.requested_workshop_coordinator.email
cname = workshop_status.requested_workshop_coordinator.username
+ cnum = workshop_status.requested_workshop_coordinator.profile.phone_number
+ cinstitute = workshop_status.requested_workshop_coordinator.profile.institute
#For Instructor
send_email(request, call_on='Booking Request Rejected',
@@ -452,6 +456,9 @@ def my_workshops(request):
workshop_date=str(client_data[1]),
workshop_title=wtitle,
user_name=str(cname),
+ other_email=cmail,
+ phone_number=cnum,
+ institute=cinstitute
)
#For Coordinator
diff --git a/workshop_portal/settings.py b/workshop_portal/settings.py
index 1ba7997..851d859 100644
--- a/workshop_portal/settings.py
+++ b/workshop_portal/settings.py
@@ -133,6 +133,11 @@ STATIC_ROOT = os.path.join(BASE_DIR, "static/")
LOGIN_URL = '/login/'
+MEDIA_URL = '/data/'
+
+MEDIA_ROOT = os.path.join(BASE_DIR, "workshop_app", "data")
+
+
#Email Connection Settings
EMAIL_HOST = EMAIL_HOST
EMAIL_HOST_USER = EMAIL_HOST_USER
@@ -140,6 +145,6 @@ EMAIL_HOST_PASSWORD = EMAIL_HOST_PASSWORD
EMAIL_PORT = EMAIL_PORT
EMAIL_USE_TLS = EMAIL_USE_TLS
EMAIL_TIMEOUT = 300
-EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' #Temp Solution
+#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' #Temp Solution
LOGIN_REDIRECT_URL = '/profile'