cache_key = "Book.short_html/%d/%s"
for lang, langname in settings.LANGUAGES:
cache.delete(cache_key % (self.id, lang))
- cache.delete(cache_key = "Book.mini_box/%d" % (self.id, ))
+ cache.delete("Book.mini_box/%d" % (self.id, ))
# Fragment.short_html relies on book's tags, so reset it here too
for fragm in self.fragments.all():
fragm.reset_short_html()
from catalogue.models import Book
from picture.models import Picture
-urlpatterns = patterns('catalogue.views',
+urlpatterns = patterns('picture.views',
+ # pictures - currently pictures are coupled with catalogue, hence the url is here
+ url(r'^obraz/?$', 'picture_list'),
+ url(r'^obraz/(?P<picture>%s)/?$' % Picture.URLID_RE, 'picture_detail')
+ ) + \
+ patterns('catalogue.views',
url(r'^$', 'catalogue', name='catalogue'),
url(r'^polki/(?P<shelf>[a-zA-Z0-9-]+)/formaty/$', 'shelf_book_formats', name='shelf_book_formats'),
url(r'^polki/(?P<shelf>[a-zA-Z0-9-]+)/(?P<book>%s)/usun$' % Book.URLID_RE, 'remove_from_shelf', name='remove_from_shelf'),
url(r'^custompdf/(?P<book_fileid>%s).pdf' % Book.FILEID_RE, 'download_custom_pdf'),
-) + patterns('picture.views',
- # pictures - currently pictures are coupled with catalogue, hence the url is here
- url(r'^obraz/?$', 'picture_list'),
- url(r'^obraz/(?P<picture>%s)/?$' % Picture.URLID_RE, 'picture_detail')
- )
-
+)
from pdcounter import models as pdcounter_models
from pdcounter import views as pdcounter_views
from suggest.forms import PublishingSuggestForm
+from picture.models import Picture
+from itertools import chain
from os import path
staff_required = user_passes_test(lambda user: user.is_staff)
def tagged_object_list(request, tags=''):
+ # import pdb; pdb.set_trace()
try:
tags = models.Tag.get_tag_list(tags)
except models.Tag.DoesNotExist:
only_author = len(tags) == 1 and tags[0].category == 'author'
objects = models.Book.objects.none()
+ # Add pictures
+ objects = Picture.tagged.with_all(tags)|objects
+
return object_list(
request,
objects,
from django.conf import settings
from django.core.files.storage import FileSystemStorage
from django.utils.datastructures import SortedDict
+from django.template.loader import render_to_string
+from django.core.cache import cache
+from catalogue.utils import split_tags
+from django.utils.safestring import mark_safe
from librarian import dcparser, picture
from slughifi import slughifi
ret = super(Picture, self).save(force_insert, force_update)
+ if reset_short_html:
+ self.reset_short_html()
+
return ret
def __unicode__(self):
info = dcparser.parse(self.xml_file.path, picture.PictureInfo)
self._info = info
return self._info
+
+ def reset_short_html(self):
+ if self.id is None:
+ return
+
+ cache_key = "Picture.short_html/%d" % (self.id)
+ cache.delete(cache_key)
+
+ def short_html(self):
+ if self.id:
+ cache_key = "Picture.short_html/%d" % (self.id)
+ short_html = cache.get(cache_key)
+ else:
+ short_html = None
+
+ if short_html is not None:
+ return mark_safe(short_html)
+ else:
+ tags = self.tags.filter(category__in=('author', 'kind', 'epoch'))
+ tags = split_tags(tags)
+
+ short_html = unicode(render_to_string('picture/picture_short.html',
+ {'picture': self, 'tags': tags}))
+
+ if self.id:
+ cache.set(cache_key, short_html, catalogue.models.CACHE_FOREVER)
+ return mark_safe(short_html)
'css/header.css',
'css/main_page.css',
'css/dialogs.css',
+ 'css/picture_box.css',
'css/book_box.css',
'css/catalogue.css',
'css/sponsors.css',
</div>
{% thumbnail picture.image_file "400x500" upscale="false" as im %}
- <img style="margin:{{ im|margin:"400x500" }}" src="{{ im.url }}" width="{{ im.x }}" height="{{ im.y }}" />
+ <img style="margin:{{ im|margin:"500x500" }}" src="{{ im.url }}" width="{{ im.x }}" height="{{ im.y }}" />
{% endthumbnail %}
{% if picture.info.license %}
{% if picture.info.description %}
<div id="description">
<div id='description-long'>{{ picture.info.description|safe }}</div>
- <div id='description-short'>{{ picture.info.description|safe|truncatewords_html:30 }}</div>
+{%comment%} <div id='description-short'>{{ picture.info.description|safe|truncatewords_html:30 }}</div>{%endcomment%}
</div>
<div id="toggle-description"><p></p></div>
{% endif %}