コード例 #1
0
ファイル: push.py プロジェクト: akfork/wifidog-auth-flask
            for message in pubsub.listen():
                if message['type'] == 'message':
                    yield 'data:%s\n\n' % message['data']
        except ConnectionError:
            while True:
                print('lost connection; trying to reconnect...')

                try:
                    redis.ping()
                except ConnectionError:
                    time.sleep(10)
                else:
                    pubsub.subscribe(channels)
                    break

@bp.route('/broadcast', methods=[ 'GET', 'POST' ])
@register_menu(bp, '.broadcast', 'Broadcast', visible_when=has_role('super-admin'), order=5)
def broadcast():
    form = BroadcastForm(flask.request.form)

    if form.validate_on_submit():
        redis.publish('notifications', form.message.data)
        flask.flash('Message published')
        return flask.redirect(flask.url_for('.broadcast'))

    return flask.render_template('broadcast.html', form=form)

@bp.route('/push')
def push():
    return flask.Response(event_stream(), mimetype='text/event-stream')
コード例 #2
0
 def push_is_visible():
     return flask.current_app.config.get('PUSH_ENABLED') and has_role('super-admin')
コード例 #3
0
            redis.publish('notifications', form.message.data)
            flask.flash('Message published')
            return flask.redirect(flask.url_for('.broadcast'))

        return flask.render_template('broadcast.html', form=form)

    @bp.route('/push')
    @login_required
    @roles_required('super-admin')
    def push():
        return flask.Response(event_stream(), mimetype='text/event-stream')

@bp.route('/networks')
@login_required
@roles_required('super-admin')
@register_menu(bp, '.networks', 'Networks', visible_when=has_role('super-admin'), order=10)
def networks_index():
    return flask.render_template('networks/index.html')

@bp.route('/networks/new', methods=[ 'GET', 'POST' ])
@login_required
@roles_required('super-admin')
def networks_new():
    network = Network()
    form = NetworkForm(flask.request.form, network)

    if form.validate_on_submit():
        form.populate_obj(network)
        db.session.add(network)
        db.session.commit()
コード例 #4
0
ファイル: views.py プロジェクト: akfork/wifidog-auth-flask
 def push_is_visible():
     return flask.current_app.config.get('PUSH_ENABLED') and has_role(
         'super-admin')
コード例 #5
0
ファイル: views.py プロジェクト: akfork/wifidog-auth-flask
        return flask.render_template('broadcast.html', form=form)

    @bp.route('/push')
    @login_required
    @roles_required('super-admin')
    def push():
        return flask.Response(event_stream(), mimetype='text/event-stream')


@bp.route('/networks')
@login_required
@roles_required('super-admin')
@register_menu(bp,
               '.networks',
               'Networks',
               visible_when=has_role('super-admin'),
               order=10)
def networks_index():
    return flask.render_template('networks/index.html')


@bp.route('/networks/new', methods=['GET', 'POST'])
@login_required
@roles_required('super-admin')
def networks_new():
    network = Network()
    form = NetworkForm(flask.request.form, network)

    if form.validate_on_submit():
        form.populate_obj(network)
        db.session.add(network)
コード例 #6
0
ファイル: views.py プロジェクト: frankiegu/wifidog-auth-flask
            redis.publish('notifications', form.message.data)
            flask.flash('Message published')
            return flask.redirect(flask.url_for('.broadcast'))

        return flask.render_template('broadcast.html', form=form)

    @bp.route('/push')
    @login_required
    @roles_required('super-admin')
    def push():
        return flask.Response(event_stream(), mimetype='text/event-stream')

@bp.route('/networks')
@login_required
@roles_required('super-admin')
@register_menu(bp, '.networks', 'Networks', visible_when=has_role('super-admin'), order=10)
def networks_index():
    return flask.render_template('networks/index.html')

@bp.route('/networks/new', methods=[ 'GET', 'POST' ])
@login_required
@roles_required('super-admin')
def networks_new():
    network = Network()
    form = NetworkForm(flask.request.form, network)

    if form.validate_on_submit():
        form.populate_obj(network)
        db.session.add(network)
        db.session.commit()