Пример #1
0
def show_change_setting(album, setting, value):
    show = Show(album, current_app.config, session)
    try:
        show.change_setting(setting, value).save()
    except:
        return jsonify(result="Failed")
    return jsonify(result="OK")
Пример #2
0
def show_remove_user(album, username):
    show = Show(album)
    show.remove_user(username)
    if (show.save()):
        return redirect(request.referrer or url_for('.index'))
    else:
        return jsonify(result='Failed')
Пример #3
0
def show_change_setting(album, setting, value):
    show = Show(album, current_app.config, session)
    try:
        show.change_setting(setting, value).save()
    except:
        return jsonify(result='Failed')
    return jsonify(result='OK')
Пример #4
0
def show_change_password(album):
    if request.method == 'POST':
        show = Show(album, current_app.config, session)
        username = request.form['username']
        password = request.form['password']
        show.set_user(username, current_app.config['SECRET_KEY'], password).save()
        return goback(True)
Пример #5
0
def show_change_password(album):
    if request.method == "POST":
        show = Show(album, current_app.config, session)
        username = request.form["username"]
        password = request.form["password"]
        show.set_user(username, current_app.config["SECRET_KEY"], password).save()
        return goback(True)
Пример #6
0
def toggle_publish_image(album, filename):
    """Toggle publish image"""
    show = Show(album, current_app.config, session)
    try:
        show.toggle_image(filename).save()
    except:
        return jsonify(result='Failed')

    return jsonify(result='OK')
Пример #7
0
def add_image_to_show(album, filename):
    """Add an image to the show"""
    show = Show(album, current_app.config, session)
    try:
        show.add_image(filename).save()
    except:
        return jsonify(result='Failed')

    return jsonify(result='OK')
Пример #8
0
def toggle_publish_image(album, filename):
    """Toggle publish image"""
    show = Show(album, current_app.config, session)
    try:
        show.toggle_image(filename).save()
    except:
        return jsonify(result="Failed")

    return jsonify(result="OK")
Пример #9
0
def add_image_to_show(album, filename):
    """Add an image to the show"""
    show = Show(album, current_app.config, session)
    try:
        show.add_image(filename).save()
    except:
        return jsonify(result="Failed")

    return jsonify(result="OK")
Пример #10
0
def remove_image_from_show(album, filename):
    """Remove an image from the show"""
    show = Show(album, current_app.config, session)

    try:
        show.remove_image(filename).save()
    except:
        return jsonify(result="Failed")

    return jsonify(result="OK")
Пример #11
0
def show_change_password(album):
    if request.method == 'POST':
        show = Show(album)
        username = request.form['username']
        password = request.form['password']
        show.set_user(username, current_app.config['SECRET_KEY'], password)
        if (show.save()):
            return redirect(request.referrer or url_for('.index'))
        else:
            return jsonify(result='Failed')
Пример #12
0
def remove_image_from_show(album, filename):
    """Remove an image from the show"""
    show = Show(album, current_app.config, session)

    try:
        show.remove_image(filename).save()
    except:
        return jsonify(result='Failed')

    return jsonify(result='OK')
Пример #13
0
def get_paginator(album, page, endpoint, template):
    show = Show(album)

    if len(show.data['files']) == 0:
        abort(404)

    files = show.data['files']

    if show.get_setting('reverse') == 'yes':
        files.reverse()

    p = Paginator(album, files, current_app.config['THUMBNAILS_PER_PAGE'], page, endpoint, template)
    return p
Пример #14
0
def show_index():
    dir_list = os.listdir(current_app.config['ALBUMS_DIR'])
    full_album_list = [ os.path.basename(album) for album in dir_list ]
    shows = {}

    for album in full_album_list:
        show = Show(album)
        if show.is_enabled():
            shows[album] = show

    album_list = shows.keys()
    album_list.sort(reverse=True)

    return render_themed('index.html', albums=album_list, shows=shows)
Пример #15
0
def get_paginator(album, page, endpoint, template):
    show = Show(album, current_app.config, session)

    if len(show.data['files']) == 0:
        abort(404)

    files = show.data['files']

    if show.get_setting('reverse') == 'yes':
        files.reverse()

    try:
        return Paginator(album, files, current_app.config['THUMBNAILS_PER_PAGE'], page, endpoint, template)
    except:
        abort(404)
