Mercurial > public > madeira
comparison photologue/models.py @ 151:762e46d0bb4a
urlquote photologue filenames when building URLs.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 30 Jul 2014 20:07:21 -0500 |
parents | dcd097a59223 |
children | f3eca817dd33 |
comparison
equal
deleted
inserted
replaced
150:a9d39fafacaf | 151:762e46d0bb4a |
---|---|
11 from django.core.files.base import ContentFile | 11 from django.core.files.base import ContentFile |
12 from django.core.urlresolvers import reverse | 12 from django.core.urlresolvers import reverse |
13 from django.utils.text import slugify | 13 from django.utils.text import slugify |
14 from django.utils.functional import curry | 14 from django.utils.functional import curry |
15 from django.utils.translation import ugettext_lazy as _ | 15 from django.utils.translation import ugettext_lazy as _ |
16 from django.utils.http import urlquote | |
16 | 17 |
17 # Required PIL classes may or may not be available from the root namespace | 18 # Required PIL classes may or may not be available from the root namespace |
18 # depending on the installation method used. | 19 # depending on the installation method used. |
19 try: | 20 try: |
20 import Image | 21 import Image |
304 if not self.size_exists(photosize): | 305 if not self.size_exists(photosize): |
305 self.create_size(photosize) | 306 self.create_size(photosize) |
306 if photosize.increment_count: | 307 if photosize.increment_count: |
307 self.view_count += 1 | 308 self.view_count += 1 |
308 self.save(update=True) | 309 self.save(update=True) |
309 return '/'.join([self.cache_url(), self._get_filename_for_size(photosize.name)]) | 310 return '/'.join([self.cache_url(), |
311 urlquote(self._get_filename_for_size(photosize.name))]) | |
310 | 312 |
311 def _get_SIZE_filename(self, size): | 313 def _get_SIZE_filename(self, size): |
312 photosize = PhotoSizeCache().sizes.get(size) | 314 photosize = PhotoSizeCache().sizes.get(size) |
313 return os.path.join(self.cache_path(), | 315 return os.path.join(self.cache_path(), |
314 self._get_filename_for_size(photosize.name)) | 316 self._get_filename_for_size(photosize.name)) |