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