예제 #1
0
def step_one():
    user = flask_security.current_user
    if user.has_role("admin"):
        return flask.redirect(flask.url_for("admin.index"))
    if not user.is_anonymous:
        return flask.redirect(flask.url_for("manage.actions"))
    if flask.request.method == "POST":
        if flask.request.form.getlist("action"):
            actions = flask.request.form.getlist("action", type=int)
            flask.session["actions"] = actions
            return flask.redirect(utils.get_redirect(".step_two"))
        else:
            message = "Uh oh. You need to pick at least one action."
            flask.flash(message, "error")
    return flask.render_template("step_one.html", methods=models.approved_methods())
예제 #2
0
def step_one():
    user = flask.ext.security.current_user
    if user.has_role('admin'):
        return flask.redirect(flask.url_for('admin.index'))
    if not user.is_anonymous():
        return flask.redirect(flask.url_for('manage.actions'))
    if flask.request.method == 'POST':
        if flask.request.form.getlist('action'):
            actions = flask.request.form.getlist('action', type=int)
            flask.session['actions'] = actions
            return flask.redirect(utils.get_redirect('.step_two'))
        else:
            message = 'Uh oh. You need to pick at least one action.'
            flask.flash(message, 'error')
    return flask.render_template('step_one.html',
                                 methods=models.approved_methods())
예제 #3
0
def step_two():
    user = flask.ext.security.current_user
    if user.has_role('admin'):
        return flask.redirect(flask.url_for('admin.index'))
    if not user.is_anonymous():
        return flask.redirect(flask.url_for('manage.schedule'))
    if not flask.session.get('actions'):
        return flask.redirect(flask.url_for('.step_one'))
    form = forms.ScheduleForm()
    if form.validate_on_submit():
        flask.session.update(form.data)
        return flask.redirect(utils.get_redirect('.step_three'))
    for key in (x for x in flask.session if hasattr(form, x)):
        value = flask.session[key]
        if key == 'minute':
            value = '{:02d}'.format(int(value))
        getattr(form, key).data = value
    return flask.render_template('step_two.html', form=form,
                                 back=flask.url_for('.step_one'))
예제 #4
0
def step_two():
    user = flask_security.current_user
    if user.has_role("admin"):
        return flask.redirect(flask.url_for("admin.index"))
    if not user.is_anonymous:
        return flask.redirect(flask.url_for("manage.schedule"))
    if not flask.session.get("actions"):
        return flask.redirect(flask.url_for(".step_one"))
    form = forms.ScheduleForm()
    if form.validate_on_submit():
        flask.session.update(form.data)
        return flask.redirect(utils.get_redirect(".step_three"))
    for key in (x for x in flask.session if hasattr(form, x)):
        value = flask.session[key]
        if key == "minute":
            value = "{:02d}".format(int(value))
        getattr(form, key).data = value
    return flask.render_template(
        "step_two.html", form=form, back=flask.url_for(".step_one")
    )