view_work is now working
authorNishanth Amuluru <nishanth@fossee.in>
Tue, 11 Jan 2011 16:51:07 +0530
changeset 382 daca865314e7
parent 381 da4c6b1cec7d
child 383 4252da60a4ef
view_work is now working
pytask/taskapp/urls.py
pytask/taskapp/views.py
pytask/templates/task/view.html
pytask/templates/task/view_work.html
--- a/pytask/taskapp/urls.py	Tue Jan 11 14:57:16 2011 +0530
+++ b/pytask/taskapp/urls.py	Tue Jan 11 16:51:07 2011 +0530
@@ -3,7 +3,8 @@
 from pytask.taskapp.views import create_task, view_task, claim_task, \
         select_user, edit_task, create_textbook, view_textbook, \
         browse_tasks, edit_textbook, approve_task, approved_task,\
-        browse_textbooks, approve_textbook, approved_textbook, addreviewer
+        browse_textbooks, approve_textbook, approved_textbook, addreviewer,\
+        view_report, view_work
 
 from pytask.views import under_construction
 
@@ -17,6 +18,8 @@
             (r'^approve/tid=(\w+)$', approve_task),
             (r'^approved/tid=(\w+)$', approved_task),
             (r'^addreviewer/tid=(\w+)$', addreviewer),
+            (r'^view/work/tid=(\w+)$', view_work),
+            (r'^view/report/rid=(\w+)$', view_report),
             (r'^browse/$', browse_tasks),
 
             (r'^textbook/create/$', create_textbook),
--- a/pytask/taskapp/views.py	Tue Jan 11 14:57:16 2011 +0530
+++ b/pytask/taskapp/views.py	Tue Jan 11 16:51:07 2011 +0530
@@ -280,8 +280,9 @@
     reviewer_choices = User.objects.filter(is_active=True).\
                                            exclude(reviewing_tasks__uniq_key=tid).\
                                            exclude(claimed_tasks__uniq_key=tid).\
-                                           exclude(approved_tasks__uniq_key=tid).\
+                                           exclude(selected_tasks__uniq_key=tid).\
                                            exclude(created_tasks__uniq_key=tid)
+
     choices = ((a_user.id,a_user.username) for a_user in reviewer_choices)
     label = "Reviewer"
 
@@ -302,6 +303,41 @@
         context.update({"form": form})
         return render_to_response("task/addreviewer.html", context)
 
+def view_work(request, tid):
+
+    task_url = "/task/view/tid=%s"%tid
+    task = getTask(tid)
+
+    user = request.user
+    old_reports = task.reports.all()
+
+    context = {"task": task,
+               "old_reports": old_reports,
+              }
+
+    if not user.is_authenticated():
+        return render_to_response("/task/view_work.html", context)
+
+    profile = user.get_profile()
+
+    context.update({"user": user,
+                    "profile": profile,
+                   })
+
+    context.update(csrf(request))
+
+    working_users = task.selected_users.all()
+    is_working = True if user in working_users else False
+
+    context.update({"is_working": is_working})
+
+    return render_to_response("task/view_work.html", context)
+
+@login_required
+def view_report(request, rid):
+    pass
+
+
 @login_required
 def create_textbook(request):
 
--- a/pytask/templates/task/view.html	Tue Jan 11 14:57:16 2011 +0530
+++ b/pytask/templates/task/view.html	Tue Jan 11 16:51:07 2011 +0530
@@ -87,13 +87,7 @@
 	<a href="/task/claim/tid={{task.uniq_key}}">View claims</a>
     {% endif %}
 
-    {% if can_assign_pynts %}
-        <a href="/task/assignpynts/tid={{task.uniq_key}}">Request assign pynts and mark the task as complete</a>
-    {% endif %}
-    
-    {% if is_selected %}
-        <a href="/task/report/tid={{task.uniq_key}}">Submit Work</a>
-    {% endif %}
+    <a href="/task/view/work/tid={{task.uniq_key}}">View submitted work reports</a>
     
         <hr />
     {% if comments %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pytask/templates/task/view_work.html	Tue Jan 11 16:51:07 2011 +0530
@@ -0,0 +1,23 @@
+{% extends 'base.html' %}
+{% block title %}
+    {{task.title}}
+{% endblock %}
+{% block content %}
+{% if not old_reports %}
+There are no reports submitted as of now<br />
+{% else %}
+<table >
+{% for rep in old_reports %}
+<tr>
+	<td>{{rep.submitted_by}}</td>
+	<td><a href="/task/view/report/rid={{rep.uniq_key}}">{{rep.data}}</a></td>
+	<td><a href="{{rep.attachment.url}}">{{rep.attachment.name}}</a> </td>
+</tr>
+{% endfor %}
+</table>
+{% endif %}
+{% if is_working %}
+<a href="/task/submit/report/tid={{task.uniq_key}}">Submit report</a>
+<hr />
+{% endif %}
+{% endblock %}