diff options
author | adityacp | 2016-03-31 19:42:44 +0530 |
---|---|---|
committer | adityacp | 2016-04-15 14:01:51 +0530 |
commit | c140d65ab1a3c4faa97789e08223d563cf283d25 (patch) | |
tree | 1604dc89ae0a7e66f18e4a6f8fde3eda7e5b54af | |
parent | 234cf831861045796a7bcf4e08a46b0c38016f75 (diff) | |
download | online_test-c140d65ab1a3c4faa97789e08223d563cf283d25.tar.gz online_test-c140d65ab1a3c4faa97789e08223d563cf283d25.tar.bz2 online_test-c140d65ab1a3c4faa97789e08223d563cf283d25.zip |
changes in edit profile, enrollment, change password
-rw-r--r-- | yaksh/static/yaksh/js/course.js | 38 | ||||
-rw-r--r-- | yaksh/templates/yaksh/course_detail.html | 55 | ||||
-rw-r--r-- | yaksh/templates/yaksh/editprofile.html | 4 | ||||
-rw-r--r-- | yaksh/templates/yaksh/view_profile.html | 22 | ||||
-rw-r--r-- | yaksh/urls.py | 9 | ||||
-rw-r--r-- | yaksh/views.py | 19 |
6 files changed, 101 insertions, 46 deletions
diff --git a/yaksh/static/yaksh/js/course.js b/yaksh/static/yaksh/js/course.js new file mode 100644 index 0000000..3a21f0d --- /dev/null +++ b/yaksh/static/yaksh/js/course.js @@ -0,0 +1,38 @@ +$(document).ready(function(){
+$(".checkall").click( function(){
+ if($(this).attr("checked")) {
+ $("#enroll-all input:checkbox").each(function(index, element) {
+ $(this).attr('checked', true);
+ });
+ }
+ else {
+ $("#enroll-all input:checkbox").each(function(index, element) {
+ $(this).attr('checked', false);
+ });
+ }
+ });
+$(".enroll").click( function(){
+ if($(this).attr("checked")) {
+ $("#enroll input:checkbox").each(function(index, element) {
+ $(this).attr('checked', true);
+ });
+ }
+ else {
+ $("#enroll input:checkbox").each(function(index, element) {
+ $(this).attr('checked', false);
+ });
+ }
+ });
+$(".reject").click( function(){
+ if($(this).attr("checked")) {
+ $("#reject input:checkbox").each(function(index, element) {
+ $(this).attr('checked', true);
+ });
+ }
+ else {
+ $("#reject input:checkbox").each(function(index, element) {
+ $(this).attr('checked', false);
+ });
+ }
+ });
+});
diff --git a/yaksh/templates/yaksh/course_detail.html b/yaksh/templates/yaksh/course_detail.html index 2e17035..dbb7b73 100644 --- a/yaksh/templates/yaksh/course_detail.html +++ b/yaksh/templates/yaksh/course_detail.html @@ -9,73 +9,78 @@ {% endblock %} {% block script %} <script language="JavaScript" type="text/javascript" src="{{ URL_ROOT }}/static/yaksh/js/jquery-1.4.2.min.js"></script> -<script> -$(document).ready(function(){ -$(".checkall").click( function(){ - if($(this).attr("checked")) { - $("#enroll-all input:checkbox").each(function(index, element) { - $(this).attr('checked', true); - }); - } - else { - $("#enroll-all input:checkbox").each(function(index, element) { - $(this).attr('checked', false); - }); - } - }); -}); -</script> +<script language="JavaScript" type="text/javascript" src="{{ URL_ROOT }}/static/yaksh/js/course.js"></script> {% endblock %} {% block manage %} <div class="row"> <div class="span6 wrap"> <center><b><u>Requests</u></b></center><br> - <form action="{{URL_ROOT}}/exam/manage/enroll/{{ course.id }}" method="post"> - {% csrf_token %} - <input type="checkbox" class="checkall"/><font size="2">Enroll all</font> + {% if course.get_requests %} + <input type="checkbox" class="checkall"/> <font size="2">Select all</font> <div id="enroll-all"> + <form action="{{URL_ROOT}}/exam/manage/enroll/{{ course.id }}/" method="post"> + {% csrf_token %} {% for request in course.get_requests %} <div class="well"> <div class="row"> - <div class="span3" style="padding-top:10px"> - <input type="checkbox" name="check" value="{{ request.id }}"></input> <a href="#" data-toggle="tooltip" title=" Institute: {{ request.profile.institute }}
Department: {{ request.profile.department}}
Roll Number: {{ request.profile.roll_number }}">{{ request.username }}</a><br> + <div class="span3" style="padding-top:10px"> + <input type="checkbox" name="check" value="{{ request.id }}"> <a href="#" data-toggle="tooltip" title=" Institute: {{ request.profile.institute }}
Department: {{ request.profile.department}}
Roll Number: {{ request.profile.roll_number }}"> {{ request.username }}</a><br> </div> <a class="btn success" href="{{URL_ROOT}}/exam/manage/enroll/{{ course.id }}/{{ request.id }}/"> Enroll </a> <a class="btn danger" href="{{URL_ROOT}}/exam/manage/reject/{{ course.id }}/{{ request.id }}/"> Reject </a> </div> </div> {% endfor %} + <button class="btn success" type="submit" name='enroll' value='enroll'>Enroll Selected</button> </div> + {% endif %} + </form> </div> <div class="span6 wrap"> <center><b><u>Rejected</u></b></center><br> + {% if course.get_rejected %} + <input type="checkbox" class="enroll"/> <font size="2">Select all</font> + <div id="enroll"> {% for rejected in course.get_rejected %} + <form action="{{URL_ROOT}}/exam/manage/enroll/rejected/{{ course.id }}/" method="post"> + {% csrf_token %} <div class="well"> <div class="row"> <div class="span4" style="padding-top:10px"> - {{ rejected.username }} + <input type="checkbox" name="check" value="{{ rejected.id }}"> {{ rejected.username }} </div> <a class="btn success" href="{{URL_ROOT}}/exam/manage/enroll/rejected/{{ course.id }}/{{ rejected.id }}/"> Enroll </a> </div> </div> {% endfor %} + <button class="btn success" type="submit" name='enroll' value='enroll'>Enroll Selected</button> + </div> + {% endif %} + </form> </div> </div> <br> -<button class="btn" type="submit" name='enroll' value='enroll'>Enroll</button> -</form> <div class="row"> <div class="span6 offset4 wrap"> <center><b><u>Enrolled</u></b></center><br> + {% if course.get_enrolled %} + <input type="checkbox" class="reject"/> <font size="2">Select all</font> + <div id="reject"> {% for enrolled in course.get_enrolled %} + <form action="{{URL_ROOT}}/exam/manage/enrolled/reject/{{ course.id }}/" method="post"> + {% csrf_token %} <div class="well"> <div class="row"> <div class="span4" style="padding-top:10px"> - {{ enrolled.username }} + <input type="checkbox" name="check" value="{{ enrolled.id }}"> {{ enrolled.username }} </div> <a class="btn danger" href="{{URL_ROOT}}/exam/manage/enrolled/reject/{{ course.id }}/{{ enrolled.id }}/"> Reject </a> </div> </div> {% endfor %} + <button class="btn danger" type="submit" name='reject' value='reject'>Reject Selected</button> + </div> + {% endif %} + </form> </div> </div> <div class="pull-right"> diff --git a/yaksh/templates/yaksh/editprofile.html b/yaksh/templates/yaksh/editprofile.html index b4cf037..f04f8fb 100644 --- a/yaksh/templates/yaksh/editprofile.html +++ b/yaksh/templates/yaksh/editprofile.html @@ -14,8 +14,8 @@ {{ form.as_table }} </table> </center> - <center><button class="btn" type="submit">Edit Profile</button> - <button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/");'>Cancel</button> </center> + <center><button class="btn" type="submit">Save</button> + <button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/viewprofile");'>Cancel</button> </center> </form> {% endblock content %} diff --git a/yaksh/templates/yaksh/view_profile.html b/yaksh/templates/yaksh/view_profile.html index 27bc5da..a419d92 100644 --- a/yaksh/templates/yaksh/view_profile.html +++ b/yaksh/templates/yaksh/view_profile.html @@ -5,44 +5,46 @@ {% block pagetitle %} Online Test {% endblock %} {% block css %} <link rel="stylesheet" media="all" type="text/css" href="{{ URL_ROOT }}/static/yaksh/css/base.css" /> + {% endblock %} {% block content %} <ul> - <a href={{ URL_ROOT }}/exam/manage/editprofile>Edit Profile</a> - <a href={{ URL_ROOT }}/exam/>Back to Home</a> + <a href="{{ URL_ROOT }}/exam/manage/editprofile">Edit Profile</a> + <a href="{{ URL_ROOT }}/exam/">Back to Home</a> </ul> - +<div class="well"> <table width="398" border="0" align="center" cellpadding="0"> <tr> <td height="26" colspan="2"><h2>Your Profile Information</h2> </td> </tr> <tr> - <td width="82" valign="top"><h3>Firstname:</h3></td> + <td width="82" valign="top"><h4>Firstname:</h4></td> <td width="165" valign="top"><h4>{{ user.first_name }}</h4></td> </tr> <tr> - <td valign="top"><h3>Lastname:</h3></td> + <td valign="top"><h4>Lastname:</h4></td> <td valign="top"><h4>{{ user.last_name }}</h4></td> </tr> <tr> - <td valign="top"><h3>Email:</h3><h3></td> + <td valign="top"><h4>Email:</h4></td> <td valign="top"><h4>{{ user.email }}</h4></td> </tr> <tr> - <td valign="top"><h3>Institute:</h3></td> + <td valign="top"><h4>Institute:</h4></td> <td valign="top"><h4>{{ user.profile.institute }}</h4></td> </tr> <tr> - <td valign="top"><h3>Department:</h3></td> + <td valign="top"><h4>Department:</h4></td> <td valign="top"><h4>{{ user.profile.department }}</h4></td> </tr> <tr> - <td valign="top"><h3>Roll Number:</h3></td> + <td valign="top"><h4>Roll Number:</h4></td> <td valign="top"><h4>{{ user.profile.roll_number }}</h4></td> </tr> <tr> - <td valign="top"><h3>Position:</h3></td> + <td valign="top"><h4>Position:</h4></td> <td valign="top"><h4>{{ user.profile.position }}</h4></td> </tr> </table> +</div> {% endblock %} diff --git a/yaksh/urls.py b/yaksh/urls.py index 584064d..ab9f90a 100644 --- a/yaksh/urls.py +++ b/yaksh/urls.py @@ -12,8 +12,10 @@ urlpatterns = [ name='password_reset_done'), url(r'^password_reset/complete/$', password_reset_complete, name='password_reset_complete'), - url(r'^changepassword/$', 'password_change', name='password_change'), - url(r'^password_change/done/$', 'password_change_done', name='password_change_done'), + url(r'^password_change/$', password_change, + name='password_change'), + url(r'^password_change/done/$', password_change_done, + name='password_change_done'), ] urlpatterns += [ url(r'^$', views.index), @@ -79,5 +81,4 @@ urlpatterns += [ url(r'^manage/editprofile/$', views.edit_profile), url(r'^manage/viewprofile/$', views.view_profile), url(r'^manage/enroll/(?P<course_id>\d+)', views.enroll) -] - +]
\ No newline at end of file diff --git a/yaksh/views.py b/yaksh/views.py index 2738a26..8001520 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -624,7 +624,8 @@ def enroll(request, course_id, user_id=None, was_rejected=False): return my_render_to_response('yaksh/course_detail.html', {'course': course}, context_instance=ci) else: - course.enroll(was_rejected, *enroll_ids) + enroll_users = User.objects.filter(id__in=enroll_ids) + course.enroll(was_rejected, *enroll_users) else: user = get_object_or_404(User, pk=user_id) course.enroll(was_rejected, user) @@ -632,13 +633,22 @@ def enroll(request, course_id, user_id=None, was_rejected=False): @login_required -def reject(request, course_id, user_id, was_enrolled=False): +def reject(request, course_id, user_id=None, was_enrolled=False): user = request.user if not is_moderator(user): raise Http404('You are not allowed to view this page') course = get_object_or_404(Course, creator=user, pk=course_id) - user = get_object_or_404(User, pk=user_id) - course.reject(was_enrolled, user) + if request.method == 'POST': + reject_ids = request.POST.getlist('check') + if reject_ids is None: + return my_render_to_response('yaksh/course_detail.html', {'course': course}, + context_instance=ci) + else: + reject_users = User.objects.filter(id__in=reject_ids) + course.reject(was_enrolled, *reject_users) + else: + user = get_object_or_404(User, pk=user_id) + course.reject(was_enrolled, user) return course_detail(request, course_id) @@ -970,7 +980,6 @@ def design_questionpaper(request): def view_profile(request): """ view moderators and users profile """ - context = {} user = request.user ci = RequestContext(request) if not user.is_authenticated(): |