summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornishanth2010-02-25 17:00:18 +0530
committernishanth2010-02-25 17:00:18 +0530
commitb85600400bfff4f467b20e71db9cd5936c2056d4 (patch)
tree508f5e54b280d090a02accb2c87372e42fd86ea1
parent20ef35279dcc5c1e5b9cfac5830739c9f7c221ef (diff)
downloadpytask-b85600400bfff4f467b20e71db9cd5936c2056d4.tar.gz
pytask-b85600400bfff4f467b20e71db9cd5936c2056d4.tar.bz2
pytask-b85600400bfff4f467b20e71db9cd5936c2056d4.zip
added events addCredits and assignCredits and modified assign_credits view accordingly.
-rw-r--r--taskapp/events/task.py18
-rw-r--r--taskapp/views/task.py8
-rw-r--r--templates/task/assigncredits.html2
-rw-r--r--templates/task/view.html4
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 %}
-
+ <a href="/task/view/tid={{task.id}}">Click here</a> to return to the task.
{% if prev_credits %}
<hr />
<br/>Previous credits:<br />
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 %}
- <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 />