From b85600400bfff4f467b20e71db9cd5936c2056d4 Mon Sep 17 00:00:00 2001 From: nishanth Date: Thu, 25 Feb 2010 17:00:18 +0530 Subject: added events addCredits and assignCredits and modified assign_credits view accordingly. --- taskapp/events/task.py | 18 ++++++++++++++++++ taskapp/views/task.py | 8 +++----- templates/task/assigncredits.html | 2 +- templates/task/view.html | 4 +++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/taskapp/events/task.py b/taskapp/events/task.py index 4f7f76f..ce9c1d9 100644 --- a/taskapp/events/task.py +++ b/taskapp/events/task.py @@ -189,3 +189,21 @@ def completeTask(main_task): 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 --git a/taskapp/views/task.py b/taskapp/views/task.py index b05a8f6..37831cc 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, 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 @@ def assign_credits(request, tid): context = { 'user':user, + 'task':task, 'prev_credits':prev_credits, 'form':form, } @@ -420,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 diff --git a/templates/task/assigncredits.html b/templates/task/assigncredits.html index 1272367..21d8807 100644 --- a/templates/task/assigncredits.html +++ b/templates/task/assigncredits.html @@ -3,7 +3,7 @@ {{task.title}} {% endblock %} {% block content %} - + Click here to return to the task. {% if prev_credits %}

Previous credits:
diff --git a/templates/task/view.html b/templates/task/view.html index 4ea4877..c22284c 100644 --- a/templates/task/view.html +++ b/templates/task/view.html @@ -4,7 +4,9 @@ {% endblock %} {% block content %} {% if task_viewable %} - Edit task + {% if is_mentor %} + Edit task + {% endif %}

{{ task.title }}


created by {{ task.created_by.username }} on {{ task.creation_datetime.ctime }}
-- cgit