taskapp/events/task.py
author nishanth
Thu, 04 Feb 2010 23:10:30 +0530
changeset 22 36d3173ab7f9
parent 21 c28774fe7ffd
child 25 c0e4fc8b8b5b
permissions -rw-r--r--
addded link to view claims in 'view task' page .
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
     1
from datetime import datetime
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
     2
from pytask.taskapp.models import Profile, Task, Comment, Credit
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
     3
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
     4
def publishTask(task):
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
     5
    """ set the task status to open """
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
     6
    
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
     7
    task.status = "OP"
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
     8
    task.save()
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
     9
    return task
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    10
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    11
def addMentor(task,mentor):
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    12
    """ add the mentor to mentors list of the task """
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    13
    
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    14
    task.mentors.add(mentor)
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    15
    task.save()
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    16
    return task    
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    17
    
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    18
def createTask(title,desc,created_by,credits):
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    19
    """ creates a bare minimum task with title, description and credits.
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    20
    the creator of the task will be assigned as a mentor for the task.
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    21
    """
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    22
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    23
    try:
21
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 19
diff changeset
    24
        task = Task.objects.get(title__iexact=title)
19
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    25
        return None
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    26
    except Task.DoesNotExist:
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    27
        task = Task(title=title)
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    28
    task.desc = desc
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    29
    task.created_by = created_by
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    30
    task.credits = credits
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    31
    task.creation_datetime = datetime.now()
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    32
    task.save()
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    33
    return task
c52f7cde9861 added events/task.py and templates/error.html.
nishanth
parents:
diff changeset
    34
21
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 19
diff changeset
    35
def addSubTask(main_task, sub_task):
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 19
diff changeset
    36
    """ add sub_task to subs list of main_task """
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 19
diff changeset
    37
    
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 19
diff changeset
    38
    main_task.subs.add(sub_task)
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 19
diff changeset
    39
    main_task.status = "LO"
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 19
diff changeset
    40
    main_task.save()
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 19
diff changeset
    41
    return main_task