# HG changeset patch # User Nishanth Amuluru # Date 1294542448 -19800 # Node ID 4cc40503bf3c1ff5df7870b0da3d5a8db19dc26f # Parent 1cc8d0b2eefb1d18bcfccf46c0a2a8b964e3c4ac view task is now in some shape atleast diff -r 1cc8d0b2eefb -r 4cc40503bf3c pytask/taskapp/views.py --- a/pytask/taskapp/views.py Sun Jan 09 00:53:51 2011 +0530 +++ b/pytask/taskapp/views.py Sun Jan 09 08:37:28 2011 +0530 @@ -63,6 +63,10 @@ task = getTask(tid) user = request.user + + if not user.is_authenticated(): + return render_to_response("/task/view.html", {"task": task}) + profile = user.get_profile() context = {"user": user, @@ -75,38 +79,39 @@ if task.status == "DL": return show_msg(user, 'This task no longer exists', '/task/browse/','browse the tasks') - comments = task.comments.filter(is_deleted=False).order_by('comment_datetime') - reviewers = task.reviewers.all() + task_viewable = True if ( task.status != "UP" ) or profile.rights != "CT"\ + else False + if not task_viewable: + return show_msg(user, "You are not authorised to view this task", "/task/browse/", "browse the tasks") - is_guest = True if not user.is_authenticated() else False + reviewers = task.reviewers.all() is_reviewer = True if user in task.reviewers.all() else False + comments = task.comments.filter(is_deleted=False).order_by('comment_datetime') - context.update({'is_guest':is_guest, - 'is_reviewer':is_reviewer, + context.update({'is_reviewer':is_reviewer, 'comments':comments, 'reviewers':reviewers, }) claimed_users = task.claimed_users.all() - + selected_users = task.selected_users.all() -# is_requested_reviewer = True if user.is_authenticated() and user.request_sent_to.filter(is_valid=True,is_replied=False,role="MT",task=task) else False -# task_viewable = True if ( task.status != "UP" ) or is_reviewer or is_requested_reviewer else False -# if not task_viewable: -# return show_msg(user, "You are not authorised to view this task", "/task/browse/", "browse the tasks") + is_creator = True if user == task.created_by else False + has_claimed = True if user in claimed_users else False -# context['is_requested_reviewer'] = is_requested_reviewer - - context['can_publish'] = True if task.status == "UP" and user == task.created_by else False - context['can_edit'] = True if task.status == "UP" and is_reviewer else False + context['is_selected'] = True if user in selected_users else False + context['can_approve'] = True if task.status == "UP" and\ + profile.rights in ["MG", "DC"]\ + else False + context['can_edit'] = True if is_creator else False context['can_close'] = True if task.status not in ["UP", "CD", "CM"] and is_reviewer else False - context['can_delete'] = True if task.status == "UP" and user == task.created_by else False - - context['can_mod_reviewers'] = True if task.status in ["UP", "OP", "LO", "WR"] and is_reviewer else False - context['can_mod_tasks'] = True if task.status in ["UP", "OP", "LO"] and is_reviewer else False + context['can_delete'] = True if task.status == "UP" and is_creator else False context['can_assign_pynts'] = True if task.status in ["OP", "WR"] and is_reviewer else False - context['task_claimable'] = True if task.status in ["OP", "WR"] and not is_guest else False + context['task_claimable'] = True if task.status in ["OP", "WR"] else False + + context['can_comment'] = True if task.status != "UP" or\ + profile.rights!="CT" else False # if task.status == "CD": # context['closing_notification'] = Notification.objects.filter(task=task,role="CD")[0] @@ -116,20 +121,17 @@ # context['assigned_users'] = task.assigned_users.all() if request.method == 'POST': - if not is_guest: - form = TaskCommentForm(request.POST) - if form.is_valid(): - data = form.cleaned_data['data'] - new_comment = TaskComment(task=task, data=data, - uniq_key=make_key(TaskComment), - commented_by=user, comment_datetime=datetime.now()) - new_comment.save() - return redirect(task_url) - else: - context['form'] = form - return render_to_response('task/view.html', context) + form = TaskCommentForm(request.POST) + if form.is_valid(): + data = form.cleaned_data['data'] + new_comment = TaskComment(task=task, data=data, + uniq_key=make_key(TaskComment), + commented_by=user, comment_datetime=datetime.now()) + new_comment.save() + return redirect(task_url) else: - return redirect(task_url) + context['form'] = form + return render_to_response('task/view.html', context) else: form = TaskCommentForm() context['form'] = form diff -r 1cc8d0b2eefb -r 4cc40503bf3c pytask/templates/task/view.html --- a/pytask/templates/task/view.html Sun Jan 09 00:53:51 2011 +0530 +++ b/pytask/templates/task/view.html Sun Jan 09 08:37:28 2011 +0530 @@ -9,7 +9,7 @@ Edit task {% endif %} - {% if can_publish %} + {% if can_approve %} Approve task {% endif %} @@ -24,15 +24,18 @@
created by {{ task.created_by.username }} on {{task.creation_datetime|date:"D d M Y"}} at {{task.creation_datetime|time:"H:i"}}
- {% ifequal task.status "UP" %} - Task can be viewed by: - {% else %} - Reviewers: - {% endifequal %} - - {% for reviewer in reviewers %} - {{reviewer.username}} - {% endfor %} + {% if reviewers %} + {% ifequal task.status "UP" %} + Task can be viewed by: + {% else %} + Reviewers: + {% endifequal %} + + {% for reviewer in reviewers %} + {{reviewer.username}} + {% endfor %} + {% endif %} + {% if can_mod_reviewers %} @@ -57,6 +60,7 @@ {% endif %} + - {% if assigned_users %} + {% if selected_users %} Users working on this task: {% for user in assigned_users %} {{user.username}} @@ -88,51 +93,36 @@
{% endif %} + {% if task_claimable %} + View claims + {% endif %} + {% if can_assign_pynts %} - View/Assign pynts + Request assign pynts and mark the task as complete {% endif %} - {% if task_claimable %} - - {% if is_reviewer %} - View claims - {% else %} + + {% if is_selected %} Submit Work - Claim the task - {% endif %} {% endif %} {% if comments %}
comments:

{% for comment in comments %} - {{ comment.created_by.username }} + {{ comment.commented_by.username }} on {{ comment.comment_datetime|date:"D d M Y"}} at {{comment.comment_datetime|time:"H:i"}} wrote:
{{ comment.data|linebreaksbr }}

{% endfor %} {% endif %} - {% if not is_guest %} -
- {% if error_msg %} - {{error_msg}}
- {% endif %} - {% ifnotequal task.status "UP" %} - Add comment:
-
- {% csrf_token %} - {{form.as_p}} - -
- {% else %} - {% if is_reviewer %} - Add comment:
-
- {% csrf_token %} - {{form.as_p}} - -
- {% endif %} - {% endifnotequal %} + {% if can_comment %} + Add comment:
+
+ {% csrf_token %} + {{form.as_p}} + +
{% endif %} + {% endblock %}