pytask/taskapp/views/utils.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Fri, 04 Feb 2011 16:37:56 +0530
changeset 557 a8102f88008c
parent 542 23bf9b4611cb
permissions -rwxr-xr-x
Use Unauthorized exception for access checks.

"""Module containing taskapp views specific utility functions
"""

__authors__ = [
    '"Madhusudan.C.S" <madhusudancs@fossee.in>',
    ]


def get_intial_tags_for_chapter(textbook):
    """Returns the initial tag set for chapter/module for the textbook.

    Args:
        textbook: textbook entity for which the tags should be built.
    """

    tags = textbook.tags_field.split(',')
    rebuild_tags = []
    for tag in tags:
        tag.strip()
        if 'Textbook' not in tag:
            rebuild_tags.append(tag)

    initial_tags = ', '.join(rebuild_tags + ['Chapter'])

    return initial_tags