Merge branch 'obrazy' into rwd
[wolnelektury.git] / apps / 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 datetime import datetime
6 from traceback import print_exc
7 from celery.task import task
8 from django.conf import settings
9 import picture.models
10 from django.core.files.base import ContentFile
11 from django.template.loader import render_to_string
12 import librarian.picture
13
14
15 @task
16 def generate_picture_html(picture_id):
17     pic = picture.models.Picture.objects.get(pk=picture_id)
18
19     
20     html_text = unicode(render_to_string('picture/picture_info.html', {
21                 'things': pic.areas_json['things'], 
22                 'themes': pic.areas_json['themes'],
23                 }))
24     pic.html_file.save("%s.html" % pic.slug, ContentFile(html_text))
25