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