diff options
author | 2017-06-12 18:19:21 +0530 | |
---|---|---|
committer | 2017-06-12 18:19:21 +0530 | |
commit | 928ebb23f8b2926240fc220791655614cc4192d2 (patch) | |
tree | fee1f4272e74c289c51638c63e083cdb3b602061 /yaksh | |
parent | 0e8289f1acbfd8fcf4460835effc438e7516700a (diff) | |
download | online_test-928ebb23f8b2926240fc220791655614cc4192d2.tar.gz online_test-928ebb23f8b2926240fc220791655614cc4192d2.tar.bz2 online_test-928ebb23f8b2926240fc220791655614cc4192d2.zip |
Change views.py and urls.py
- Add new url for sending email
- Add new view function to send email to students
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/urls.py | 1 | ||||
-rw-r--r-- | yaksh/views.py | 27 |
2 files changed, 21 insertions, 7 deletions
diff --git a/yaksh/urls.py b/yaksh/urls.py index 825e5f5..068df7a 100644 --- a/yaksh/urls.py +++ b/yaksh/urls.py @@ -69,6 +69,7 @@ urlpatterns = [ url(r'manage/enroll/rejected/(?P<course_id>\d+)/(?P<user_id>\d+)/$', views.enroll, {'was_rejected': True}), url(r'manage/reject/(?P<course_id>\d+)/(?P<user_id>\d+)/$', views.reject), + url(r'manage/send_mail/(?P<course_id>\d+)/$', views.send_mail, name="send_mail"), url(r'manage/enrolled/reject/(?P<course_id>\d+)/(?P<user_id>\d+)/$', views.reject, {'was_enrolled': True}), url(r'manage/toggle_status/(?P<course_id>\d+)/$', views.toggle_course_status), diff --git a/yaksh/views.py b/yaksh/views.py index 41db80e..3319773 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -757,10 +757,9 @@ 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 reject(request, course_id, user_id=None, was_enrolled=False): +def send_mail(request, course_id, user_id=None): user = request.user ci = RequestContext(request) if not is_moderator(user): @@ -770,6 +769,7 @@ def reject(request, course_id, user_id=None, was_enrolled=False): if not course.is_creator(user) and not course.is_teacher(user): raise Http404('This course does not belong to you') + message = None if request.method == 'POST': user_ids = request.POST.getlist('check') if not user_ids: @@ -787,12 +787,25 @@ def reject(request, course_id, user_id=None, was_enrolled=False): message = send_bulk_mail(subject, email_body, recipients, attachments) - return my_render_to_response('yaksh/course_detail.html', - {'course': course, "message": message}, - context_instance=ci) + return my_render_to_response('yaksh/course_detail.html', + {'course': course, "message": message, + 'msg': 'mail'}, + context_instance=ci) - if request.POST.get('reject') == 'reject': - reject_ids = user_ids +@login_required +@email_verified +def reject(request, course_id, user_id=None, was_enrolled=False): + user = request.user + ci = RequestContext(request) + if not is_moderator(user): + raise Http404('You are not allowed to view this page') + + course = get_object_or_404(Course, pk=course_id) + if not course.is_creator(user) and not course.is_teacher(user): + raise Http404('This course does not belong to you') + + if request.method == 'POST': + reject_ids = request.POST.getlist('check') else: reject_ids = [user_id] if not reject_ids: |