1 # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.contrib.auth.models import User
6 from django.core.management import BaseCommand
8 from documents.models import Book, Chunk
11 class Command(BaseCommand):
14 def add_arguments(self, parser):
16 '-u', '--username', dest='username', metavar='USER',
17 help='Assign commits to this user (required).')
19 def handle(self, slug_file, **options):
20 username = options.get('username')
23 user = User.objects.get(username=username)
25 print('Please provide a username.')
28 slugs = [line.strip() for line in open(slug_file)]
29 books = Book.objects.filter(slug__in=slugs)
32 print('processing %s' % book.slug)
33 for chunk in book.chunk_set.all():
34 src = chunk.head.materialize()
38 description=u'Ostateczna akceptacja merytoryczna przez kierownika literackiego.',
39 tags=[Chunk.tag_model.objects.get(slug='editor-proofreading')],
42 print('committed %s' % book.slug)