Пример #16
0
def show_edit_users(album):
    show = Show(album, current_app.config, session)
    users = show.data['users']
    return render_themed('edit_users.html',
                         album=album,
                         show=show,
                         users=users)
Пример #17
0
def show_nonpaginated(album, template='grid_full'):
    show = Show(album, current_app.config, session)

    if len(show.data['files']) == 0:
        abort(404)

    files = show.data['files']
    return render_themed(template + '.html', album=album, files=files)
Пример #18
0
def image_page(album, filename):
    show = Show(album, current_app.config, session)
    image = Image(album, filename, current_app.config)
    exif_manager = ExifManager(image)
    exif_array = exif_manager.get_exif()
    if exif_array is None:
        exif_array = {}
    return render_themed('image.html', album=album, filename=filename,
                         exif=exif_array, show=show)
Пример #19
0
def _paginated_overview(album, page, endpoint='admin.list', template='grid'):
    show = Show(album, current_app.config, session)
    files = os.listdir(os.path.join(current_app.config['ALBUMS_DIR'], album))

    ext = re.compile(".(jpg|png|gif|bmp)$", re.IGNORECASE)
    files = [f for f in files if ext.search(f)]

    #if len(files) == 0:
        #abort(404)

    files.sort()

    if show.get_setting('reverse') == 'yes':
        files.reverse()

    try:
        return Paginator(album, files, current_app.config['THUMBNAILS_PER_PAGE'], page, endpoint, template)
    except:
        abort(404)
Пример #20
0
def list_album(album, page, template='grid'):
    show = Show(album, current_app.config, session)
    ext = re.compile(".(jpg|png|gif|bmp)$", re.IGNORECASE)

    album_dir = os.path.join(current_app.config['ALBUMS_DIR'], album)
    all_files = [f for f in os.listdir(album_dir) if ext.search(f)]
    all_files.sort()

    if show.get_setting('reverse') == 'yes':
        all_files.reverse()

    paginator = _paginated_overview(album, page, 'admin.list_album', template)
    return render_themed(template + '.html',
                         album=album,
                         show=show,
                         files=paginator.entries,
                         paginator=paginator,
                         page=page,
                         all_files=all_files)
Пример #21
0
def _paginated_overview(album, page, endpoint='admin.list', template='grid'):
    show = Show(album, current_app.config, session)
    files = os.listdir(os.path.join(current_app.config['ALBUMS_DIR'], album))

    ext = re.compile(".(jpg|png|gif|bmp)$", re.IGNORECASE)
    files = [f for f in files if ext.search(f)]

    if len(files) == 0:
        abort(404)

    files.sort()

    if show.get_setting('reverse') == 'yes':
        files.reverse()

    try:
        return Paginator(album, files, current_app.config['THUMBNAILS_PER_PAGE'], page, endpoint, template)
    except:
        abort(404)
Пример #22
0
def image_page(album, filename, template='image'):
    image = Image(album, filename, current_app.config)
    show = Show(album, current_app.config, session)
    exif_manager = ExifManager(image)
    exif_array = exif_manager.get_exif()

    return render_themed(template + '.html',
                         album=album,
                         filename=filename,
                         exif=exif_array,
                         show=show)
Пример #23
0
def list_album(album, page, template="grid"):
    show = Show(album, current_app.config, session)
    ext = re.compile(".(jpg|png|gif|bmp)$", re.IGNORECASE)

    album_dir = os.path.join(current_app.config["ALBUMS_DIR"], album)
    all_files = [f for f in os.listdir(album_dir) if ext.search(f)]
    all_files.sort()

    if show.get_setting("reverse") == "yes":
        all_files.reverse()

    paginator = _paginated_overview(album, page, "admin.list_album", template)
    return render_themed(
        template + ".html",
        album=album,
        show=show,
        files=paginator.entries,
        paginator=paginator,
        page=page,
        all_files=all_files,
    )
Пример #24
0
def list_album(album, page, template='list'):
    if template in current_app.config['FRONTEND_LIST_TEMPLATES']:
        show = Show(album, current_app.config, session)
        paginator = get_paginator(album, page, 'frontend.list_album', template)
        return render_themed(template + '.html',
                             album=album,
                             show=show,
                             files=paginator.entries,
                             paginator=paginator,
                             page=page)
    else:
        abort(404)
