pytask/taskapp/views/utils.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Tue, 01 Feb 2011 02:31:53 +0530
changeset 540 b07d52d49db7
child 542 23bf9b4611cb
permissions -rwxr-xr-x
Initial tags for the chapters should not contain Textbook as the keyword.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
540
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     1
"""Module containing taskapp views specific utility functions
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     2
"""
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     3
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     4
__authors__ = [
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     5
    '"Madhusudan.C.S" <madhusudancs@fossee.in>',
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     6
    ]
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     7
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     8
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     9
def get_intial_tags_for_chapter(textbook):
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    10
    """Returns the initial tag set for chapter/module for the textbook.
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    11
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    12
    Args:
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    13
        textbook: textbook entity for which the tags should be built.
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    14
    """
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    15
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    16
    tags1=textbook.tags_field
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    17
    tags = textbook.tags_field.split(',')
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
    rebuild_tags = []
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    19
    for tag in tags:
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    20
        tag.strip()
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    21
        if 'Textbook' not in tag:
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    22
            rebuild_tags.append(tag)
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    23
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    24
    initial_tags = ', '.join(rebuild_tags + ['Chapter'])
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    25
b07d52d49db7 Initial tags for the chapters should not contain Textbook as the keyword.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    26
    return initial_tags