# HG changeset patch # User Nishanth Amuluru # Date 1294729210 -19800 # Node ID 8fcde6f8f7505d94e739613543e88cc1054bb860 # Parent 4f0cfd486d9b873fa2b466fcdbe6e29eaf4b4ef1 added view_user functionality diff -r 4f0cfd486d9b -r 8fcde6f8f750 pytask/profile/urls.py --- a/pytask/profile/urls.py Tue Jan 11 11:56:34 2011 +0530 +++ b/pytask/profile/urls.py Tue Jan 11 12:30:10 2011 +0530 @@ -2,7 +2,8 @@ from pytask.profile.views import view_profile, edit_profile,\ browse_notifications, view_notification,\ - delete_notification, unread_notification + delete_notification, unread_notification, \ + view_user urlpatterns = patterns('', @@ -12,5 +13,7 @@ (r'^notf/view/nid=(\w+)$', view_notification), (r'^notf/del/nid=(\w+)$', delete_notification), (r'^notf/unr/nid=(\w+)$', unread_notification), + + (r'^user/view/uid=(\w+)$', view_user), ) diff -r 4f0cfd486d9b -r 8fcde6f8f750 pytask/profile/utils.py --- a/pytask/profile/utils.py Tue Jan 11 11:56:34 2011 +0530 +++ b/pytask/profile/utils.py Tue Jan 11 12:30:10 2011 +0530 @@ -1,3 +1,5 @@ +from django.http import Http404 +from django.contrib.auth.models import User from pytask.profile.models import Notification def get_notification(nid, user): @@ -30,3 +32,16 @@ else: return None, None, None, None, None + +def get_user(uid): + + try: + user = User.objects.get(id=uid) + except User.DoesNotExist: + raise Http404 + + if user.is_active: + return user + else: + raise Http404 + diff -r 4f0cfd486d9b -r 8fcde6f8f750 pytask/profile/views.py --- a/pytask/profile/views.py Tue Jan 11 11:56:34 2011 +0530 +++ b/pytask/profile/views.py Tue Jan 11 12:30:10 2011 +0530 @@ -6,7 +6,7 @@ from django.views.decorators.csrf import csrf_protect from pytask.profile.forms import EditProfileForm -from pytask.profile.utils import get_notification +from pytask.profile.utils import get_notification, get_user @login_required def view_profile(request): @@ -147,3 +147,32 @@ redirect_url = "/profile/notf/browse" return redirect(redirect_url) + +@login_required +def view_user(request, uid): + + user = request.user + profile = user.get_profile() + + viewing_user = get_user(uid) + viewing_profile = viewing_user.get_profile() + + working_tasks = viewing_user.approved_tasks.filter(status="WR") + completed_tasks = viewing_user.approved_tasks.filter(status="CM") + reviewing_tasks = viewing_user.reviewing_tasks.all() + claimed_tasks = viewing_user.claimed_tasks.all() + + can_view_info = True if profile.rights in ["MG", "DC"] else False + + context = {"user": user, + "profile": profile, + "viewing_user": viewing_user, + "viewing_profile": viewing_profile, + "working_tasks": working_tasks, + "completed_tasks": completed_tasks, + "reviewing_tasks": reviewing_tasks, + "claimed_tasks": claimed_tasks, + "can_view_info": can_view_info, + } + + return render_to_response("profile/view_user.html", context) diff -r 4f0cfd486d9b -r 8fcde6f8f750 pytask/templates/profile/view_user.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pytask/templates/profile/view_user.html Tue Jan 11 12:30:10 2011 +0530 @@ -0,0 +1,51 @@ +{% extends 'base.html' %} +{% block content %} +Name: {{viewing_profile.full_name}}
+ +{% if can_view_info %} + Gender: {{viewing_profile.gender}}
+ Date of Birth: {{viewing_profile.dob}}
+
+ About Me: {{viewing_profile.aboutme|linebreaksbr}}
+
+ Address: {{viewing_profile.address|linebreaksbr}}
+
+ Phone Number: {{viewing_profile.phonenum}}
+{% endif %} + +{% if comp_tasks %} +Tasks completed by {{viewing_profile.full_name}}: + +{% endif %} + +{% if working_tasks %} +Tasks {{viewing_profile.full_name}} is currently working on: + +{% endif %} + +{% if reviewing_tasks %} +Tasks reviewed by {{viewing_profile.full_name}}: + +{% endif %} + +{% if claimed_tasks and can_view_info %} + +{% endif %} + +{% endblock %}