def id_settings(id): form = AddForm() account = get_accounts(id) if form.validate_on_submit(): if form.delete.data: if account_del(id): message = u'删除账号%s :成功!' % account[0]['name'] flash(message, 'success') return redirect(url_for('dial.index')) if form.save.data: if account_update(form, id): flash(u'修改账号配置成功!', 'success') return redirect(url_for('dial.id_settings', id=id)) return render_template('dial/view.html', account=account[0], form=form)
def add(): settings = Settings.query.get(1) if not settings: flash(u'提示:请先进行「设置」再添加VPN 账号。', 'alert') return redirect(url_for('dial.settings')) form = AddForm() if form.validate_on_submit(): if not Account.query.filter_by(name=form.name.data).first(): if account_update(form): message = u'添加VPN 拨号账号成功!' flash(message, 'success') return redirect(url_for('dial.index')) else: message = u'该账号已经存在:%s' % form.name.data flash(message, 'alert') return render_template('dial/add.html', form=form)