예제 #1
0
def editalert():
    form = EditAlertForm()
    user = current_user
    if form.validate_on_submit():
        user.hrs = form.hrs.data
        user.pop = form.pop.data
        db.session.add(user)
        db.session.commit()
        flash('Your changes have been saved.')
        return redirect(url_for('index'))
    elif request.method != "POST":
        form.hrs.data = user.hrs
        form.pop.data = user.pop
    return render_template('editalert.html', form=form)
예제 #2
0
파일: views.py 프로젝트: payoung/cl-app
def editalert(alertname):
    form = EditAlertForm()
    alert = db_session.query(Alert).filter_by(user=current_user, name=alertname).first()
    if form.validate_on_submit():
        alert.name = form.name.data
        alert.link = form.link.data
        alert.interval = form.interval.data
        alert.email = form.email.data
        alert.text = form.text.data
        alert.status = form.status.data
        db_session.add(alert)
        db_session.commit()
        flash('Your changes have been saved.')
        return redirect(url_for('editalert', alertname=alert.name))
    elif request.method != "POST":
        form.name.data = alert.name
        form.link.data = alert.link
        form.interval.data = alert.interval
        form.email.data = alert.email
        form.text.data = alert.text
        form.status.data = alert.status
    return render_template('editalert.html', form=form)
예제 #3
0
파일: views.py 프로젝트: payoung/cl-app
def editalert(alertname):
    form = EditAlertForm()
    alert = db_session.query(Alert).filter_by(user=current_user,
                                              name=alertname).first()
    if form.validate_on_submit():
        alert.name = form.name.data
        alert.link = form.link.data
        alert.interval = form.interval.data
        alert.email = form.email.data
        alert.text = form.text.data
        alert.status = form.status.data
        db_session.add(alert)
        db_session.commit()
        flash('Your changes have been saved.')
        return redirect(url_for('editalert', alertname=alert.name))
    elif request.method != "POST":
        form.name.data = alert.name
        form.link.data = alert.link
        form.interval.data = alert.interval
        form.email.data = alert.email
        form.text.data = alert.text
        form.status.data = alert.status
    return render_template('editalert.html', form=form)