summaryrefslogtreecommitdiff
path: root/taskapp/views
diff options
context:
space:
mode:
authoranoop2010-02-25 17:37:14 +0530
committeranoop2010-02-25 17:37:14 +0530
commita725bee741ac5391d7b103aa19e08a5cdff74658 (patch)
treec85fbe3a9cd206a87d96aaa0c16759de2223af89 /taskapp/views
parent0f44b2c832a6a8266e4337b0a32190c3864633c6 (diff)
parentb85600400bfff4f467b20e71db9cd5936c2056d4 (diff)
downloadpytask-a725bee741ac5391d7b103aa19e08a5cdff74658.tar.gz
pytask-a725bee741ac5391d7b103aa19e08a5cdff74658.tar.bz2
pytask-a725bee741ac5391d7b103aa19e08a5cdff74658.zip
merged
Diffstat (limited to 'taskapp/views')
-rw-r--r--taskapp/views/task.py53
1 files changed, 47 insertions, 6 deletions
diff --git a/taskapp/views/task.py b/taskapp/views/task.py
index 8857d9e..37831cc 100644
--- a/taskapp/views/task.py
+++ b/taskapp/views/task.py
@@ -4,8 +4,8 @@ from django.http import HttpResponse
from django.shortcuts import render_to_response, redirect
from pytask.taskapp.models import User, Task, Comment, Claim, Credit
-from pytask.taskapp.forms.task import TaskCreateForm, AddMentorForm, AddTaskForm, ChoiceForm, AssignCreditForm
-from pytask.taskapp.events.task import createTask, addMentor, publishTask, addSubTask, addDep, addClaim, assignTask, getTask, updateTask, removeTask
+from pytask.taskapp.forms.task import TaskCreateForm, AddMentorForm, AddTaskForm, ChoiceForm, AssignCreditForm, RemoveUserForm
+from pytask.taskapp.events.task import createTask, addMentor, publishTask, addSubTask, addDep, addClaim, assignTask, getTask, updateTask, removeTask, removeUser, assignCredits
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
@@ -301,7 +301,50 @@ def claim_task(request, tid):
else:
return show_msg('You are not logged in to view claims for this task', task_url, 'view the task')
+def rem_user(request, tid):
+ """ show a list of working users and ask for a message/reason for removing user.
+ """
+
+ task_url = "/task/view/tid=%s"%tid
+ user = request.user
+ task = getTask(tid)
+
+ is_guest = True if not user.is_authenticated() else False
+ is_mentor = True if user in task.mentors.all() else False
+
+ if (not is_guest) and is_mentor:
+
+ assigned_users = task.assigned_users.all()
+ choices = [ (_.id,_.username) for _ in assigned_users ]
+ context = {
+ 'user':user,
+ 'task':task,
+ }
+
+ if assigned_users:
+ form = RemoveUserForm(choices)
+ context['form'] = form
+ if request.method == "POST":
+ data = request.POST
+ form = RemoveUserForm(choices, data)
+ if form.is_valid():
+ data = form.cleaned_data
+ uid = data['user']
+ rem_user = User.objects.get(id=uid)
+ removeUser(task, rem_user)
+ print data['reason']
+ return redirect(task_url)
+ else:
+ context['form'] = form
+ return render_to_response('task/remove_user.html', context)
+ else:
+ return render_to_response('task/remove_user.html',context)
+ else:
+ return show_msg("There is no one working on this task to be kicked off", task_url, "view the task")
+ else:
+ return show_msg("You are not authorised to do this", task_url, "view the task")
+
def assign_task(request, tid):
""" first get the status of the task and then assign it to one of claimed users
generate list of claimed users by passing it as an argument to a function.
@@ -365,6 +408,7 @@ def assign_credits(request, tid):
context = {
'user':user,
+ 'task':task,
'prev_credits':prev_credits,
'form':form,
}
@@ -377,10 +421,7 @@ def assign_credits(request, tid):
uid = data['user']
points = data['points']
given_to = User.objects.get(id=uid)
- given_time = datetime.now()
- creditobj = Credit(task=task, given_by=user, given_to=given_to,points=points,given_time=given_time)
- ## remove the next line and add a request here
- creditobj.save()
+ assignCredits(task=task, given_by=user, given_to=given_to, points=points)
return redirect('/task/assigncredits/tid=%s'%task.id)
else:
context['form'] = form