diff options
author | nishanth | 2010-03-01 12:44:27 +0530 |
---|---|---|
committer | nishanth | 2010-03-01 12:44:27 +0530 |
commit | 1d1cd491495ff976db93b3de82f1feecdcc14dff (patch) | |
tree | 2e7d58feb632dfe97863e3f74014b92419a76918 /taskapp | |
parent | 77312a19a2877e4650ebe55fc2fa596c968252ed (diff) | |
download | pytask-1d1cd491495ff976db93b3de82f1feecdcc14dff.tar.gz pytask-1d1cd491495ff976db93b3de82f1feecdcc14dff.tar.bz2 pytask-1d1cd491495ff976db93b3de82f1feecdcc14dff.zip |
added au ru notifications.
Diffstat (limited to 'taskapp')
-rw-r--r-- | taskapp/events/task.py | 9 | ||||
-rw-r--r-- | taskapp/models.py | 6 | ||||
-rw-r--r-- | taskapp/utilities/notification.py | 45 | ||||
-rw-r--r-- | taskapp/views/task.py | 2 |
4 files changed, 56 insertions, 6 deletions
diff --git a/taskapp/events/task.py b/taskapp/events/task.py index 9a12125..625c2d8 100644 --- a/taskapp/events/task.py +++ b/taskapp/events/task.py @@ -149,15 +149,17 @@ def addClaim(task, message, user): user.request_sent_to.filter(is_replied=False, is_valid=True, role="MT", task=task).update(is_valid=False) -def assignTask(task, user, assigned_by): +def assignTask(task, added_user, assigned_by): """ check for the status of task and assign it to the particular user """ if task.status in ['OP', 'WR']: - task.assigned_users.add(user) - task.claimed_users.remove(user) + task.assigned_users.add(added_user) + task.claimed_users.remove(added_user) task.status = "WR" task.save() + create_notification("AU", added_user, assigned_by, task=task) + def updateTask(task, title=None, desc=None, credits=None, tags_field=None): """ update the property accordingly. @@ -195,6 +197,7 @@ def removeUser(main_task, rem_user, removed_by, reason=None): ## TODiscuss : when a user is kicked off, his pending requests for pynts is made invalid rem_user.request_receiving_user.filter(task=main_task,role="PY",is_valid=True,is_replied=False).update(is_valid=False) + create_notification("RU", rem_user, removed_by, task=main_task, remarks=reason) ## TODO : create notification to the victim def assignCredits(task, given_by, given_to, points): diff --git a/taskapp/models.py b/taskapp/models.py index e6e1133..a429cd3 100644 --- a/taskapp/models.py +++ b/taskapp/models.py @@ -34,9 +34,13 @@ NOTIFY_CHOICES = ( ("CM", "Task completed"), ("CD", "Task closed"), ("DL", "Task deleted"), - ("KD", "Kicked off"), ("NU", "New User"), ("NT", "New Mentor"), + ("ND", "New Developer"), + ("NG", "New Manager"), + ("NA", "New Admin"), + ("AU", "Assign user"), ## i mean assign the task + ("RU", "Remove user"), ## remove from working users list in task ) diff --git a/taskapp/utilities/notification.py b/taskapp/utilities/notification.py index e16a94f..887b82e 100644 --- a/taskapp/utilities/notification.py +++ b/taskapp/utilities/notification.py @@ -69,12 +69,12 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re notification.sub = "%s rejected request to act as a mentor"%new_mentor.username notification.message = "%s has rejected your request asking him to act as a mentor for %s.<br />"%(new_mentor_url, task_url) if remarks: + notification.remarks = remarks notification.message += "Remarks: %s<br />"%remarks elif role in ["DV", "MG", "AD"]: notification.sent_from = sent_from - accepting_user = sent_from user_url = '<a href="/user/view/uid=%s">%s</a>'%(accepting_user.id, accepting_user.username) ## i mean the user who has accepted it requested_by_url = '<a href="/user/view/uid=%s">%s</a>'%(requested_by.id, requested_by.username) @@ -89,6 +89,7 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re notification.sub = "Rejected your request to act as %s"%role_rights notification.message = "%s has rejected your request asking him to act as %s %s.<br />"%(user_url, a_or_an, role_rights) if remarks: + notification.remarks = remarks notification.message += "Remarks: %s<br />"%remarks elif role == "NT": @@ -162,8 +163,50 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re notification.message = "The task %s has been closed by %s.<br />"%(task_url, mentor_url) if remarks: + notification.remarks = remarks notification.message += "<b>Remarks:</b> %s"%remarks + elif role == "AU": + + notification.task = task + added_user = sent_to + mentor = sent_from + assigned_by_url = '<a href="/user/view/uid=%s">%s</a>'%(mentor.id, mentor.username) + task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title) + + notification.sub = "Your claim for the task %s accepted."%task.title[:20] + notification.message = "You have been selected to work on the task %s by %s.<br />"%(task_url, assigned_by_url) + notification.message += "You can now start working on the task and will be credited by the mentors for your work.<br />" + + notification.message += " Here is a list of mentors for the task and their email addresses.<br /> <ul>" + for a_mentor in task.mentors.all(): + notification.message += "<li> %s - %s </li>"%(a_mentor.username, a_mentor.email) + notification.message += "</ul>" + + working_users = task.assigned_users.exclude(id=added_user.id) + if working_users: + notification.message += "List of other users working on the task.<br />" + notification.message += "<ul>" + for a_user in working_users: + notification.message += "<li> %s - %s </li>"%(a_user.username, a_user.email) + notification.message += "</ul><br />" + + elif role == "RU": + + notification.task = task + removed_user = sent_to + mentor = sent_from + removed_by_url = '<a href="/user/view/uid=%s">%s</a>'%(mentor.id, mentor.username) + task_url = '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title) + claim_url = '<a href="/task/claim/tid=%s">%s</a>'%(task.id, "clicking here") + + notification.sub = "You have been removed from working users of %s"%task.title[:20] + notification.message = "%s has removed you from the working users list of %s.<br />"%(removed_by_url, task_url) + notification.message += "if you want to work on the task again, you can claim the task by %s.<br />"%claim_url + if remarks: + notification.remarks = remarks + notification.message += "<b>Reason: </b>%s"%(remarks) + notification.save() diff --git a/taskapp/views/task.py b/taskapp/views/task.py index 20329bc..16ec11e 100644 --- a/taskapp/views/task.py +++ b/taskapp/views/task.py @@ -393,7 +393,7 @@ def rem_user(request, tid): 'task':task, } - if task.status in ["OP", "WR"]: + if task.status in ["WR"]: if assigned_users: form = RemoveUserForm(choices) context['form'] = form |