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