--- 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),
)
--- 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
+
--- 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)
--- /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}} <br />
+
+{% if can_view_info %}
+ Gender: {{viewing_profile.gender}} <br />
+ Date of Birth: {{viewing_profile.dob}}<br />
+ <hr />
+ About Me: {{viewing_profile.aboutme|linebreaksbr}} <br />
+ <hr />
+ Address: {{viewing_profile.address|linebreaksbr}} <br />
+ <hr />
+ Phone Number: {{viewing_profile.phonenum}} <br />
+{% endif %}
+
+{% if comp_tasks %}
+Tasks completed by {{viewing_profile.full_name}}:
+<ul>
+ {% for task in comp_tasks %}
+ <li><a href="/task/view/tid={{task.uniq_key}}">{{task.title}}</a></li>
+ {% endfor %}
+</ul>
+{% endif %}
+
+{% if working_tasks %}
+Tasks {{viewing_profile.full_name}} is currently working on:
+<ul>
+ {% for task in working_tasks %}
+ <li><a href="/task/view/tid={{task.uniq_key}}">{{task.title}}</a></li>
+ {% endfor %}
+</ul>
+{% endif %}
+
+{% if reviewing_tasks %}
+Tasks reviewed by {{viewing_profile.full_name}}:
+<ul>
+ {% for task in reviewing_tasks %}
+ <li><a href="/task/view/tid={{task.uniq_key}}">{{task.title}}</a></li>
+ {% endfor %}
+</ul>
+{% endif %}
+
+{% if claimed_tasks and can_view_info %}
+<ul>
+ {% for task in claimed_tasks %}
+ <li><a href="/task/view/tid={{task.uniq_key}}">{{task.title}}</a></li>
+ {% endfor %}
+</ul>
+{% endif %}
+
+{% endblock %}