1 # -*- coding: utf-8 -*-
3 # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
7 from django.contrib.auth.models import User
8 from optparse import make_option
10 from django.core.management import BaseCommand
12 from catalogue.models import Book, Chunk
15 class Command(BaseCommand):
16 option_list = BaseCommand.option_list + (
17 # make_option('-q', '--quiet', action='store_false', dest='verbose',
18 # default=True, help='Less output'),
19 # make_option('-d', '--dry-run', action='store_true', dest='dry_run',
20 # default=False, help="Don't actually touch anything"),
22 '-u', '--username', dest='username', metavar='USER',
23 help='Assign commits to this user (required).'),
27 def handle(self, slug_file, **options):
28 username = options.get('username')
31 user = User.objects.get(username=username)
33 print 'Please provide a username.'
36 slugs = [line.strip() for line in open(slug_file)]
37 books = Book.objects.filter(slug__in=slugs)
40 print 'processing %s' % book.slug
41 for chunk in book.chunk_set.all():
42 src = chunk.head.materialize()
46 description=u'Ostateczna akceptacja merytoryczna przez kierownika literackiego.',
47 tags=[Chunk.tag_model.objects.get(slug='editor-proofreading')],
50 print 'committed %s' % book.slug