# HG changeset patch # User nishanth # Date 1267097418 -19800 # Node ID 2881ed1c52b0116aa688ac260792f96155faabc1 # Parent e4034904f82edf2b9cf6e3a0981148a7bee5b74f added events addCredits and assignCredits and modified assign_credits view accordingly. diff -r e4034904f82e -r 2881ed1c52b0 taskapp/events/task.py --- a/taskapp/events/task.py Thu Feb 25 16:37:46 2010 +0530 +++ b/taskapp/events/task.py Thu Feb 25 17:00:18 2010 +0530 @@ -189,3 +189,21 @@ main_task.status = "CP" main_task.save() + +def assignCredits(task, given_by, given_to, points): + """ make a proper request object. + """ + + addCredits(task, given_by, given_to, points) + +def addCredits(task, given_by, given_to, points): + """ add credit to the credits model. + """ + + creditobj = Credit() + creditobj.task = task + creditobj.given_by = given_by + creditobj.given_to = given_to + creditobj.points = points + creditobj.given_time = datetime.now() + creditobj.save() diff -r e4034904f82e -r 2881ed1c52b0 taskapp/views/task.py --- a/taskapp/views/task.py Thu Feb 25 16:37:46 2010 +0530 +++ b/taskapp/views/task.py Thu Feb 25 17:00:18 2010 +0530 @@ -5,7 +5,7 @@ from pytask.taskapp.models import User, Task, Comment, Claim, Credit 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 +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 @@ -408,6 +408,7 @@ context = { 'user':user, + 'task':task, 'prev_credits':prev_credits, 'form':form, } @@ -420,10 +421,7 @@ 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 diff -r e4034904f82e -r 2881ed1c52b0 templates/task/assigncredits.html --- a/templates/task/assigncredits.html Thu Feb 25 16:37:46 2010 +0530 +++ b/templates/task/assigncredits.html Thu Feb 25 17:00:18 2010 +0530 @@ -3,7 +3,7 @@ {{task.title}} {% endblock %} {% block content %} - + Click here to return to the task. {% if prev_credits %}