diff options
author | Akshen | 2017-08-01 15:08:49 +0530 |
---|---|---|
committer | Akshen | 2017-08-01 15:08:49 +0530 |
commit | 0e819d1bd1d92df29ad5c0ecc3610103d945bfae (patch) | |
tree | 5aad1a0d8ce1348d310e69d6a0ce8814f289f64b | |
parent | bab841b7c03f45b91ee4bd9229898758e973807e (diff) | |
download | workshop_booking-0e819d1bd1d92df29ad5c0ecc3610103d945bfae.tar.gz workshop_booking-0e819d1bd1d92df29ad5c0ecc3610103d945bfae.tar.bz2 workshop_booking-0e819d1bd1d92df29ad5c0ecc3610103d945bfae.zip |
Sends Mail To Instructor on each Propose Workshop request
-rw-r--r-- | workshop_app/send_mails.py | 33 | ||||
-rw-r--r-- | workshop_app/views.py | 17 |
2 files changed, 43 insertions, 7 deletions
diff --git a/workshop_app/send_mails.py b/workshop_app/send_mails.py index 15fc1d5..f76a7c2 100644 --- a/workshop_app/send_mails.py +++ b/workshop_app/send_mails.py @@ -242,12 +242,12 @@ def send_email( request, call_on, elif call_on == "Booking Request Rejected": if user_position == "instructor": message = dedent("""\ - Coordinator name:{0} + Coordinator name: {0} Coordinator email: {1} - Contact number:{2} - Institute:{3} - Workshop date:{4} - Workshop title:{4} + Contact number: {2} + Institute: {3} + Workshop date: {4} + Workshop title: {5} You have rejected this booking. The coordinator has been notified.""".format(user_name, other_email, @@ -303,3 +303,26 @@ def send_email( request, call_on, format(workshop_date), message=message, other_email=request.user.email ) + + elif call_on == 'Proposed Workshop': + if user_position == "instructor": + message = dedent("""\ + A coordinator has proposed a workshop below are the + details: + + Coordinator name: {0} + Coordinator email: {1} + Contact number: {2} + Institute: {3} + Workshop date: {4} + Workshop title: {5} + + Please Accept only if you are willing to take the workshop. + {6}/my_workshops/ """ + .format(user_name, request.user.email, + phone_number, institute, + workshop_date, workshop_title, + PRODUCTION_URL)) + send_mail("Proposed Workshop on {0}". + format(workshop_date), message, SENDER_EMAIL, + [other_email], fail_silently=False)
\ No newline at end of file diff --git a/workshop_app/views.py b/workshop_app/views.py index 1dad51a..7cf1c84 100644 --- a/workshop_app/views.py +++ b/workshop_app/views.py @@ -685,7 +685,17 @@ def propose_workshop(request): else: form_data.proposed_workshop_coordinator.save() form_data.save() - + instructors = Profile.objects.filter(position='instructor') + for i in instructors: + send_email(request, call_on='Proposed Workshop', + user_position='instructor', + workshop_date=str(form_data.proposed_workshop_date), + workshop_title=form_data.proposed_workshop_title, + user_name=str(user.get_full_name()), + other_email=i.user.email, + phone_number=user.profile.phone_number, + institute=user.profile.institute + ) return redirect('/my_workshops/') else: form = ProposeWorkshopDateForm() @@ -881,7 +891,10 @@ def testimonials(request): def scheduled_workshops(request): user = request.user if is_instructor(user) and is_email_checked(user): - accepted_workshops = ProposeWorkshopDate.objects.all().order_by('-id')[:15] + try: + accepted_workshops = ProposeWorkshopDate.objects.all().order_by('-id')[:15] + except: + accepted_workshops = None return render(request, 'workshop_app/scheduled_workshops.html', { "accepted_workshops": accepted_workshops, |