Exemple #1
0
def loop_list(page):
    if request.method == 'POST':
        if request.form.get('action') == 'add':
        #           try:
            spl = request.form.get('begin').split(':')
            begin = int(int(spl[0]) * 100 + (int(spl[1]) / 60.) * 100)
            spl = request.form.get('end').split(':')
            end = math.ceil(int(spl[0]) * 100 + (int(spl[1]) / 60.) * 100)
            if end == begin and end == 0:
                end = 2400
            loop = Loop(begin=begin, end=end, filename=request.form.get('filename'))
            rfk.database.session.add(loop)
            rfk.database.session.commit()
        #            except Exception as e:
        #                flash('error while inserting Loop')
        elif request.form.get('action') == 'delete':
            try:
                rfk.database.session.delete(Loop.query.get(request.form.get('loopid')))
                rfk.database.session.commit()
            except Exception as e:
                flash('error while deleting Loop')
    per_page = 25
    (result, total_count) = paginate_query(Loop.query, page=page)
    current_loop = Loop.get_current_loop()
    loops = []
    for loop in result:
        loops.append({'loop': loop.loop,
                      'begin': '%02d:%02d' % (int(loop.begin / 100), int(((loop.begin % 100) / 100.) * 60)),
                      'end': '%02d:%02d' % (int(loop.end / 100), int(((loop.end % 100) / 100.) * 60)),
                      'current': loop == current_loop,
                      'filename': loop.filename,
                      'file_missing': not (loop.file_exists)})
    pagination = Pagination(page, per_page, total_count)
    searchpath = get_path(rfk.CONFIG.get('liquidsoap', 'looppath'))
    return render_template('admin/loops/list.html', loops=loops, pagination=pagination, searchpath=searchpath)
Exemple #2
0
def user_list(page):
    per_page = 25
    (users, total_count) = paginate_query(User.query.order_by(
        User.register_date.asc()),
                                          page=page)
    pagination = Pagination(page, per_page, total_count)
    return render_template('admin/user/list.html',
                           users=users,
                           pagination=pagination)
Exemple #3
0
def log_list(page):
    per_page = 25
    (logs,
     total_count) = paginate_query(Log.query.order_by(Log.timestamp.desc()),
                                   page=page)
    pagination = Pagination(page, per_page, total_count)
    return render_template('admin/logs_list.html',
                           logs=logs,
                           pagination=pagination)
Exemple #4
0
def history(page):
    per_page = 25
    (tracks, total_count) = paginate_query(
        Track.query.join(Show).join(UserShow).order_by(Track.end.desc()),
        page=page,
        per_page=per_page)
    pagination = Pagination(page, per_page, total_count)
    return render_template('history.html',
                           tracks=tracks,
                           pagination=pagination,
                           TITLE=gettext('History'))
Exemple #5
0
def loop_list(page):
    if request.method == 'POST':
        if request.form.get('action') == 'add':
            #           try:
            spl = request.form.get('begin').split(':')
            begin = int(int(spl[0]) * 100 + (int(spl[1]) / 60.) * 100)
            spl = request.form.get('end').split(':')
            end = math.ceil(int(spl[0]) * 100 + (int(spl[1]) / 60.) * 100)
            if end == begin and end == 0:
                end = 2400
            loop = Loop(begin=begin,
                        end=end,
                        filename=request.form.get('filename'))
            rfk.database.session.add(loop)
            rfk.database.session.commit()
        #            except Exception as e:
        #                flash('error while inserting Loop')
        elif request.form.get('action') == 'delete':
            try:
                rfk.database.session.delete(
                    Loop.query.get(request.form.get('loopid')))
                rfk.database.session.commit()
            except Exception as e:
                flash('error while deleting Loop')
    per_page = 25
    (result, total_count) = paginate_query(Loop.query, page=page)
    current_loop = Loop.get_current_loop()
    loops = []
    for loop in result:
        loops.append({
            'loop':
            loop.loop,
            'begin':
            '%02d:%02d' %
            (int(loop.begin / 100), int(((loop.begin % 100) / 100.) * 60)),
            'end':
            '%02d:%02d' %
            (int(loop.end / 100), int(((loop.end % 100) / 100.) * 60)),
            'current':
            loop == current_loop,
            'filename':
            loop.filename,
            'file_missing':
            not (loop.file_exists)
        })
    pagination = Pagination(page, per_page, total_count)
    searchpath = get_path(rfk.CONFIG.get('liquidsoap', 'looppath'))
    return render_template('admin/loops/list.html',
                           loops=loops,
                           pagination=pagination,
                           searchpath=searchpath)
Exemple #6
0
def log_list(page):
    per_page = 25
    (logs, total_count) = paginate_query(Log.query.order_by(Log.timestamp.desc()), page=page)
    pagination = Pagination(page, per_page, total_count)
    return render_template('admin/logs_list.html', logs=logs, pagination=pagination)
Exemple #7
0
def history(page):
    per_page = 25
    (tracks, total_count) = paginate_query(Track.query.join(Show).join(UserShow).order_by(Track.end.desc()), page=page, per_page=per_page)
    pagination = Pagination(page, per_page, total_count)
    return render_template('history.html', tracks=tracks, pagination=pagination, TITLE='History')
Exemple #8
0
def user_list(page):
    per_page = 25
    (users, total_count) = paginate_query(User.query.order_by(User.register_date.asc()), page=page)
    pagination = Pagination(page, per_page, total_count)
    return render_template('admin/user/list.html', users=users, pagination=pagination)