diff --git a/sas/models.py b/sas/models.py index 944b646f..c66c6498 100644 --- a/sas/models.py +++ b/sas/models.py @@ -78,16 +78,20 @@ class Picture(SithFile): # Result is cached 4s for this user if user.is_anonymous: return False - + perm = cache.get("%d_can_view_pictures" % (user.id), False) - + # use cache only when user is in SAS Admins or when picture is moderated if perm and (self.is_moderated or self.can_be_edited_by(user)): return perm - - perm = self.is_in_sas and (self.is_moderated or self.can_be_edited_by(user)) and user.was_subscribed + + perm = ( + self.is_in_sas + and (self.is_moderated or self.can_be_edited_by(user)) + and user.was_subscribed + ) cache.set("%d_can_view_pictures" % (user.id), perm, timeout=4) - + return perm def get_download_url(self):