diff options
author | nishanth | 2010-02-24 13:14:00 +0530 |
---|---|---|
committer | nishanth | 2010-02-24 13:14:00 +0530 |
commit | 490bc24f10f1f819069f4e28cd986736f2905816 (patch) | |
tree | 1c4cc7d55aa288ed7c9841606cfaed1d9330df9c | |
parent | f98d30aa38f712f672947c6920920625e4c391eb (diff) | |
download | pytask-490bc24f10f1f819069f4e28cd986736f2905816.tar.gz pytask-490bc24f10f1f819069f4e28cd986736f2905816.tar.bz2 pytask-490bc24f10f1f819069f4e28cd986736f2905816.zip |
modified view task template and view to suit new design.
-rw-r--r-- | taskapp/views/task.py | 25 | ||||
-rw-r--r-- | templates/task/view.html | 108 |
2 files changed, 82 insertions, 51 deletions
diff --git a/taskapp/views/task.py b/taskapp/views/task.py index 372e361..3e5119b 100644 --- a/taskapp/views/task.py +++ b/taskapp/views/task.py @@ -5,7 +5,7 @@ from django.shortcuts import render_to_response, redirect from pytask.taskapp.models import User, Task, Comment, Claim from pytask.taskapp.forms.task import TaskCreateForm, AddMentorForm, AssignTaskForm -from pytask.taskapp.events.task import createTask, addMentor, publishTask, addSubTask, addClaim, assignTask, getTask +from pytask.taskapp.events.task import createTask, addMentor, publishTask, addSubTask, addClaim, assignTask, getTask, updateTask from pytask.taskapp.views.user import show_msg ## everywhere if there is no task, django should display 500 message.. but take care of that in sensitive views like add mentor and all @@ -33,25 +33,31 @@ def view_task(request, tid): task = getTask(tid) comments = Comment.objects.filter(task=task) mentors = task.mentors.all() + subs = task.subs.all() + deps = task.deps.all() errors = [] is_guest = True if not user.is_authenticated() else False is_mentor = True if user in task.mentors.all() else False - - task_claimable = True if task.status in ["OP", "WR"] else False - context = {'user':user, 'task':task, 'comments':comments, 'mentors':mentors, + 'subs':subs, + 'deps':deps, 'is_guest':is_guest, 'is_mentor':is_mentor, 'errors':errors, - } - - assigned_users = task.assigned_users.all() - if assigned_users: - context['assigned_users'] = assigned_users + } + + context['task_viewable'] = True if ( task.status not in ["UP", "DL"] ) or is_mentor else False + context['task_claimable'] = True if task.status in ["OP", "WR"] 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() if request.method == 'POST': if not is_guest: @@ -93,6 +99,7 @@ def create_task(request): return render_to_response('task/create.html',{'form':form, 'error_msg':error_msg}) addMentor(task, user) + updateTask(task,tags_field=data['tags_field']) if publish: publishTask(task) task_url = '/task/view/tid=%s'%task.id return redirect(task_url) diff --git a/templates/task/view.html b/templates/task/view.html index 2343b20..7e03cb1 100644 --- a/templates/task/view.html +++ b/templates/task/view.html @@ -3,49 +3,73 @@ {{task.title}} {% endblock %} {% block content %} - <a href="/task/browse/">Browse tasks</a> - <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.ctime }}<br /> - Mentors: - {% for mentor in mentors %} - <a href="/user/view/uid={{mentor.id}}">{{mentor.username}}|</a> - {% endfor %} - {% if is_mentor %} - <br /><a href="/task/addmentor/tid={{task.id}}">Add another Mentor to this task</a><br /> - edit task goes here and it should contain all those add subs and add deps depending on availability<br /> - {% endif %} - <hr> - <br />Description:<br /> - <br />{{ task.desc }}<br /> - <hr> - status of task is {{task.status}}<br /> - {% if assigned_users %} - Users working on this task: - {% for user in assigned_users %} - <a href="/user/view/uid={{user.id}}">{{user.username}}</a>| - {% endfor %} - <br /> - {% endif %} - {% if not is_guest %} - <a href="/task/claim/tid={{task.id}}">View claims</a><br /> - {% endif %} - - {% if comments %} - <hr /> - <br/>comments:<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 /> + {% if task_viewable %} + <a href="/task/browse/">Browse tasks</a> + <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.ctime }}<br /> + Mentors: + {% for mentor in mentors %} + <a href="/user/view/uid={{mentor.id}}">{{mentor.username}}|</a> {% endfor %} - {% endif %} + {% if can_mod_mentors %} + <br /><a href="/task/addmentor/tid={{task.id}}">Add another Mentor to this task</a><br /> + edit task goes here and it should contain all those add subs and add deps depending on availability<br /> + {% endif %} + + {% if deps %} + <br />The task has following dependencies + {% for dep in deps %} + <a href="/task/view/tid={{dep.id}}">{{dep.title}}</a><br /> + {% endfor %} + {% if can_mod_tasks %} + <a href="/task/addtask/tid={{task.id}}">add more tasks</a> + <a href="/task/remtask/tid={{task.id}}">remove an existing task</a> + {% endif %} + {% else %} + {%if can_mod_tasks %} + <a href="/task/addtask/tid={{task.id}}">add a subtask/dependency </a> + {%endif%} + {% endif %} + + <hr> + <br />Description:<br /> + <br />{{ task.desc }}<br /> + <hr> + + status of task is {{task.status}}<br /> + {% if assigned_users %} + Users working on this task: + {% for user in assigned_users %} + <a href="/user/view/uid={{user.id}}">{{user.username}}</a>| + {% endfor %} + <br /> + {% endif %} + {%if can_assign_credits%} + <a href="/task/assigncredits/tid={{task.id}}">Assign credits</a> + {%endif%} + {% if not is_guest %} + <a href="/task/claim/tid={{task.id}}">View claims</a><br /> + {% endif %} + + {% if comments %} + <hr /> + <br/>comments:<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 /> + {% endfor %} + {% endif %} - {% if not is_guest %} - <br />Add comment:<br /> - <form action="" method="post"> - <!-- we might even want to use forms here --> - <textarea name="data"></textarea><br /> - <input type="submit" value="Submit"> - </form> + {% if not is_guest %} + <br />Add comment:<br /> + <form action="" method="post"> + <!-- we might even want to use forms here --> + <textarea name="data"></textarea><br /> + <input type="submit" value="Submit"> + </form> + {% endif %} + {% else %} + You are not authorised to view this task. <a href="/task/browse/">click here</a> to return to browsing the tasks. {% endif %} {% endblock %} |