add command for scheduling tag description update
[wolnelektury.git] / src / catalogue / management / commands / update_tag_description.py
1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 from django.core.management import BaseCommand
6
7 from catalogue.models import Tag
8
9
10 class Command(BaseCommand):
11     help = "Update description for given tag."
12     args = 'category slug description_filename'
13
14     def handle(self, category, slug, description_filename, **options):
15         tag = Tag.objects.get(category=category, slug=slug)
16         description = open(description_filename).read().decode('utf-8')
17         tag.description = description
18         tag.save()