fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Search.
[wolnelektury.git]
/
src
/
picture
/
models.py
diff --git
a/src/picture/models.py
b/src/picture/models.py
index
1ad09e2
..
b9ddcae
100644
(file)
--- a/
src/picture/models.py
+++ b/
src/picture/models.py
@@
-22,7
+22,7
@@
import re
from PIL import Image
from PIL import Image
-from django.utils.translation import
u
gettext_lazy as _
+from django.utils.translation import gettext_lazy as _
from newtagging import managers
from os import path
from newtagging import managers
from os import path
@@
-101,6
+101,8
@@
class Picture(models.Model):
short_html_url_name = 'picture_short'
short_html_url_name = 'picture_short'
+ is_picture = True
+
class AlreadyExists(Exception):
pass
class AlreadyExists(Exception):
pass
@@
-110,6
+112,9
@@
class Picture(models.Model):
verbose_name = _('picture')
verbose_name_plural = _('pictures')
verbose_name = _('picture')
verbose_name_plural = _('pictures')
+ def get_extra_info_json(self):
+ return json.loads(self.extra_info or '{}')
+
def save(self, force_insert=False, force_update=False, **kwargs):
from sortify import sortify
def save(self, force_insert=False, force_update=False, **kwargs):
from sortify import sortify
@@
-118,7
+123,7
@@
class Picture(models.Model):
try:
author = self.authors().first().sort_key
except AttributeError:
try:
author = self.authors().first().sort_key
except AttributeError:
- author =
u
''
+ author = ''
self.sort_key_author = author
ret = super(Picture, self).save(force_insert, force_update)
self.sort_key_author = author
ret = super(Picture, self).save(force_insert, force_update)
@@
-131,6
+136,15
@@
class Picture(models.Model):
def authors(self):
return self.tags.filter(category='author')
def authors(self):
return self.tags.filter(category='author')
+ def epochs(self):
+ return self.tags.filter(category='epoch')
+
+ def genres(self):
+ return self.tags.filter(category='genre')
+
+ def kinds(self):
+ return self.tags.filter(category='kind')
+
def tag_unicode(self, category):
relations = prefetched_relations(self, category)
if relations:
def tag_unicode(self, category):
relations = prefetched_relations(self, category)
if relations: