diff options
author | nishanth | 2010-03-01 04:44:49 +0530 |
---|---|---|
committer | nishanth | 2010-03-01 04:44:49 +0530 |
commit | 22f86093698c68207c89c57c42e10fa56d73935c (patch) | |
tree | 9c3223151a8fd415f15277748e01c27e3fb6b108 | |
parent | 87428b64d3a02ce6bde8df83a0ffb115440ecaa7 (diff) | |
download | pytask-22f86093698c68207c89c57c42e10fa56d73935c.tar.gz pytask-22f86093698c68207c89c57c42e10fa56d73935c.tar.bz2 pytask-22f86093698c68207c89c57c42e10fa56d73935c.zip |
finalised the view_task page.
-rw-r--r-- | taskapp/events/task.py | 11 | ||||
-rw-r--r-- | taskapp/utilities/notification.py | 12 | ||||
-rw-r--r-- | taskapp/views/task.py | 22 | ||||
-rw-r--r-- | taskapp/views/user.py | 7 | ||||
-rw-r--r-- | templates/task/assign.html | 1 | ||||
-rw-r--r-- | templates/task/claim.html | 32 | ||||
-rw-r--r-- | templates/task/view.html | 110 |
7 files changed, 115 insertions, 80 deletions
diff --git a/taskapp/events/task.py b/taskapp/events/task.py index 2d5cadf..5d018e4 100644 --- a/taskapp/events/task.py +++ b/taskapp/events/task.py @@ -27,8 +27,11 @@ def publishTask(task, rem_mentors=True, rem_comments=True): task.comment_set.update(deleted_by=task.created_by) task.published_datetime = datetime.now() - task.save() + + pending_requests = task.request_task.filter(is_valid=True, is_replied=False) + pending_requests.update(is_valid=False) + return task def addSubTask(main_task, sub_task): @@ -233,12 +236,12 @@ def closeTask(task, closed_by, reason=None): ## generate notifications here for a_user in task.assigned_users.all(): - create_notification(role="CD", sent_to=a_user, sent_from=marked_by, task=task) + create_notification(role="CD", sent_to=a_user, sent_from=closed_by, task=task, remarks=reason) for a_user in task.claimed_users.all(): - create_notification(role="CD", sent_to=a_user, sent_from=marked_by, task=task) + create_notification(role="CD", sent_to=a_user, sent_from=closed_by, task=task, remarks=reason) for a_mentor in task.mentors.all(): - create_notification(role="CD", sent_to=a_mentor, sent_from=marked_by, task=task) + create_notification(role="CD", sent_to=a_mentor, sent_from=closed_by, task=task, remarks=reason) diff --git a/taskapp/utilities/notification.py b/taskapp/utilities/notification.py index 75c35db..16e80a1 100644 --- a/taskapp/utilities/notification.py +++ b/taskapp/utilities/notification.py @@ -52,6 +52,9 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re elif role == "MT": + notification.task = task + notification.sent_from = sent_from + task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title) requested_mentor_url = '<a href="/user/view/uid=%s">%s</a>'%(requested_by.id, requested_by.username) new_mentor = sent_from @@ -70,6 +73,8 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re elif role in ["DV", "MG", "AD"]: + notification.sent_from = sent_from + accepting_user = sent_from user_url = '<a href="/user/view/uid=%s">%s</a>'%(accepting_user.id, accepting_user.username) ## i mean the user who has accepted it requested_by_url = '<a href="/user/view/uid=%s">%s</a>'%(requested_by.id, requested_by.username) @@ -88,6 +93,7 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re elif role == "NT": + notification.task = task new_mentor = sent_to mentor_learn_url = '<sup><a href="/about/mentor">learn more</a></sup>' task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title) @@ -110,6 +116,12 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re notification.message += "Happy Mentoring." elif role in ["CM", "CD"]: + + notification.sent_from = sent_from + notification.role = role + notification.task = task + notification.remarks = remarks + mentor = sent_from mentor_url = '<a href="/user/view/uid=%s">%s</a>'%(mentor.id, mentor.username) task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title) diff --git a/taskapp/views/task.py b/taskapp/views/task.py index eae2720..02bfb62 100644 --- a/taskapp/views/task.py +++ b/taskapp/views/task.py @@ -3,7 +3,7 @@ from datetime import datetime from django.http import HttpResponse, Http404 from django.shortcuts import render_to_response, redirect -from pytask.taskapp.models import User, Task, Comment, Claim, Request +from pytask.taskapp.models import User, Task, Comment, Claim, Request, Notification from pytask.taskapp.utilities.task import getTask 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 @@ -80,15 +80,24 @@ def view_task(request, tid): 'is_mentor':is_mentor, } - context['can_publish'] = True if task.status == "UP" and user == task.created_by else False context['task_viewable'] = True if ( task.status != "UP" ) or is_mentor else False - context['task_claimable'] = True if task.status in ["OP", "WR"] else False + + context['can_publish'] = True if task.status == "UP" and user == task.created_by else False + context['can_edit'] = True if task.status in ["UP", "LO", "OP"] and is_mentor else False + context['can_close'] = True if task.status not in ["UP", "CD", "CM"] and is_mentor else False context['can_mod_mentors'] = True if task.status in ["UP", "OP", "LO", "WR"] and is_mentor else False context['can_mod_tasks'] = True if task.status in ["UP", "OP", "LO"] and is_mentor else False + context['can_assign_credits'] = True if task.status in ["OP", "WR"] and is_mentor else False - - context['assigned_users'] = task.assigned_users.all() + context['task_claimable'] = True if task.status in ["OP", "WR"] and not is_guest else False + + if task.status == "CD": + context['closing_notification'] = Notification.objects.filter(task=task,role="CD")[0] + elif task.status == "CM": + context['completed_notification'] = Notifications.objects.filter(task=task,role="CM")[0] + elif task.status == "WR": + context['assigned_users'] = task.assigned_users.all() if request.method == 'POST': if not is_guest: @@ -182,6 +191,7 @@ def add_mentor(request, tid): context = { 'user':user, + 'task':task, 'pending_requests':pending_requests, 'form':form, } @@ -420,7 +430,7 @@ def assign_task(request, tid): assignTask(task, assigned_user, user) return redirect(task_url) else: - return render_to_response('task/assign.html',{'form':form}) + return render_to_response('task/assign.html',{'user':user, 'task':task,'form':form}) elif assigned_users: return show_msg(user, 'When the no of users you need for the task is more than the no of users willing to do the task, I\'d say please re consider the task :P',task_url, 'view the task') else: diff --git a/taskapp/views/user.py b/taskapp/views/user.py index a33f25c..c55728d 100644 --- a/taskapp/views/user.py +++ b/taskapp/views/user.py @@ -38,12 +38,7 @@ def homepage(request): if not user.is_authenticated(): is_guest = True disp_num = 10 - tasks_count = Task.objects.count() - if tasks_count <= disp_num: - task_list = Task.objects.order_by('id').reverse() - else: - task_list = Task.objects.order_by('id').reverse()[:10] - + task_list = Task.objects.exclude(status="UP").order_by('published_datetime').reverse()[:10] return render_to_response('index.html', {'user':user, 'is_guest':is_guest, 'task_list':task_list}) else: diff --git a/templates/task/assign.html b/templates/task/assign.html index 232b56d..8c4e3d2 100644 --- a/templates/task/assign.html +++ b/templates/task/assign.html @@ -1,5 +1,6 @@ {% extends 'base.html' %} {% block content %} + <a href="/task/claim/tid={{task.id}}">click here</a> to return to the claims page.<br /><br /> Select a user to assign this task.<br /> <form action="" method="POST"> {{form.as_table}} diff --git a/templates/task/claim.html b/templates/task/claim.html index 47e24b7..9368da1 100644 --- a/templates/task/claim.html +++ b/templates/task/claim.html @@ -4,31 +4,35 @@ List of all the claims for the task <a href="/task/view/tid={{task.id}}">{{task.title}}</a><br /> {% for claim in claims %} <hr /> - <a href="/user/view/uid={{claim.user.id}}">{{claim.user.username}}</a> at {{claim.creation_datetime.ctime}} wrote:<br /> + <a href="/user/view/uid={{claim.user.id}}">{{claim.user.username}}</a> + on {{claim.creation_datetime|date:"D d M Y"}} at {{claim.creation_datetime|time:"H:i"}} wrote:<br /> {{claim.message}}<br /> {% endfor %} {% else %} - {% if task_claimable%} + {% if task_claimable %} There are no claims for this task yet.<br /> + Be the first to claim the task.<br /> {% else %} This task cannot be claimed right now. {% endif %} - <a href="/task/view/tid={{task.id}}">Click here</a> to return to the task. + <a href="/task/view/tid={{task.id}}">Click here</a> to return to the task.<br /> {% endif %} {% if task_claimed and is_mentor %} <a href="/task/assign/tid={{task.id}}">Select a user to assign the work.</a> {% endif %} {% if user_can_claim %} - <hr /> - {% if errors %} - {% for error in errors %} - {{error}}<br /> - {% endfor %} - {% endif %} - Claim the task:<br /> - <form action="" method="post"> - <textarea name="message"></textarea><br /> - <input type="submit" value="Submit Claim"> - </form> + {% if errors %} + {% for error in errors %} + {{error}}<br /> + {% endfor %} + {% endif %} + + <hr /> + Please note that you can claim only once and so write your proposal carefully.<br /> + Claim proposal:<br /> + <form action="" method="post"> + <textarea name="message"></textarea><br /> + <input type="submit" value="Submit Claim"> + </form> {% endif %} {% endblock %} diff --git a/templates/task/view.html b/templates/task/view.html index 1b25927..d30290e 100644 --- a/templates/task/view.html +++ b/templates/task/view.html @@ -5,40 +5,46 @@ {% block content %} {% if task_viewable %} <h3>{{ task.title }}</h3><br /> - <!-- we have to write our own datetime.strftime filter and use in the next line --> - created by <a href="/user/view/uid={{ task.created_by.id }}">{{ task.created_by.username }}</a> - on {{task.creation_datetime|date:"D d M Y"}} at {{task.creation_datetime|time:"H:i"}}<br /> - {% if is_mentor %} + {% if can_edit %} + <a href="/task/edit/tid={{task.id}}">Edit task</a> + {% endif %} - {% ifequal task.status "UP" %} - <a href="/task/edit/tid={{task.id}}">Edit task</a> - {% else %} - <a href="/task/close/tid={{task.id}}">Close this task</a> - {% endifequal %} - - {% if can_publish %} - <a href="/task/publish/tid={{task.id}}">Publish task</a> - {% endif %} - <br /> + {% if can_close %} + <a href="/task/close/tid={{task.id}}">Close this task</a> {% endif %} + + {% if can_publish %} + <a href="/task/publish/tid={{task.id}}">Publish task</a> + {% endif %} + + <hr />created by <a href="/user/view/uid={{ task.created_by.id }}">{{ task.created_by.username }}</a> + on {{task.creation_datetime|date:"D d M Y"}} at {{task.creation_datetime|time:"H:i"}}<br /> {% ifequal task.status "UP" %} Task can be viewed by: {% else %} Mentors: {% endifequal %} + {% for mentor in mentors %} - <a href="/user/view/uid={{mentor.id}}">{{mentor.username}}|</a> + <a href="/user/view/uid={{mentor.id}}">{{mentor.username}}</a> {% endfor %} + {% if can_mod_mentors %} <a href="/task/addmentor/tid={{task.id}}"> {% ifequal task.status "UP" %} Request others to view/edit the task {% else %} Add another Mentor to this task - {% endifequal %}</a><br /> + {% endifequal %}</a> {% endif %} + <br /> + + <hr /> + <b>Description:</b><br /> + {{ task.desc }} + <hr /> {% if deps %} @@ -75,51 +81,55 @@ {% endif %} {% endif %} + {% ifequal task.status "CD" %} + Task has been closed by <a href="/user/view={{closing_notification.sent_from.id}}">{{closing_notification.sent_from.username}}</a> + on {{closing_notification.sent_date|date:"D d M Y"}} at {{closing_notification.sent_date|time:"H:i"}}<br /> + <b>Reason: </b>{{closing_notification.remarks}}<br /> + {% endifequal %} - <hr> - <br />Description:<br /> - <br />{{ task.desc }}<br /> - <hr> - - {% ifnotequal task.status "CM" %} - {% if assigned_users %} - Users working on this task: - {% for user in assigned_users %} - <a href="/user/view/uid={{user.id}}">{{user.username}}</a>| - {% endfor %} - {% if is_mentor %} - <a href="/task/remuser/tid={{task.id}}">Remove an existing user</a> - <br /> - {% endif %} - {% else %} - There are no users currently working on this task.<br /> - {% endif %} - {% if can_assign_credits %} - <a href="/task/assigncredits/tid={{task.id}}">View/Assign credits</a> - {% endif %} - {% if not is_guest and task_claimable %} - <a href="/task/claim/tid={{task.id}}">View claims</a><br /> + {% ifequal task.status "CM" %} + Task has been marked complete by <a href="/user/view={{completed_notification.sent_from.id}}"> + {{completed_notification.sent_from.username}}</a> + on {{completed_notification.sent_date|date:"D d M Y"}} at {{completed_notification.sent_date|time:"H:i"}}<br /> + {% endifequal %} + + {% ifequal task.status "OP" %} + <br />There are no users working on this task.<br /> + {% endifequal %} + + {% if assigned_users %} + Users working on this task: + {% for user in assigned_users %} + <a href="/user/view/uid={{user.id}}">{{user.username}}</a> + {% endfor %} + {% if is_mentor %} + <a href="/task/remuser/tid={{task.id}}">Remove an existing user</a> {% endif %} - {% else %} - {% ifequal task.status "CD" %} - The task has been closed by .. due to .. - {% else %} - The task is complete. - {% endifequal %} - {% endifnotequal %} + <br /> + {% endif %} + + {% if can_assign_credits %} + <a href="/task/assigncredits/tid={{task.id}}">View/Assign credits</a> + {% endif %} + + {% if task_claimable %} + <a href="/task/claim/tid={{task.id}}">View claims</a> + {% endif %} {% if comments %} <hr /> - <br/>comments:<br /> + comments:<br /><br /> {% for comment in comments %} - <br /><a href="/user/view/uid={{comment.created_by.id}}">{{ comment.created_by.username }}</a> at {{ comment.creation_datetime.ctime }} wrote:<br /> - {{ comment.data }}<br /> + <a href="/user/view/uid={{comment.created_by.id}}">{{ comment.created_by.username }}</a> + on {{ comment.creation_datetime|date:"D d M Y"}} at {{comment.creation_datetime|time:"H:i"}} wrote:<br /> + {{ comment.data }}<br /><br /> {% endfor %} {% endif %} {% if not is_guest %} + <hr /> {% ifnotequal task.status "CM" %} - <br />Add comment:<br /> + Add comment:<br /> <form action="" method="post"> <!-- we might even want to use forms here --> <textarea name="data"></textarea><br /> |