From c707b18dab443db98a50eb29ec6ce6d00e157293 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Mon, 19 Dec 2016 12:02:28 +0100 Subject: [PATCH] add command for scheduling tag description update --- .../commands/update_tag_description.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/catalogue/management/commands/update_tag_description.py diff --git a/src/catalogue/management/commands/update_tag_description.py b/src/catalogue/management/commands/update_tag_description.py new file mode 100644 index 000000000..d13b12005 --- /dev/null +++ b/src/catalogue/management/commands/update_tag_description.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +from django.core.management import BaseCommand + +from catalogue.models import Tag + + +class Command(BaseCommand): + help = "Update description for given tag." + args = 'category slug description_filename' + + def handle(self, category, slug, description_filename, **options): + tag = Tag.objects.get(category=category, slug=slug) + description = open(description_filename).read().decode('utf-8') + tag.description = description + tag.save() -- 2.20.1