pytask/taskapp/utils.py
author Nishanth Amuluru <nishanth@fossee.in>
Tue, 11 Jan 2011 11:30:14 +0530
changeset 137 40f1ef7a46d8
parent 132 1be4a3c09a47
permissions -rw-r--r--
added admin files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
132
1be4a3c09a47 view textbook works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 106
diff changeset
     1
from pytask.taskapp.models import Task, TextBook
105
94dd9d25d52a Added utils to taskapp
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     2
from django.http import Http404
94dd9d25d52a Added utils to taskapp
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     3
94dd9d25d52a Added utils to taskapp
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     4
def getTask(tid):
94dd9d25d52a Added utils to taskapp
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     5
94dd9d25d52a Added utils to taskapp
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     6
    try:
106
aa61ea9c29f9 now deleted tasks are also selected in db query
Nishanth Amuluru <nishanth@fossee.in>
parents: 105
diff changeset
     7
        task = Task.objects.get(uniq_key=tid)
105
94dd9d25d52a Added utils to taskapp
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     8
        return task
94dd9d25d52a Added utils to taskapp
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     9
    except Task.DoesNotExist:
94dd9d25d52a Added utils to taskapp
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    10
        raise Http404
94dd9d25d52a Added utils to taskapp
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    11
132
1be4a3c09a47 view textbook works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 106
diff changeset
    12
def getTextBook(tid):
1be4a3c09a47 view textbook works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 106
diff changeset
    13
1be4a3c09a47 view textbook works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 106
diff changeset
    14
    try:
1be4a3c09a47 view textbook works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 106
diff changeset
    15
        task = TextBook.objects.get(uniq_key=tid)
1be4a3c09a47 view textbook works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 106
diff changeset
    16
        return task
1be4a3c09a47 view textbook works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 106
diff changeset
    17
    except TextBook.DoesNotExist:
1be4a3c09a47 view textbook works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 106
diff changeset
    18
        raise Http404
1be4a3c09a47 view textbook works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 106
diff changeset
    19