2 # -*- coding: utf-8 -*-
3 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
8 sys.path.append('./apps')
9 sys.path.append('./lib')
11 from django.core.management import setup_environ
12 from redakcja import settings
14 setup_environ(settings)
16 from catalogue.models import Book, Chunk
21 tag_with_name = r"<([^>]+)name=\"([^>]+)>"
23 def fix(book, author, dry_run=True):
25 print "%s does not contain chunks" % book.slug
28 txt = fc.materialize()
30 newtxt, cnt = re.subn(tag_with_name, r'<\1nazwa="\2>', txt)
32 print "%s nothing changed" % book
36 print "%s changing" % book
37 fc.commit(newtxt, author=author, description=u"Automatyczna zmiana atrybutu name na nazwa")
42 from django.contrib.auth.models import User
43 opts, oth_ = getopt.getopt(sys.argv[1:],
46 dry_run = not (("--seriously",'') in opts)
47 me = User.objects.get(username='marcinkoziej')
49 print "This is a dry run, to really change dates, run with --seriously"
50 for b in Book.objects.all():