e5e87387c78eba90653698cf9a4feaacd6f9f0fe
[wolnelektury.git] / apps / picture / migrations / 0005_auto_20141022_1001.py
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 from django.db import models, migrations
5
6 def rebuild_extra_info(apps, schema_editor):
7     Picture = apps.get_model("picture", "Picture")
8     from librarian.picture import PictureInfo
9     from librarian import dcparser
10     for pic in Picture.objects.all():
11         info = dcparser.parse(pic.xml_file.path, PictureInfo)
12         pic.extra_info = info.to_dict()
13         pic.save()
14
15
16 class Migration(migrations.Migration):
17
18     dependencies = [
19         ('picture', '0004_auto_20141016_1337'),
20     ]
21
22     operations = [
23         migrations.RunPython(rebuild_extra_info),
24     ]