def _set_album_cover(self): photo = self.object context = {} album = Album(settings.PHOTOS_ROOT_DIR, photo.album) album.set_cover(photo.filename) self.purge_album_cache(photo.album) return context
def get_object(self): root_folder = self.get_album_base() try: album = Album(root_folder, self.kwargs['album_path']) return album except AlbumNotFoundError: raise Http404
def _change_album_visibility(self, visibility): photo = self.object context = {} album = Album(settings.PHOTOS_ROOT_DIR, photo.album) album.set_photo_visibility(photo.filename, visibility) context['visibility'] = album.get_photo_visibility(photo.filename) self.purge_album_cache(photo.album) return context
def create_cache_for_album(self, album): print "Album: %s" % album.path for picture in album.get_pictures(): try: self.create_cache(picture, [640, 1440]) except Exception: print "Errror generating cache for %s" % str(picture) for sub_album_path in album.get_albuns(): path = os.path.join(album.path, sub_album_path) sub_album = Album(settings.PHOTOS_ROOT_DIR, path) self.create_cache_for_album(sub_album)
def is_album_token_valid(request, album=None): from retrato.album.views import AlbumView token = str(request.GET.get("token", None)) if album is None: album_path = request.path.replace("/album", "", 1) album_base = AlbumView.get_album_base() album = Album(album_base, album_path) while album is not None: config = album.config() if not config: return False token_match = (str(config.get("token")) == token) if token_match: return True album = album.get_parent() return False
def handle(self, *args, **options): path = '/' if len(args) > 0: path = args[0] root_album = Album(settings.PHOTOS_ROOT_DIR, path) self.create_cache_for_album(root_album)
def test_create_album(self): PHOTOS_ROOT_DIR = getattr(settings, 'PHOTOS_ROOT_DIR', '/') album = Album(PHOTOS_ROOT_DIR, '/') self.assertEquals(album.get_pictures(), []) self.assertEquals(len(album.get_albuns()), 2)