Create a package for taskapp views and break the views into task and textbook.
Now all the view functions common to any two entities along with all
tasks related views sit in task module. Even if the view is not directly
related to the task entity, it sits in the task module since task is the
base for every other entity in the application.
"""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()