raven (for sentry.io)
[wolnelektury.git] / src / picture / tasks.py
1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 from celery.task import task
6 from django.core.files.base import ContentFile
7 from django.template.loader import render_to_string
8
9
10 @task
11 def generate_picture_html(picture_id):
12     import picture.models
13     pic = picture.models.Picture.objects.get(pk=picture_id)
14
15     html_text = unicode(render_to_string('picture/picture_info.html', {
16                 'things': pic.areas_json['things'],
17                 'themes': pic.areas_json['themes'],
18                 }))
19     pic.html_file.save("%s.html" % pic.slug, ContentFile(html_text))