taskapp/events/request.py
changeset 100 2275886511df
child 105 091b044a3bf4
equal deleted inserted replaced
99:64c34c1f441f 100:2275886511df
       
     1 from datetime import datetime
       
     2 from pytask.taskapp.events.task import addCredits
       
     3 
       
     4 def reply_to_request(request_obj, reply, replied_by):
       
     5     """
       
     6     makes a request replied with the given reply.
       
     7     arguments:
       
     8         request_obj - Request object for which change is intended
       
     9         reply - a boolean value to be given as reply (True/False)
       
    10         replied_by - the user object who replies to the request
       
    11     """
       
    12     if not request_obj.is_replied:
       
    13         request_obj.reply = reply
       
    14         request_obj.is_replied = True
       
    15         request_obj.reply_date = datetime.now()
       
    16         request_obj.replied_by = replied_by
       
    17         request_obj.save()
       
    18 
       
    19         if request_obj.role == "PY":
       
    20             if reply:
       
    21                 addCredits(request_obj.task, request_obj.sent_by, request_obj.receiving_user, request_obj.pynts)
       
    22                 print "send yes notifications appropriately"
       
    23             else:
       
    24                 print "send a no notificvaton"
       
    25         elif request_obj.role == "MT":
       
    26             ## add him as a mentor to the task
       
    27             pass
       
    28         elif request_obj.role in ["AD", "MG", "DV"]:
       
    29             if reply:
       
    30                 pass
       
    31                 ## make him the role
       
    32                 ## changeRole(role=request_obj.role, made_by=request_obj.sent_by)
       
    33             else:
       
    34                 ## notify request_obj.sent_by that it has been rejected
       
    35                 pass
       
    36         return True #Reply has been added successfully
       
    37     return False #Already replied