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 collections import defaultdict
11 from django.core.management import BaseCommand
13 from catalogue.models import Book, Chunk
16 class Command(BaseCommand):
17 option_list = BaseCommand.option_list + (
18 # make_option('-q', '--quiet', action='store_false', dest='verbose',
19 # default=True, help='Less output'),
20 # make_option('-d', '--dry-run', action='store_true', dest='dry_run',
21 # default=False, help="Don't actually touch anything"),
23 '-u', '--username', dest='username', metavar='USER',
24 help='Assign commits to this user (required).'),
28 def handle(self, slug_file, **options):
29 username = options.get('username')
32 user = User.objects.get(username=username)
34 print 'Please provide a username.'
37 slugs = [line.strip() for line in open(slug_file)]
38 books = Book.objects.filter(slug__in=slugs)
41 print 'processing %s' % book.slug
42 chunk = book.chunk_set.first()
43 src = chunk.head.materialize()
44 new_head = chunk.commit(
47 description=u'Ostateczna akceptacja merytoryczna przez kierownika literackiego.',
48 tags=[Chunk.tag_model.objects.get(slug='editor-proofreading')],
51 print 'committed %s' % book.slug
52 new_head.set_publishable(True)