author | nishanth |
Thu, 25 Feb 2010 18:49:17 +0530 | |
changeset 100 | 2275886511df |
parent 99 | 64c34c1f441f |
child 122 | daee11bdfbaa |
permissions | -rw-r--r-- |
58 | 1 |
from datetime import datetime |
87 | 2 |
from django.contrib.auth.models import User |
100
2275886511df
now admin can accept a request for assigning credits.
nishanth
parents:
99
diff
changeset
|
3 |
from pytask.taskapp.models import Request, Profile |
58 | 4 |
|
87 | 5 |
def create_request(sent_by,role,sent_to=None,task=None,receiving_user=None,pynts=0): |
58 | 6 |
""" |
7 |
creates an unreplied request, based on the passed arguments |
|
87 | 8 |
sent_to - a list of users to which the notification is to be sent |
9 |
sent_by - sender of request |
|
10 |
role - a two character field which represents the role requested, if role = 'PY' then sent to all admins |
|
78
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
71
diff
changeset
|
11 |
task - a requesting task (useful for sending admins a request to give Pynts to the user) |
87 | 12 |
receiving_user - user to whom the Pynts is assigned to(useful for sending admins a request to give Pynts to the user) |
13 |
pynts - the pynts assigned to the receiving user |
|
58 | 14 |
""" |
15 |
req = Request(creation_date=datetime.now()) |
|
87 | 16 |
req.sent_by = sent_by |
58 | 17 |
req.reply_date = datetime(1970,01,01) |
18 |
req.role = role |
|
87 | 19 |
req.pynts = pynts |
80 | 20 |
if task: |
71
801cf8fca53a
made change to the request model and corresponding create_request utility.
anoop
parents:
58
diff
changeset
|
21 |
req.task = task |
87 | 22 |
req.save() |
23 |
if role == 'PY': |
|
24 |
admin_profiles = Profile.objects.filter(rights='AD') |
|
99
64c34c1f441f
assign_credits event now creates a proper request object .
nishanth
parents:
87
diff
changeset
|
25 |
for admin_profile in admin_profiles: |
87 | 26 |
req.sent_to.add(admin_profile.user) |
27 |
req.receiving_user = receiving_user |
|
28 |
else: |
|
29 |
req.sent_to.add(sent_to) |
|
58 | 30 |
req.save() |
78
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
71
diff
changeset
|
31 |