switch to fnp-django-pagination
[wolnelektury.git] / src / catalogue / management / commands / gencover.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.base import BaseCommand
6
7 from catalogue.models import Book
8 from librarian.cover import DefaultEbookCover
9
10
11 class Command(BaseCommand):
12     def add_arguments(self, parser):
13         parser.add_argument('slug')
14         parser.add_argument('size', type=int)
15
16     def handle(self, *args, **options):
17         slug = options['slug']
18         size = options['size']
19         wldoc = Book.objects.get(slug=slug).wldocument()
20         cover = DefaultEbookCover(wldoc.book_info, width=size)
21         cover.save('%s.jpg' % slug)