X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/6d42bc478e3d1bd90eb294464748c21e4de0fc63..2954f0e21a4c9adf96bb63c85339e7fa79d78e22:/src/picture/migrations/0005_auto_20141022_1001.py diff --git a/src/picture/migrations/0005_auto_20141022_1001.py b/src/picture/migrations/0005_auto_20141022_1001.py index 2d8f7b166..efc8f22f1 100644 --- a/src/picture/migrations/0005_auto_20141022_1001.py +++ b/src/picture/migrations/0005_auto_20141022_1001.py @@ -1,29 +1,8 @@ -# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # import json -from django.core.files.base import ContentFile -from django.db import models, migrations -from django.template.loader import render_to_string - - -def rebuild_extra_info(apps, schema_editor): - Picture = apps.get_model("picture", "Picture") - from librarian.picture import PictureInfo - from librarian import dcparser - for pic in Picture.objects.all(): - info = dcparser.parse(pic.xml_file.path, PictureInfo) - pic.extra_info = json.dumps(info.to_dict()) - areas_json = json.loads(pic.areas_json) - for field in areas_json['things'].values(): - field['object'] = field['object'].capitalize() - pic.areas_json = json.dumps(areas_json) - html_text = render_to_string('picture/picture_info.html', { - 'things': areas_json['things'], - 'themes': areas_json['themes'], - }) - pic.html_file.save("%s.html" % pic.slug, ContentFile(html_text)) - pic.save() +from django.db import migrations class Migration(migrations.Migration): @@ -33,5 +12,4 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RunPython(rebuild_extra_info), ]