taskapp/utilities/request.py
changeset 82 7c38ff64aee7
parent 81 cade14d25a58
child 87 f0a3d6612462
equal deleted inserted replaced
81:cade14d25a58 82:7c38ff64aee7
    21     if assigned_user:
    21     if assigned_user:
    22         req.assigned_user = assigned_user
    22         req.assigned_user = assigned_user
    23     req.pynts = pynts
    23     req.pynts = pynts
    24     req.save()
    24     req.save()
    25 
    25 
    26 def reply_to_request(request_id, reply):
    26 def reply_to_request(request_obj, reply):
    27     """
    27     """
    28     makes a request replied with the given reply.
    28     makes a request replied with the given reply.
    29     arguments:
    29     arguments:
    30         request_id - a number denoting the id of the Request object
    30         request_obj - Request object for which change is intended
    31         reply - a boolean value to be given as reply (True/False)
    31         reply - a boolean value to be given as reply (True/False)
    32     """
    32     """
    33     try:
    33     if not request_obj.replied:
    34         request = Request.objects.get(id = request_id)
    34         request_obj.reply = reply
    35     except Request.DoesNotExist:
    35         request_obj.replied = True
    36         return False #No such request exist
    36         request_obj.read = True
    37     if not request.replied:
    37         request_obj.reply_date = datetime.now()
    38         request.reply = reply
    38         request_obj.save()
    39         request.replied = True
       
    40         request.read = True
       
    41         request.reply_date = datetime.now()
       
    42         request.save()
       
    43         return True #Reply has been added successfully
    39         return True #Reply has been added successfully
    44     return False #Already replied
    40     return False #Already replied