taskapp/utilities/request.py
changeset 71 801cf8fca53a
parent 58 e0ec1901dfce
child 78 c5bcafccc135
equal deleted inserted replaced
70:a14ec2f09beb 71:801cf8fca53a
     1 from pytask.taskapp.models import Request
     1 from pytask.taskapp.models import Request
     2 from datetime import datetime
     2 from datetime import datetime
     3 
     3 
     4 def create_request(to,by,role):
     4 def create_request(to,by,role,task=None,assigned_user=None):
     5     """
     5     """
     6     creates an unreplied request, based on the passed arguments
     6     creates an unreplied request, based on the passed arguments
     7         to - a list of users to which the notification is to be sent
     7         to - a list of users to which the notification is to be sent
     8         by - sender of request
     8         by - sender of request
     9         role - a two character field which represents the role requested
     9         role - a two character field which represents the role requested
       
    10         task - a requesting task (useful for sending admins a request to give Pynts to the user, assigning a user to a task)
       
    11         assigned_user - user to whom the Pynts/Task is assigned to(useful for sending admins a request to give Pynts to the user, assigning a user to a task)
    10     """
    12     """
    11     req = Request(creation_date=datetime.now())
    13     req = Request(creation_date=datetime.now())
    12     req.by = by
    14     req.by = by
    13     req.reply_date = datetime(1970,01,01)
    15     req.reply_date = datetime(1970,01,01)
    14     req.save()
    16     req.save()
    15     req.to = to
    17     req.to = to
    16     req.role = role
    18     req.role = role
       
    19     if task not None:
       
    20         req.task = task
       
    21     if assigned_user not None:
       
    22         req.assigned_user = assigned_user
    17     req.save()
    23     req.save()