X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/5913c54d19b8f6775633176032161d49f9b2f1aa..edf56edfdbea88b0e18c2e5aecbb6e62250ec3d7:/src/catalogue/management/commands/mark_final.py diff --git a/src/catalogue/management/commands/mark_final.py b/src/catalogue/management/commands/mark_final.py index cdfaab93..11d63a3c 100644 --- a/src/catalogue/management/commands/mark_final.py +++ b/src/catalogue/management/commands/mark_final.py @@ -1,43 +1,35 @@ -# -*- coding: utf-8 -*- -# # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # import sys from django.contrib.auth.models import User -from optparse import make_option - from django.core.management import BaseCommand from catalogue.models import Book, Chunk class Command(BaseCommand): - option_list = BaseCommand.option_list + ( - # make_option('-q', '--quiet', action='store_false', dest='verbose', - # default=True, help='Less output'), - # make_option('-d', '--dry-run', action='store_true', dest='dry_run', - # default=False, help="Don't actually touch anything"), - make_option( - '-u', '--username', dest='username', metavar='USER', - help='Assign commits to this user (required).'), - ) args = 'slug_file' + def add_arguments(self, parser): + self.add_argument( + '-u', '--username', dest='username', metavar='USER', + help='Assign commits to this user (required).') + def handle(self, slug_file, **options): username = options.get('username') if username: user = User.objects.get(username=username) else: - print 'Please provide a username.' + print('Please provide a username.') sys.exit(1) slugs = [line.strip() for line in open(slug_file)] books = Book.objects.filter(slug__in=slugs) for book in books: - print 'processing %s' % book.slug + print('processing %s' % book.slug) for chunk in book.chunk_set.all(): src = chunk.head.materialize() chunk.commit( @@ -47,4 +39,4 @@ class Command(BaseCommand): tags=[Chunk.tag_model.objects.get(slug='editor-proofreading')], publishable=True ) - print 'committed %s' % book.slug + print('committed %s' % book.slug)