diff options
author | adityacp | 2017-08-17 10:47:50 +0530 |
---|---|---|
committer | adityacp | 2017-08-17 10:47:50 +0530 |
commit | 4f305d1e2ccce8b2250624838a29d2000d0d9230 (patch) | |
tree | f18f28bfdfc69200c9ce9b0d32e8ea9e1325a97a /yaksh/views.py | |
parent | 8c1d2ffb0670998c35bd963d5458d245ac97c5fd (diff) | |
download | online_test-4f305d1e2ccce8b2250624838a29d2000d0d9230.tar.gz online_test-4f305d1e2ccce8b2250624838a29d2000d0d9230.tar.bz2 online_test-4f305d1e2ccce8b2250624838a29d2000d0d9230.zip |
Change views.py
- Pep8 changes
- Remove redundant check from send mail function
- Move validation send mail validation to js
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index ffdcf98..b4ab9bb 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -732,6 +732,7 @@ def enroll(request, course_id, user_id=None, was_rejected=False): course.enroll(was_rejected, *users) return course_detail(request, course_id) + @login_required @email_verified def send_mail(request, course_id, user_id=None): @@ -747,25 +748,23 @@ def send_mail(request, course_id, user_id=None): message = None if request.method == 'POST': user_ids = request.POST.getlist('check') - if not user_ids: - message = "Please select atleast one User" - return my_render_to_response('yaksh/course_detail.html', - {'course': course, "message": message}, - context_instance=ci) - if request.POST.get('send_mail') == 'send_mail': users = User.objects.filter(id__in=user_ids) - recipients = [user.email for user in users] + recipients = [student.email for student in users] email_body = request.POST.get('body') subject = request.POST.get('subject') attachments = request.FILES.getlist('email_attach') - message = send_bulk_mail(subject, email_body, recipients, - attachments) + message = send_bulk_mail( + subject, email_body, recipients, attachments + ) + context = { + 'course': course, 'message': message, + 'status': 'mail' + } + return my_render_to_response( + 'yaksh/course_detail.html', context, context_instance=ci + ) - return my_render_to_response('yaksh/course_detail.html', - {'course': course, "message": message, - 'msg': 'mail'}, - context_instance=ci) @login_required @email_verified |