lots of typing fixes
This commit is contained in:
parent
51f580a304
commit
3665c34961
43 changed files with 260 additions and 178 deletions
|
@ -1,6 +1,8 @@
|
|||
from datetime import datetime
|
||||
from typing import Optional, List
|
||||
|
||||
from flask import render_template, url_for, flash, redirect, Response, Blueprint
|
||||
from flask.typing import ResponseReturnValue
|
||||
from flask_wtf import FlaskForm
|
||||
from sqlalchemy import exc
|
||||
from wtforms import SelectField, StringField, IntegerField, SubmitField
|
||||
|
@ -14,7 +16,7 @@ from app.portal.util import response_404, view_lifecycle
|
|||
bp = Blueprint("bridgeconf", __name__)
|
||||
|
||||
|
||||
class NewBridgeConfForm(FlaskForm):
|
||||
class NewBridgeConfForm(FlaskForm): # type: ignore
|
||||
provider = SelectField('Provider', validators=[DataRequired()])
|
||||
method = SelectField('Distribution Method', validators=[DataRequired()])
|
||||
description = StringField('Description')
|
||||
|
@ -23,15 +25,15 @@ class NewBridgeConfForm(FlaskForm):
|
|||
submit = SubmitField('Save Changes')
|
||||
|
||||
|
||||
class EditBridgeConfForm(FlaskForm):
|
||||
class EditBridgeConfForm(FlaskForm): # type: ignore
|
||||
description = StringField('Description')
|
||||
number = IntegerField('Number', validators=[NumberRange(1, message="One or more bridges must be created")])
|
||||
submit = SubmitField('Save Changes')
|
||||
|
||||
|
||||
@bp.route("/list")
|
||||
def bridgeconf_list():
|
||||
bridgeconfs = BridgeConf.query.filter(BridgeConf.destroyed == None).all()
|
||||
def bridgeconf_list() -> ResponseReturnValue:
|
||||
bridgeconfs: List[BridgeConf] = BridgeConf.query.filter(BridgeConf.destroyed == None).all()
|
||||
return render_template("list.html.j2",
|
||||
section="bridgeconf",
|
||||
title="Tor Bridge Configurations",
|
||||
|
@ -42,7 +44,7 @@ def bridgeconf_list():
|
|||
|
||||
@bp.route("/new", methods=['GET', 'POST'])
|
||||
@bp.route("/new/<group_id>", methods=['GET', 'POST'])
|
||||
def bridgeconf_new(group_id=None):
|
||||
def bridgeconf_new(group_id: Optional[int] = None) -> ResponseReturnValue:
|
||||
form = NewBridgeConfForm()
|
||||
form.group.choices = [(x.id, x.group_name) for x in Group.query.all()]
|
||||
form.provider.choices = [
|
||||
|
@ -82,7 +84,7 @@ def bridgeconf_new(group_id=None):
|
|||
|
||||
|
||||
@bp.route('/edit/<bridgeconf_id>', methods=['GET', 'POST'])
|
||||
def bridgeconf_edit(bridgeconf_id):
|
||||
def bridgeconf_edit(bridgeconf_id: int) -> ResponseReturnValue:
|
||||
bridgeconf = BridgeConf.query.filter(BridgeConf.id == bridgeconf_id).first()
|
||||
if bridgeconf is None:
|
||||
return Response(render_template("error.html.j2",
|
||||
|
@ -107,7 +109,7 @@ def bridgeconf_edit(bridgeconf_id):
|
|||
|
||||
|
||||
@bp.route("/destroy/<bridgeconf_id>", methods=['GET', 'POST'])
|
||||
def bridgeconf_destroy(bridgeconf_id: int):
|
||||
def bridgeconf_destroy(bridgeconf_id: int) -> ResponseReturnValue:
|
||||
bridgeconf = BridgeConf.query.filter(BridgeConf.id == bridgeconf_id, BridgeConf.destroyed == None).first()
|
||||
if bridgeconf is None:
|
||||
return response_404("The requested bridge configuration could not be found.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue