now all the pages show number of unread beside requests and notifications link in sidebar.
--- a/taskapp/views/task.py Sun Feb 28 03:31:40 2010 +0530
+++ b/taskapp/views/task.py Sun Feb 28 03:45:28 2010 +0530
@@ -8,6 +8,7 @@
from pytask.taskapp.forms.task import TaskCreateForm, AddMentorForm, AddTaskForm, ChoiceForm, AssignCreditForm, RemoveUserForm
from pytask.taskapp.events.task import createTask, reqMentor, publishTask, addSubTask, addDep, addClaim, assignTask, updateTask, removeTask, removeUser, assignCredits, completeTask, closeTask
from pytask.taskapp.views.user import show_msg
+from pytask.taskapp.utilities.user import get_user
## everywhere if there is no task, django should display 500 message.. but take care of that in sensitive views like add mentor and all
## do not create su user thro syncdb
@@ -15,7 +16,7 @@
def browse_tasks(request):
""" display all the tasks """
- user = request.user
+ user = get_user(request.user)
task_list = Task.objects.exclude(status="UP").exclude(status="DL").order_by('published_datetime').reverse()
context = {'user':user,
@@ -29,7 +30,7 @@
task_url = "/task/view/tid=%s"%tid
- user = request.user
+ user = get_user(request.user)
task = getTask(tid)
is_guest = True if not user.is_authenticated() else False
@@ -57,7 +58,7 @@
task_url = "/task/view/tid=%s"%tid
- user = request.user
+ user = get_user(request.user)
task = getTask(tid)
if task.status == "DL":
@@ -109,7 +110,7 @@
if user cannot create a task, redirect to homepage.
"""
- user = request.user
+ user = get_user(request.user)
is_guest = True if not user.is_authenticated() else False
if not is_guest:
@@ -151,7 +152,7 @@
task_url = "/task/view/tid=%s"%tid
- user = request.user
+ user = get_user(request.user)
task = getTask(tid)
errors = []
@@ -191,7 +192,7 @@
task_url = "/task/view/tid=%s"%tid
- user = request.user
+ user = get_user(request.user)
task = getTask(tid)
deps, subs = task.deps, task.subs
@@ -251,7 +252,7 @@
task_url = "/task/view/tid=%s"%tid
- user = request.user
+ user = get_user(request.user)
task = getTask(tid)
is_guest = True if not user.is_authenticated() else False
@@ -294,7 +295,7 @@
errors = []
- user = request.user
+ user = get_user(request.user)
task = getTask(tid)
claims = Claim.objects.filter(task=task)
@@ -338,7 +339,7 @@
task_url = "/task/view/tid=%s"%tid
- user = request.user
+ user = get_user(request.user)
task = getTask(tid)
is_guest = True if not user.is_authenticated() else False
@@ -383,7 +384,7 @@
task_url = "/task/view/tid=%s"%tid
- user = request.user
+ user = get_user(request.user)
task = getTask(tid)
is_guest = True if not user.is_authenticated() else False
@@ -422,7 +423,7 @@
task_url = "/task/view/tid=%s"%tid
- user = request.user
+ user = get_user(request.user)
task = getTask(tid)
is_guest = True if not user.is_authenticated() else False
@@ -480,7 +481,7 @@
task_url = "/task/view/tid=%s"%tid
- user = request.user
+ user = get_user(request.user)
task = getTask(tid)
is_guest = True if not user.is_authenticated() else False
@@ -521,7 +522,7 @@
task_url = "/task/view/tid=%s"%tid
- user = request.user
+ user = get_user(request.user)
task = getTask(tid)
is_guest = True if not user.is_authenticated() else False
--- a/taskapp/views/user.py Sun Feb 28 03:31:40 2010 +0530
+++ b/taskapp/views/user.py Sun Feb 28 03:45:28 2010 +0530
@@ -71,29 +71,33 @@
""" depending on what was asked for, we render different pages.
"""
+ user = get_user(request.user)
disp_template = about.get(what, None)
if not disp_template:
raise Http404
else:
- return render_to_response(disp_template)
+ return render_to_response(disp_template, {'user':user})
@login_required
def view_my_profile(request,uid=None):
""" allows the user to view the profiles of users """
+ user = get_user(request.user)
if uid == None:
edit_profile = True
profile = Profile.objects.get(user = request.user)
- return render_to_response('user/my_profile.html', {'edit_profile':edit_profile,'profile':profile, 'user':request.user})
+ return render_to_response('user/my_profile.html', {'edit_profile':edit_profile,'profile':profile, 'user':user})
edit_profile = True if request.user == User.objects.get(pk=uid) else False
try:
profile = Profile.objects.get(user = User.objects.get(pk=uid))
except Profile.DoesNotExist:
raise Http404
- return render_to_response('user/my_profile.html', {'edit_profile':edit_profile,'profile':profile, 'user':request.user})
+ return render_to_response('user/my_profile.html', {'edit_profile':edit_profile,'profile':profile, 'user':user})
@login_required
def edit_my_profile(request):
""" enables the user to edit his/her user profile """
+
+ user = get_user(request.user)
if request.method == 'POST':
form = UserProfileEditForm(request.POST)
# if not form.is_valid():
@@ -122,12 +126,12 @@
else:
profile = Profile.objects.get(user = request.user)
edit_profile_form = UserProfileEditForm(instance = profile)
- return render_to_response('user/edit_profile.html',{'edit_profile_form' : edit_profile_form, 'user':request.user})
+ return render_to_response('user/edit_profile.html',{'edit_profile_form' : edit_profile_form, 'user':user})
@login_required
def browse_requests(request):
- user = request.user
+ user = get_user(request.user)
active_reqs = user.request_sent_to.filter(is_replied=False).exclude(is_valid=False)
reqs = active_reqs.order_by('creation_date').reverse()
@@ -144,7 +148,7 @@
our app request is called user_request.
"""
- user = request.user
+ user = get_user(request.user)
newest, newer, user_request, older, oldest = get_request(rid, user)
if not user_request:
raise Http404
@@ -170,7 +174,7 @@
if it is get, display a 404 error.
"""
- user = request.user
+ user = get_user(request.user)
browse_request_url= '/user/requests'
newest, newer, req_obj, older, oldest = get_request(rid, user)
@@ -197,7 +201,7 @@
""" get the list of notifications that are not deleted and display in datetime order.
"""
- user = request.user
+ user = get_user(request.user)
active_notifications = user.notification_sent_to.filter(is_deleted=False).order_by('sent_date').reverse()
@@ -214,7 +218,7 @@
Display it.
"""
- user = request.user
+ user = get_user(request.user)
newest, newer, notification, older, oldest = get_notification(nid, user)
if not notification:
raise Http404
@@ -240,7 +244,7 @@
save the notification and redirect to browse_notifications.
"""
- user = request.user
+ user = get_user(request.user)
newest, newer, notification, older, oldest = get_notification(nid, user)
if not notification: