From 3ab5cf0783159aab349ef69db7500a42ad2e719c Mon Sep 17 00:00:00 2001 From: prathamesh Date: Fri, 27 Oct 2017 12:49:45 +0530 Subject: Edit Profile Bug Fix edit_profile view had a decorator has_profile. So, has_profile will redirect to edit_profile if no profile. But then if I submit my profile form then the has_profile will again redirect to edit_profile, instead of updating my profile. So this cycle will continue endlessly for a user with no profile, and will never be able to create/update his profile! Will face this when user is created via csv upload, django admin or oauth login without pipeline. Also, profile instance is passed to the profile form via get query, which will fail if no profile. Added a views test for the above. Fixed. Additionally that can be thought of later: The has_profile decorator is used for few views only, so one can access views if they know the url, even if they do not have a profile. email edit option for users --- yaksh/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index b4cb844..c50ba33 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1406,7 +1406,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 +1417,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) -- cgit From ae78048a1f978a6a570faeb10ecb77229460eae1 Mon Sep 17 00:00:00 2001 From: Akshen Date: Tue, 31 Oct 2017 11:15:41 +0530 Subject: Fix Course Ordering in Courses Page Latest Course will be shown on Top in Courses Page --- yaksh/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index b4cb844..47d8c9f 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('-id') + allotted_courses = Course.objects.filter( + teachers=user, is_trial=False).order_by('-id') context = {'courses': courses, "allotted_courses": allotted_courses} return my_render_to_response('yaksh/courses.html', context, context_instance=ci) -- cgit From 9aeaf153851c7821336ab542b4fd8f4e621a8d65 Mon Sep 17 00:00:00 2001 From: Akshen Date: Sat, 4 Nov 2017 13:35:36 +0530 Subject: Show Active Course on top of Courses Page --- yaksh/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 47d8c9f..0d6acfe 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -793,9 +793,9 @@ def courses(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).order_by('-id') + creator=user, is_trial=False).order_by('-active') allotted_courses = Course.objects.filter( - teachers=user, is_trial=False).order_by('-id') + teachers=user, is_trial=False).order_by('-active') context = {'courses': courses, "allotted_courses": allotted_courses} return my_render_to_response('yaksh/courses.html', context, context_instance=ci) -- cgit From 52afb684b1bd59cc1d5f2f1a6963b877a5604b37 Mon Sep 17 00:00:00 2001 From: Akshen Date: Mon, 6 Nov 2017 15:45:21 +0530 Subject: Show Latest Active Course on top of Courses Page --- yaksh/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 0d6acfe..e2412bb 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -793,9 +793,9 @@ def courses(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).order_by('-active') + creator=user, is_trial=False).order_by('-active', '-id') allotted_courses = Course.objects.filter( - teachers=user, is_trial=False).order_by('-active') + 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) -- cgit