Пример #25
0
def authenticate(album):
    """Check user credentials and initialize session"""
    show = Show(album)

    if request.method == 'POST':
        form = LoginForm(request.form)
        if form.validate():
            if show.check_auth(request.form['username'], current_app.config['SECRET_KEY'], request.form['password']):
                next_url = None
                if session.has_key('next_url'):
                    next_url = session['next_url']

                session.clear()

                session['username'] = request.form['username']
                session['album'] = album

                if next_url is not None:
                    session['next_url'] = next_url

                return True
    return False
Пример #26
0
def show_index():
    dir_list = os.listdir(current_app.config['ALBUMS_DIR'])
    full_album_list = [os.path.basename(album) for album in dir_list]
    shows = {}

    for album in full_album_list:
        show = Show(album, current_app.config, session)
        if show.is_enabled:
            shows[album] = show

    album_list = shows.keys()
    album_list.sort(reverse=True)

    return render_themed('index.html', albums=album_list, shows=shows)
Пример #27
0
def authenticate(album):
    """Check user credentials and initialize session"""
    show = Show(album, current_app.config, session)

    if request.method == 'POST':
        form = LoginForm()
        if form.validate_on_submit():
            if show.check_auth(request.form['username'],
                               current_app.config['SECRET_KEY'],
                               request.form['password']):
                next_url = None
                if session.has_key('next_url'):
                    next_url = session['next_url']

                session.clear()

                session['username'] = request.form['username']
                session['album'] = album

                if next_url is not None:
                    session['next_url'] = next_url

                return True
    return False
Пример #28
0
def sort_show_by_exifdate(album):
    """Sort the show by exif datetime """
    show = Show(album)
    show.sort_by_exif_datetime()
    return redirect(request.referrer or url_for('.index'))
Пример #29
0
def remove_image_from_show(album, filename):
    """Remove an image from the show"""
    show = Show(album)
    if show.remove_image(filename):
        return jsonify(result='OK')
    return jsonify(result='Failed')
Пример #30
0
def add_image_to_show(album, filename):
    """Add an image to the show"""
    show = Show(album)
    if show.add_image(filename):
        return jsonify(result='OK')
    return jsonify(result='Failed')
Пример #31
0
 def decorated_function(album, *args, **kwargs):
     show = Show(album)
     if show.need_authentication():
         session['next_url'] = request.url
         return redirect(url_for('.login', album=album))
     return f(album, *args, **kwargs)
Пример #32
0
def sort_show_by_exifdate(album):
    """Sort the show by exif datetime """
    show = Show(album, current_app.config, session)
    show.sort_by_exif_datetime().save()
    return goback(True)
Пример #33
0
def sort_show_by_filename(album):
    """Sort the show by filename """
    show = Show(album, current_app.config, session)
    show.sort_by_filename().save()
    return goback(True)
Пример #34
0
def show_remove_user(album, username):
    show = Show(album, current_app.config, session)
    show.remove_user(username).save()
    return jsonify(result='OK')
Пример #35
0
def sort_show_by_exifdate(album):
    """Sort the show by exif datetime """
    show = Show(album, current_app.config, session)
    show.sort_by_exif_datetime().save()
    return goback(True)
Пример #36
0
def sort_show_by_filename(album):
    """Sort the show by filename """
    show = Show(album, current_app.config, session)
    show.sort_by_filename().save()
    return goback(True)
Пример #37
0
def add_all_images_to_show(album):
    show = Show(album, current_app.config, session)
    show.add_all_images().save()
    return goback(True)
Пример #38
0
def add_all_images_to_show(album):
    show = Show(album)
    show.add_all_images()
    return redirect(request.referrer or url_for('.index'))
Пример #39
0
def show_change_setting(album, setting, value):
    show = Show(album)
    if (show.change_setting(setting, value) and show.save()):
        return jsonify(result='OK')
    else:
        return jsonify(result='Failed')
Пример #40
0
 def decorated_function(album, *args, **kwargs):
     show = Show(album, current_app.config, session)
     if show.need_authentication:
         session['next_url'] = request.url
         return redirect(url_for('.login', album=album))
     return f(album, *args, **kwargs)
Пример #41
0
def add_all_images_to_show(album):
    show = Show(album, current_app.config, session)
    show.add_all_images().save()
    return goback(True)
Пример #42
0
def show_remove_user(album, username):
    show = Show(album, current_app.config, session)
    show.remove_user(username).save()
    return jsonify(result="OK")