flake8 formating
This commit is contained in:
parent
4f877dd2f2
commit
1492c803a8
5 changed files with 18 additions and 20 deletions
|
|
@ -186,15 +186,15 @@ class Gallery(models.Model):
|
|||
def sample(self, public=True):
|
||||
"""Return a sample of photos, ordered at random."""
|
||||
count = 1
|
||||
nb = self.photo_count(public) #Optimisation don't do twice the SQL requests
|
||||
nb = self.photo_count(public) # Optimisation don't do twice the SQL requests
|
||||
if nb < count:
|
||||
count = nb
|
||||
|
||||
|
||||
if public:
|
||||
photo_set = self.photos.filter(is_public=True)
|
||||
else:
|
||||
photo_set = self.photos
|
||||
return photo_set.order_by("?")[:count] # Use native SQL random
|
||||
return photo_set.order_by("?")[:count] # Use native SQL random
|
||||
|
||||
def photo_count(self, public=True):
|
||||
"""Return a count of all the photos in this gallery."""
|
||||
|
|
@ -726,14 +726,14 @@ class PhotoSizeCache:
|
|||
def __init__(self):
|
||||
self.__dict__ = self.__state
|
||||
|
||||
cached = caches.get("PhotoSizeCache",None)
|
||||
if cached is None :
|
||||
cached = caches.get("PhotoSizeCache", None)
|
||||
if cached is None:
|
||||
if not len(self.sizes):
|
||||
sizes = PhotoSize.objects.all()
|
||||
for size in sizes:
|
||||
self.sizes[size.name] = size
|
||||
caches.set("PhotoSizeCache",self)
|
||||
else :
|
||||
caches.set("PhotoSizeCache", self)
|
||||
else:
|
||||
self = cached
|
||||
|
||||
def reset(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue