fnp
/
wolnelektury.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
dfd584e
)
Some cleaning.
author
Radek Czajka
<radekczajka@nowoczesnapolska.org.pl>
Wed, 10 Sep 2014 09:35:49 +0000
(11:35 +0200)
committer
Radek Czajka
<radekczajka@nowoczesnapolska.org.pl>
Wed, 10 Sep 2014 09:35:49 +0000
(11:35 +0200)
apps/catalogue/models/book.py
patch
|
blob
|
history
apps/catalogue/models/bookmedia.py
patch
|
blob
|
history
apps/catalogue/models/listeners.py
patch
|
blob
|
history
apps/catalogue/models/tag.py
patch
|
blob
|
history
apps/catalogue/templatetags/catalogue_tags.py
patch
|
blob
|
history
apps/catalogue/utils.py
patch
|
blob
|
history
apps/catalogue/views.py
patch
|
blob
|
history
apps/lesmianator/models.py
patch
|
blob
|
history
apps/newtagging/models.py
patch
|
blob
|
history
apps/picture/models.py
patch
|
blob
|
history
diff --git
a/apps/catalogue/models/book.py
b/apps/catalogue/models/book.py
index
37d9b71
..
e499afc
100644
(file)
--- a/
apps/catalogue/models/book.py
+++ b/
apps/catalogue/models/book.py
@@
-18,7
+18,7
@@
from fnpdjango.storage import BofhFileSystemStorage
from catalogue import constants
from catalogue.fields import EbookField
from catalogue.models import Tag, Fragment, BookMedia
from catalogue import constants
from catalogue.fields import EbookField
from catalogue.models import Tag, Fragment, BookMedia
-from catalogue.utils import create_zip
, split_tags
+from catalogue.utils import create_zip
from catalogue import app_settings
from catalogue import tasks
from newtagging import managers
from catalogue import app_settings
from catalogue import tasks
from newtagging import managers
@@
-64,7
+64,7
@@
class Book(models.Model):
upload_to=_cover_upload_to,
storage=bofh_storage, max_length=255)
# Cleaner version of cover for thumbs
upload_to=_cover_upload_to,
storage=bofh_storage, max_length=255)
# Cleaner version of cover for thumbs
- cover_thumb = EbookField('cover_thumb', _('cover thumbnail'),
+ cover_thumb = EbookField('cover_thumb', _('cover thumbnail'),
null=True, blank=True,
upload_to=_cover_thumb_upload_to,
max_length=255)
null=True, blank=True,
upload_to=_cover_thumb_upload_to,
max_length=255)
@@
-166,8
+166,6
@@
class Book(models.Model):
author = u''
type(self).objects.filter(pk=self.pk).update(sort_key_author=author)
author = u''
type(self).objects.filter(pk=self.pk).update(sort_key_author=author)
-
-
def has_description(self):
return len(self.description) > 0
has_description.short_description = _('description')
def has_description(self):
return len(self.description) > 0
has_description.short_description = _('description')
diff --git
a/apps/catalogue/models/bookmedia.py
b/apps/catalogue/models/bookmedia.py
index
607f4cd
..
1ef3fd7
100644
(file)
--- a/
apps/catalogue/models/bookmedia.py
+++ b/
apps/catalogue/models/bookmedia.py
@@
-46,7
+46,6
@@
class BookMedia(models.Model):
app_label = 'catalogue'
def save(self, *args, **kwargs):
app_label = 'catalogue'
def save(self, *args, **kwargs):
- from fnpdjango.utils.text.slughifi import slughifi
from catalogue.utils import ExistingFile, remove_zip
try:
from catalogue.utils import ExistingFile, remove_zip
try:
diff --git
a/apps/catalogue/models/listeners.py
b/apps/catalogue/models/listeners.py
index
031c4f1
..
d414eb2
100644
(file)
--- a/
apps/catalogue/models/listeners.py
+++ b/
apps/catalogue/models/listeners.py
@@
-6,10
+6,8
@@
from django.conf import settings
from django.core.cache import caches
from django.db.models.signals import post_save, pre_delete, post_delete
import django.dispatch
from django.core.cache import caches
from django.db.models.signals import post_save, pre_delete, post_delete
import django.dispatch
-from catalogue.models import Tag, BookMedia, Book, Fragment, Collection
-from catalogue import tasks
+from catalogue.models import BookMedia, Book, Collection
from catalogue.utils import delete_from_cache_by_language
from catalogue.utils import delete_from_cache_by_language
-from newtagging.models import tags_updated
permanent_cache = caches['permanent']
permanent_cache = caches['permanent']
diff --git
a/apps/catalogue/models/tag.py
b/apps/catalogue/models/tag.py
index
bff9932
..
fb25118
100644
(file)
--- a/
apps/catalogue/models/tag.py
+++ b/
apps/catalogue/models/tag.py
@@
-4,10
+4,9
@@
#
from django.conf import settings
from django.contrib.auth.models import User
#
from django.conf import settings
from django.contrib.auth.models import User
-from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import permalink
from django.db import models
from django.db.models import permalink
-from django.utils.translation import ugettext
, ugettext
_lazy as _
+from django.utils.translation import ugettext_lazy as _
from newtagging.models import TagBase
from newtagging.models import TagBase
@@
-172,4
+171,4
@@
class Tag(TagBase):
# Pickle complains about not having this.
# Pickle complains about not having this.
-TagRelation = Tag.intermediary_table_model
\ No newline at end of file
+TagRelation = Tag.intermediary_table_model
diff --git
a/apps/catalogue/templatetags/catalogue_tags.py
b/apps/catalogue/templatetags/catalogue_tags.py
index
515c1fe
..
2edae9b
100644
(file)
--- a/
apps/catalogue/templatetags/catalogue_tags.py
+++ b/
apps/catalogue/templatetags/catalogue_tags.py
@@
-434,15
+434,15
@@
def tag_url(category, slug):
@register.simple_tag
def download_audio(book, daisy=True):
links = []
@register.simple_tag
def download_audio(book, daisy=True):
links = []
- if
related['media'].get
('mp3'):
+ if
book.has_media
('mp3'):
links.append("<a href='%s'>%s</a>" %
(reverse('download_zip_mp3', args=[book.slug]),
BookMedia.formats['mp3'].name))
links.append("<a href='%s'>%s</a>" %
(reverse('download_zip_mp3', args=[book.slug]),
BookMedia.formats['mp3'].name))
- if
related['media'].get
('ogg'):
+ if
book.has_media
('ogg'):
links.append("<a href='%s'>%s</a>" %
(reverse('download_zip_ogg', args=[book.slug]),
BookMedia.formats['ogg'].name))
links.append("<a href='%s'>%s</a>" %
(reverse('download_zip_ogg', args=[book.slug]),
BookMedia.formats['ogg'].name))
- if daisy and
related['media'].get
('daisy'):
+ if daisy and
book.has_media
('daisy'):
for dsy in book.get_media('daisy'):
links.append("<a href='%s'>%s</a>" %
(dsy.file.url, BookMedia.formats['daisy'].name))
for dsy in book.get_media('daisy'):
links.append("<a href='%s'>%s</a>" %
(dsy.file.url, BookMedia.formats['daisy'].name))
diff --git
a/apps/catalogue/utils.py
b/apps/catalogue/utils.py
index
df7e438
..
91e782e
100644
(file)
--- a/
apps/catalogue/utils.py
+++ b/
apps/catalogue/utils.py
@@
-14,7
+14,6
@@
from django.http import HttpResponse
from django.core.files.uploadedfile import UploadedFile
from django.core.files.storage import DefaultStorage
from django.utils.encoding import force_unicode
from django.core.files.uploadedfile import UploadedFile
from django.core.files.storage import DefaultStorage
from django.utils.encoding import force_unicode
-from django.utils.translation import get_language
from django.conf import settings
from os import mkdir, path, unlink
from errno import EEXIST, ENOENT
from django.conf import settings
from os import mkdir, path, unlink
from errno import EEXIST, ENOENT
@@
-155,7
+154,7
@@
class MultiQuerySet(object):
def __getitem__(self, item):
try:
def __getitem__(self, item):
try:
-
indices =
(offset, stop, step) = item.indices(self.count())
+ (offset, stop, step) = item.indices(self.count())
except AttributeError:
# it's not a slice - make it one
return self[item : item + 1][0]
except AttributeError:
# it's not a slice - make it one
return self[item : item + 1][0]
@@
-185,7
+184,7
@@
class SortedMultiQuerySet(MultiQuerySet):
def __getitem__(self, item):
sort_heads = [0] * len(self.querysets)
try:
def __getitem__(self, item):
sort_heads = [0] * len(self.querysets)
try:
-
indices =
(offset, stop, step) = item.indices(self.count())
+ (offset, stop, step) = item.indices(self.count())
except AttributeError:
# it's not a slice - make it one
return self[item : item + 1][0]
except AttributeError:
# it's not a slice - make it one
return self[item : item + 1][0]
diff --git
a/apps/catalogue/views.py
b/apps/catalogue/views.py
index
76aaddf
..
f47329a
100644
(file)
--- a/
apps/catalogue/views.py
+++ b/
apps/catalogue/views.py
@@
-4,7
+4,6
@@
#
from collections import OrderedDict
import re
#
from collections import OrderedDict
import re
-import itertools
from django.conf import settings
from django.core.cache import get_cache
from django.conf import settings
from django.core.cache import get_cache
@@
-190,7
+189,7
@@
def tagged_object_list(request, tags=''):
only_my_shelf = only_shelf and request.user.is_authenticated() and request.user == tags[0].user
only_my_shelf = only_shelf and request.user.is_authenticated() and request.user == tags[0].user
- objects =
only_author =
None
+ objects = None
categories = {}
object_queries = []
categories = {}
object_queries = []
@@
-240,7
+239,6
@@
def tagged_object_list(request, tags=''):
if not objects:
if not objects:
- only_author = len(tags) == 1 and tags[0].category == 'author'
objects = models.Book.objects.none()
return render_to_response('catalogue/tagged_object_list.html',
objects = models.Book.objects.none()
return render_to_response('catalogue/tagged_object_list.html',
@@
-248,7
+246,6
@@
def tagged_object_list(request, tags=''):
'object_list': objects,
'categories': categories,
'only_shelf': only_shelf,
'object_list': objects,
'categories': categories,
'only_shelf': only_shelf,
- #~ 'only_author': only_author,
'only_my_shelf': only_my_shelf,
'formats_form': forms.DownloadFormatsForm(),
'tags': tags,
'only_my_shelf': only_my_shelf,
'formats_form': forms.DownloadFormatsForm(),
'tags': tags,
diff --git
a/apps/lesmianator/models.py
b/apps/lesmianator/models.py
index
1f558e9
..
5db02c2
100644
(file)
--- a/
apps/lesmianator/models.py
+++ b/
apps/lesmianator/models.py
@@
-168,7
+168,7
@@
class Continuations(models.Model):
elif isinstance(sth, Tag):
conts = cls.for_set(sth)
else:
elif isinstance(sth, Tag):
conts = cls.for_set(sth)
else:
- raise NotImplemented('Lesmianator continuations: only Book and Tag supported')
+ raise NotImplemented
Error
('Lesmianator continuations: only Book and Tag supported')
c, created = cls.objects.get_or_create(content_type=object_type, object_id=sth.id)
c.pickle.save(sth.slug+'.p', ContentFile(cPickle.dumps((should_keys, conts))))
c, created = cls.objects.get_or_create(content_type=object_type, object_id=sth.id)
c.pickle.save(sth.slug+'.p', ContentFile(cPickle.dumps((should_keys, conts))))
diff --git
a/apps/newtagging/models.py
b/apps/newtagging/models.py
index
7e9936f
..
ead442f
100644
(file)
--- a/
apps/newtagging/models.py
+++ b/
apps/newtagging/models.py
@@
-228,8
+228,8
@@
def create_intermediary_table_model(model):
class TagMeta(ModelBase):
"Metaclass for tag models (models inheriting from TagBase)."
class TagMeta(ModelBase):
"Metaclass for tag models (models inheriting from TagBase)."
- def __new__(
cl
s, name, bases, attrs):
- model = super(TagMeta,
cls).__new__(cl
s, name, bases, attrs)
+ def __new__(
mc
s, name, bases, attrs):
+ model = super(TagMeta,
mcs).__new__(mc
s, name, bases, attrs)
if not model._meta.abstract:
# Create an intermediary table and register custom managers for concrete models
model.intermediary_table_model = create_intermediary_table_model(model)
if not model._meta.abstract:
# Create an intermediary table and register custom managers for concrete models
model.intermediary_table_model = create_intermediary_table_model(model)
diff --git
a/apps/picture/models.py
b/apps/picture/models.py
index
75ea4c3
..
5fc3722
100644
(file)
--- a/
apps/picture/models.py
+++ b/
apps/picture/models.py
@@
-380,5
+380,5
@@
class Picture(models.Model):
# copied from book.py, figure out
def related_themes(self):
# copied from book.py, figure out
def related_themes(self):
- return catalogue.models.Tag.usage_for_queryset(
+ return catalogue.models.Tag.
objects.
usage_for_queryset(
self.areas.all(), counts=True).filter(category__in=('theme', 'thing'))
self.areas.all(), counts=True).filter(category__in=('theme', 'thing'))