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
13 from redakcja import localsettings
15 setup_environ(settings)
16 settings.CATALOGUE_REPO_PATH = localsettings.CATALOGUE_REPO_PATH
17 settings.CATALOGUE_IMAGE_REPO_PATH = localsettings.CATALOGUE_IMAGE_REPO_PATH
18 settings.MEDIA_ROOT = localsettings.MEDIA_ROOT
19 settings.STATIC_ROOT = localsettings.STATIC_ROOT
22 from catalogue.models import Image
23 from django.core.files import File
26 from django.contrib.auth.models import User
27 from django.conf import settings
32 'obj': User.objects.get(username='marcinkoziej'),
33 'name': 'Marcin Koziej',
34 'email': 'marcinkoziej@nowoczesnapolska.org.pl'
39 xml = open(path.dirname(__file__)+"/image.xml").read().decode('utf-8')
41 for filename in files:
42 dfile = File(open(filename))
44 name = path.splitext(path.basename(filename))[0]
47 old = Image.objects.get(slug=name)
48 print "deleting old %s" % name
56 img.image.save(filename, dfile)
59 img.commit(xml, author=user['obj'], author_name=user['name'], author_email=user['email'])