diff options
Diffstat (limited to 'workshop_app')
-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, |