def do_directlink(self, arg): if arg and album.is_valid_path(self.config['ALBUMS_PATH'], arg): perm_config = permission.get_config(self.config['CACHE_PATH']) print permission.get_album_direct_link(perm_config, arg, self.config['FRONTEND_HOST'], \ self.config['FRONTEND_PORT'], self.config['FRONTEND_PREFIX']) else: self.perror("Invalid album name")
def do_keygen(self, arg): if arg and album.is_valid_path(self.config['ALBUMS_PATH'], arg): perm_config = permission.get_config(self.config['CACHE_PATH']) permission.generate_album_key(perm_config, arg) key = permission.get_album_key(perm_config, arg) permission.save_config(perm_config, self.config['CACHE_PATH']) print 'Key for album "%s" has been generated: %s' % (arg, key) else: self.perror("Invalid album name")
def do_ls(self, arg): if album.is_valid_path(self.config['ALBUMS_PATH'], arg): inner_albums = album.get_album_dirs(self.config['ALBUMS_PATH'], arg) inner_pictures = album.get_album_pictures(self.config['ALBUMS_PATH'], arg) for inner_album in inner_albums: self.poutput("%s/ (%d picture(s))" % (inner_album, album.get_album_total_number_pictures(self.config['ALBUMS_PATH'], os.path.join(arg, inner_album)))) for inner_picture in inner_pictures: self.poutput("%s" % inner_picture) else: self.perror("Invalid album name")
def do_permission(self, arg): args = arg.split() if len(args) == 1: # Only one argument: name of an album # Print the permission of the album (if it exists) if album.is_valid_path(self.config['ALBUMS_PATH'], arg): perm_config = permission.get_config(self.config['CACHE_PATH']) if arg in perm_config['public']: self.poutput('public album') else: self.poutput('private album') else: self.perror("Invalid album name") elif len(args) == 2: # Two arguments: name of an album + associated permission album_path = args[0] album_perm = args[1] if album.is_valid_path(self.config['ALBUMS_PATH'], album_path): if album_perm in ['private', 'public']: perm_config = permission.get_config( self.config['CACHE_PATH']) if album_perm == 'private': permission.set_album_private(perm_config, album_path) elif album_perm == 'public': permission.set_album_public(perm_config, album_path) permission.save_config(perm_config, self.config['CACHE_PATH']) else: self.perror( "Invalid permission (must be 'public' or 'private')") else: self.perror("Invalid album name") else: pass
def do_permission(self, arg): args = arg.split() if len(args) == 1: # Only one argument: name of an album # Print the permission of the album (if it exists) if album.is_valid_path(self.config['ALBUMS_PATH'], arg): perm_config = permission.get_config(self.config['CACHE_PATH']) if arg in perm_config['public']: self.poutput('public album') else: self.poutput('private album') else: self.perror("Invalid album name") elif len(args) == 2: # Two arguments: name of an album + associated permission album_path = args[0] album_perm = args[1] if album.is_valid_path(self.config['ALBUMS_PATH'], album_path): if album_perm in ['private', 'public']: perm_config = permission.get_config(self.config['CACHE_PATH']) if album_perm == 'private': permission.set_album_private(perm_config, album_path) elif album_perm == 'public': permission.set_album_public(perm_config, album_path) permission.save_config(perm_config, self.config['CACHE_PATH']) else: self.perror("Invalid permission (must be 'public' or 'private')") else: self.perror("Invalid album name") else: pass
def do_ls(self, arg): if album.is_valid_path(self.config['ALBUMS_PATH'], arg): inner_albums = album.get_album_dirs(self.config['ALBUMS_PATH'], arg) inner_pictures = album.get_album_pictures( self.config['ALBUMS_PATH'], arg) for inner_album in inner_albums: self.poutput("%s/ (%d picture(s))" % (inner_album, album.get_album_total_number_pictures( self.config['ALBUMS_PATH'], os.path.join(arg, inner_album)))) for inner_picture in inner_pictures: self.poutput("%s" % inner_picture) else: self.perror("Invalid album name")
def show_album(album_path): if not album.is_valid_path(current_app.config['ALBUMS_PATH'], album_path): abort(404) album_context = context.generate_album_context(album_path) return render_theme('album.html', **album_context)