scripts/utils.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Sat, 05 Feb 2011 03:24:52 +0530
changeset 559 96e8e65a3738
parent 535 d90684a803c1
permissions -rw-r--r--
Display Pynts on task/textbook description page. Also make some style fixes.

"""Helper script that contains many utilities.
"""


__authors__ = [
  '"Madhusudan.C.S" <madhusudancs@gmail.com>',
  ]


from tagging.managers import TaggedItem

from pytask.taskapp.models import Task


def remove_textbook_from_chapter():
    """Removes the tag Textbook from Chapter.
    """

    tasks = TaggedItem.objects.get_by_model(Task, 'Chapter')
    for task in tasks:
        tags = task.tags_field.split(',')
        retags = []
        for tag in tags:
            if 'Textbook' not in tag:
                retags.append(tag)
        task.tags_field = ', '.join(retags)
        task.save()