# HG changeset patch
# User nishanth
# Date 1267377545 -19800
# Node ID 925af1b4ee65e83daf6699c78149846941a727ca
# Parent a65e1ef725dd5f90fe28986df93b0809c1980728
ditchaxed credit model.
diff -r a65e1ef725dd -r 925af1b4ee65 taskapp/admin.py
--- a/taskapp/admin.py Sun Feb 28 20:49:59 2010 +0530
+++ b/taskapp/admin.py Sun Feb 28 22:49:05 2010 +0530
@@ -1,11 +1,10 @@
from django.contrib import admin
-from pytask.taskapp.models import Profile, Task, Credit, Comment, Claim, Notification, Request
+from pytask.taskapp.models import Profile, Task, Comment, Claim, Notification, Request
admin.site.register(Profile)
admin.site.register(Task)
admin.site.register(Comment)
-admin.site.register(Credit)
admin.site.register(Claim)
admin.site.register(Notification)
admin.site.register(Request)
diff -r a65e1ef725dd -r 925af1b4ee65 taskapp/events/request.py
--- a/taskapp/events/request.py Sun Feb 28 20:49:59 2010 +0530
+++ b/taskapp/events/request.py Sun Feb 28 22:49:05 2010 +0530
@@ -1,6 +1,6 @@
from datetime import datetime
from pytask.taskapp.models import Profile
-from pytask.taskapp.events.task import addCredits, addMentor
+from pytask.taskapp.events.task import addMentor
from pytask.taskapp.events.user import changeRole
from pytask.taskapp.utilities.notification import create_notification
@@ -25,12 +25,9 @@
pynts = request_obj.pynts
receiving_user = request_obj.receiving_user
requested_by = request_obj.sent_by
- for a_mentor in task.mentors.all():
- if reply:
- addCredits(task, request_obj.sent_by, request_obj.receiving_user, pynts)
- create_notification(request_obj.role, a_mentor, replied_by, True, task, request_obj.remarks, requested_by, receiving_user, pynts)
- else:
- create_notification(request_obj.role, a_mentor, replied_by, False, task, request_obj.remarks, requested_by, receiving_user, pynts)
+ create_notification(request_obj.role, receiving_user, replied_by, reply, task, request_obj.remarks, requested_by, receiving_user, pynts)
+ if receiving_user != requested_by:
+ create_notification(request_obj.role, requested_by, replied_by, reply, task, request_obj.remarks, requested_by, receiving_user, pynts)
elif request_obj.role == "MT":
task = request_obj.task
diff -r a65e1ef725dd -r 925af1b4ee65 taskapp/events/task.py
--- a/taskapp/events/task.py Sun Feb 28 20:49:59 2010 +0530
+++ b/taskapp/events/task.py Sun Feb 28 22:49:05 2010 +0530
@@ -1,5 +1,5 @@
from datetime import datetime
-from pytask.taskapp.models import Profile, Task, Comment, Credit, Claim, Map
+from pytask.taskapp.models import Profile, Task, Comment, Claim, Map
from pytask.taskapp.utilities.task import getTask
from pytask.taskapp.utilities.request import create_request
from pytask.taskapp.utilities.helper import get_key
@@ -102,8 +102,6 @@
task.save()
return task
-
-
def createTask(title,desc,created_by,credits):
""" creates a bare minimum task with title, description and credits.
the creator of the task will be assigned as a mentor for the task.
@@ -189,31 +187,12 @@
main_task.assigned_users.remove(rem_user)
main_task.save()
-def completeTask(main_task):
- """ set the status of task to CP.
- """
-
- main_task.status = "CP"
- main_task.save()
-
def assignCredits(task, given_by, given_to, points):
""" make a proper request object.
"""
create_request(sent_by=given_by, role="PY", task=task, receiving_user=given_to, pynts=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()
-
def completeTask(task, marked_by):
""" set the status of task as completed.
We dont have to inform parent tasks.
@@ -229,7 +208,18 @@
## generate notification appropriately using marked_by
## we also have to mark unread requests as invalid
-def closeTask(task, closed_by):
+ for a_user in task.assigned_users.all():
+ create_notification(role="CM", sent_to=a_user, sent_from=marked_by, task=task)
+
+ for a_user in task.claimed_users.all():
+ create_notification(role="CM", sent_to=a_user, sent_from=marked_by, task=task)
+
+ for a_mentor in task.mentors.all():
+ create_notification(role="CM", sent_to=a_mentor, sent_from=marked_by, task=task)
+
+
+
+def closeTask(task, closed_by, reason=None):
""" set the status of task as CD.
generate notifications accordingly.
"""
@@ -242,4 +232,13 @@
## generate notifications here
+ for a_user in task.assigned_users.all():
+ create_notification(role="CD", sent_to=a_user, sent_from=marked_by, task=task)
+ for a_user in task.claimed_users.all():
+ create_notification(role="CD", sent_to=a_user, sent_from=marked_by, task=task)
+
+ for a_mentor in task.mentors.all():
+ create_notification(role="CD", sent_to=a_mentor, sent_from=marked_by, task=task)
+
+
diff -r a65e1ef725dd -r 925af1b4ee65 taskapp/events/user.py
--- a/taskapp/events/user.py Sun Feb 28 20:49:59 2010 +0530
+++ b/taskapp/events/user.py Sun Feb 28 22:49:05 2010 +0530
@@ -1,5 +1,5 @@
from django.contrib.auth.models import User
-from pytask.taskapp.models import Profile, Task, Comment, Credit
+from pytask.taskapp.models import Profile, Task, Comment
""" A collection of helper methods. note that there is no validation done here.
we take care of validation and others checks in methods that invoke these methods.
diff -r a65e1ef725dd -r 925af1b4ee65 taskapp/models.py
--- a/taskapp/models.py Sun Feb 28 20:49:59 2010 +0530
+++ b/taskapp/models.py Sun Feb 28 22:49:05 2010 +0530
@@ -127,17 +127,6 @@
def __unicode__(self):
return unicode(self.task.title)
-class Credit(models.Model):
-
- task = models.ForeignKey('Task')
- given_by = models.ForeignKey(User, related_name = "%(class)s_given_by")
- given_to = models.ForeignKey(User, related_name = "%(class)s_given_to")
- points = models.PositiveSmallIntegerField()
- given_time = models.DateTimeField()
-
- def __unicode__(self):
- return unicode(self.task.title)
-
class Claim(models.Model):
task = models.ForeignKey('Task')
diff -r a65e1ef725dd -r 925af1b4ee65 taskapp/utilities/notification.py
--- a/taskapp/utilities/notification.py Sun Feb 28 20:49:59 2010 +0530
+++ b/taskapp/utilities/notification.py Sun Feb 28 22:49:05 2010 +0530
@@ -102,13 +102,30 @@
working_users = task.assigned_users.all()
if working_users:
- notification_message += "List of users working on the task.
"
- notification_message += "