diff options
author | Akshen | 2017-11-07 13:11:04 +0530 |
---|---|---|
committer | Akshen | 2017-11-07 13:11:04 +0530 |
commit | 0c9c80e6068f3a279ebf0f99f8c121d7e3e55117 (patch) | |
tree | a23a6676089d0467e2e55faa47fc4d5cd4cb6f69 | |
parent | af8507e6e6ada08acf56c6fd1db297fc354fe293 (diff) | |
parent | 807a52e45a9b6c6ac64a7a5e4bd8248900fb4367 (diff) | |
download | online_test-0c9c80e6068f3a279ebf0f99f8c121d7e3e55117.tar.gz online_test-0c9c80e6068f3a279ebf0f99f8c121d7e3e55117.tar.bz2 online_test-0c9c80e6068f3a279ebf0f99f8c121d7e3e55117.zip |
Fix Conflicts in CHANGELOG.txt
-rw-r--r-- | CHANGELOG.txt | 1 | ||||
-rw-r--r-- | yaksh/test_views.py | 32 | ||||
-rw-r--r-- | yaksh/views.py | 12 |
3 files changed, 41 insertions, 4 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d3c6b37..352eb56 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -12,6 +12,7 @@ * Fixed a bug that did not allow expected input in Standard I/O type question to be none. * UI changes in grade user, view answerpaper and monitor pages. * Fixed a bug that would require shebang to be put in for Bash assertion based questions. +* Updated Courses Page to show Active Courses on top. * Added a Datetime Picker to Add Course Page === 0.6.0 (11-05-2017) === diff --git a/yaksh/test_views.py b/yaksh/test_views.py index dc06126..0950785 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -196,6 +196,38 @@ class TestProfile(TestCase): self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'yaksh/profile_updated.html') + def test_edit_profile_post_for_user_without_profile(self): + """ + POST request to edit_profile view should update the user's profile + """ + self.client.login( + username=self.user1.username, + password=self.user1_plaintext_pass + ) + response = self.client.post(reverse('yaksh:edit_profile'), + data={ + 'user': self.user1, + 'first_name': 'new_first_name', + 'last_name': 'new_last_name', + 'roll_number': 21, + 'institute': 'new_institute', + 'department': 'Aerospace', + 'position': 'new_position', + 'timezone': 'UTC' + } + ) + updated_profile_user = User.objects.get(id=self.user1.id) + updated_profile = Profile.objects.get(user=updated_profile_user) + self.assertEqual(updated_profile_user.first_name, 'new_first_name') + self.assertEqual(updated_profile_user.last_name, 'new_last_name') + self.assertEqual(updated_profile.roll_number, '21') + self.assertEqual(updated_profile.institute, 'new_institute') + self.assertEqual(updated_profile.department, 'Aerospace') + self.assertEqual(updated_profile.position, 'new_position') + + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, 'yaksh/profile_updated.html') + def test_edit_profile_get(self): """ GET request to edit profile should display profile form diff --git a/yaksh/views.py b/yaksh/views.py index b4cb844..63da956 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -792,8 +792,10 @@ def courses(request): ci = RequestContext(request) if not is_moderator(user): raise Http404('You are not allowed to view this page') - courses = Course.objects.filter(creator=user, is_trial=False) - allotted_courses = Course.objects.filter(teachers=user, is_trial=False) + courses = Course.objects.filter( + creator=user, is_trial=False).order_by('-active', '-id') + allotted_courses = Course.objects.filter( + teachers=user, is_trial=False).order_by('-active', '-id') context = {'courses': courses, "allotted_courses": allotted_courses} return my_render_to_response('yaksh/courses.html', context, context_instance=ci) @@ -1406,7 +1408,6 @@ def view_profile(request): @login_required -@has_profile @email_verified def edit_profile(request): """ edit profile details facility for moderator and students """ @@ -1418,7 +1419,10 @@ def edit_profile(request): else: template = 'user.html' context = {'template': template} - profile = Profile.objects.get(user_id=user.id) + try: + profile = Profile.objects.get(user_id=user.id) + except Profile.DoesNotExist: + profile = None if request.method == 'POST': form = ProfileForm(request.POST, user=user, instance=profile) |