blob: eb5a7140846dcfdb0baa541f01e6dbb5fc55557c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
"""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()
|