summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadhusudan.C.S2011-02-09 02:30:12 +0530
committerMadhusudan.C.S2011-02-09 02:36:52 +0530
commit1b09248c06c7df0c218bff7e921ef40a470c5ba8 (patch)
tree7c99e18c6a3f5069c033c061892ebbaec531ff42
parent6c632964b3979edd5badbf094434f7c2fb0b4cba (diff)
downloadpytask-1b09248c06c7df0c218bff7e921ef40a470c5ba8.tar.gz
pytask-1b09248c06c7df0c218bff7e921ef40a470c5ba8.tar.bz2
pytask-1b09248c06c7df0c218bff7e921ef40a470c5ba8.zip
Merged the view_profile and view_user_profile views.
We also pass the context variables required to render the profile page's sensitive information.
-rw-r--r--pytask/profile/urls.py2
-rwxr-xr-xpytask/profile/views.py41
-rw-r--r--pytask/templates/profile/view.html75
-rw-r--r--pytask/templates/profile/view_user.html52
4 files changed, 91 insertions, 79 deletions
diff --git a/pytask/profile/urls.py b/pytask/profile/urls.py
index fcd5a2c..9b0e0fe 100644
--- a/pytask/profile/urls.py
+++ b/pytask/profile/urls.py
@@ -4,7 +4,7 @@ from django.conf.urls.defaults import url
urlpatterns = patterns('pytask.profile.views',
url(r'^view/$', 'view_profile', name='view_profile'),
- url(r'^view/(?P<user_id>\d+)$', 'view_user_profile',
+ url(r'^view/(?P<user_id>\d+)$', 'view_profile',
name='view_user_profile'),
url(r'^edit/$', 'edit_profile', name='edit_profile'),
url(r'^notification/browse/$', 'browse_notifications',
diff --git a/pytask/profile/views.py b/pytask/profile/views.py
index c247d78..a50154a 100755
--- a/pytask/profile/views.py
+++ b/pytask/profile/views.py
@@ -16,34 +16,35 @@ from pytask.profile.utils import get_user
@login_required
-def view_profile(request, template_name='profile/view.html'):
- """ Display the profile information.
- """
-
- user = request.user
- profile = user.get_profile()
-
- context = {
- 'user': user,
- 'profile': profile,
- }
-
- return shortcuts.render_to_response(
- template_name, RequestContext(request, context))
-
-@login_required
-def view_user_profile(request, user_id, template_name='profile/view_user.html'):
+def view_profile(request, user_id=None,
+ template_name='profile/view.html'):
""" Display the profile information of the user specified in the ID.
"""
- user = shortcuts.get_object_or_404(User, pk=int(user_id))
- profile = user.get_profile()
+ if user_id:
+ profile_user = shortcuts.get_object_or_404(User, pk=int(user_id))
+ else:
+ profile_user = request.user
+ profile = profile_user.get_profile()
context = {
- 'profile_user': user,
+ 'profile_user': profile_user,
'profile': profile,
}
+ access_user_role = request.user.get_profile().role
+
+ if (request.user == profile_user or access_user_role == 'Administrator'
+ or request.user.is_superuser):
+ # context variable all is used to indicate that the currently
+ # logged in user has access to all the sensitive information.
+ # context variable medium indicates that the currently logged
+ # in user has access to medium sensitive information.
+ context['all'] = True
+ context['medium'] = True
+ elif access_user_role == 'Coordinator':
+ context['medium'] = True
+
return shortcuts.render_to_response(
template_name, RequestContext(request, context))
diff --git a/pytask/templates/profile/view.html b/pytask/templates/profile/view.html
index ff00163..cb7841f 100644
--- a/pytask/templates/profile/view.html
+++ b/pytask/templates/profile/view.html
@@ -2,15 +2,78 @@
{% block content %}
+
+{% if all %}
+ <a href="{% url edit_profile %}">Edit Profile</a><br />
+{% endif %}
+
Name: {{ profile.full_name }} <br />
-Username: {{ user.username }} <br />
Gender: {{ profile.gender }} <br />
-Date of Birth: {{ profile.dob }}<br />
-<hr />
-About Me: {{ profile.aboutme|linebreaksbr }} <br />
+
+{% if medium %}
+ <hr />
+ Username: {{ user.username }} <br />
+{% endif %}
+
+{% if all %}
+ Date of Birth: {{ profile.dob }}<br />
+{% endif %}
+
+{% if medium %}
<hr />
+<h4>Contact Details</h4>
+Email: {{ profile_user.email }}<br />
+{% endif %}
+
+{% if all %}
Address: {{ profile.address|linebreaksbr }} <br />
-<hr />
Phone Number: {{ profile.phonenum }} <br />
-<a href="{% url edit_profile %}">Edit profile</a>
+{% endif %}
+
+{% if medium %}
+ <hr />
+{% endif %}
+
+About: {{ profile.aboutme|linebreaksbr }} <br />
+
+{% if profile_user.claimed_tasks.all %}
+<hr />
+<h3>List of Tasks requested for claim but awaiting approval:</h3>
+<ul>
+ {% for task in profile_user.claimed_tasks.all %}
+ <li><a href="{% url view_task task.id %}">{{ task.title }}</a></li>
+ {% endfor %}
+</ul>
+{% endif %}
+
+{% if profile_user.selected_tasks.all %}
+<hr />
+<h3>List of Tasks currently working on:</h3>
+<ul>
+ {% for task in profile_user.selected_tasks.all %}
+ <li><a href="{% url view_task task.id %}">{{ task.title }}</a></li>
+ {% endfor %}
+</ul>
+{% endif %}
+
+{% if profile_user.comp_tasks.all %}
+<hr />
+<h3>List of Tasks completed:</h3>
+<ul>
+ {% for task in profile_user.comp_tasks.all %}
+ <li><a href="{% url view_task task.id %}">{{ task.title }}</a></li>
+ {% endfor %}
+</ul>
+{% endif %}
+
+{% if profile_user.reviewing_tasks.all %}
+<hr />
+<h3>List of Tasks reviewed:</h3>
+<ul>
+ {% for task in profile_user.reviewing_tasks.all %}
+ <li><a href="{% url view_task task.id %}">{{ task.title }}</a></li>
+ {% endfor %}
+</ul>
+{% endif %}
+
{% endblock %}
diff --git a/pytask/templates/profile/view_user.html b/pytask/templates/profile/view_user.html
deleted file mode 100644
index f25c0f1..0000000
--- a/pytask/templates/profile/view_user.html
+++ /dev/null
@@ -1,52 +0,0 @@
-{% extends "base.html" %}
-
-
-{% block content %}
-Name: {{ profile.full_name }} <br />
-
-Gender: {{ profile.gender }} <br />
-<hr />
-About: {{ profile.aboutme|linebreaksbr }} <br />
-
-{{ profile_user.getprofile.full_name }}
-{% if profile_user.claimed_tasks.all %}
-<hr />
-<h3>List of Tasks requested for claim but awaiting approval:</h3>
-<ul>
- {% for task in profile_user.claimed_tasks.all %}
- <li><a href="{% url view_task task.id %}">{{ task.title }}</a></li>
- {% endfor %}
-</ul>
-{% endif %}
-
-{% if profile_user.selected_tasks.all %}
-<hr />
-<h3>List of Tasks currently working on:</h3>
-<ul>
- {% for task in profile_user.selected_tasks.all %}
- <li><a href="{% url view_task task.id %}">{{ task.title }}</a></li>
- {% endfor %}
-</ul>
-{% endif %}
-
-{% if profile_user.comp_tasks.all %}
-<hr />
-<h3>List of Tasks completed:</h3>
-<ul>
- {% for task in profile_user.comp_tasks.all %}
- <li><a href="{% url view_task task.id %}">{{ task.title }}</a></li>
- {% endfor %}
-</ul>
-{% endif %}
-
-{% if profile_user.reviewing_tasks.all %}
-<hr />
-<h3>List of Tasks reviewed:</h3>
-<ul>
- {% for task in profile_user.reviewing_tasks.all %}
- <li><a href="{% url view_task task.id %}">{{ task.title }}</a></li>
- {% endfor %}
-</ul>
-{% endif %}
-
-{% endblock %}