added events addCredits and assignCredits and modified assign_credits view accordingly.
--- 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()
--- 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
--- 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 %}
-
+ <a href="/task/view/tid={{task.id}}">Click here</a> to return to the task.
{% if prev_credits %}
<hr />
<br/>Previous credits:<br />
--- a/templates/task/view.html Thu Feb 25 16:37:46 2010 +0530
+++ b/templates/task/view.html Thu Feb 25 17:00:18 2010 +0530
@@ -4,7 +4,9 @@
{% endblock %}
{% block content %}
{% if task_viewable %}
- <a href="/task/edit/tid={{task.id}}">Edit task</a>
+ {% if is_mentor %}
+ <a href="/task/edit/tid={{task.id}}">Edit task</a>
+ {% endif %}
<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 />