Skip to content

Commit

Permalink
hotfix to V2
Browse files Browse the repository at this point in the history
  • Loading branch information
SLey3 committed Nov 2, 2023
1 parent 3ca9f4d commit 4cb8cfb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions routelookup/data/data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AIRLINE: None
4 changes: 2 additions & 2 deletions routelookup/form_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ def AirlineRequired(url):
"""
Validates whether the form data matches a valid airline or not
"""
message = f"""Must be an airline ICAO code.
message = f"""Must be a valid airline.
Please refer to:
<a id="err-icao" href="{url}" class="link-danger">List of Airlines</a>
for a list of airlines with ICAO codes listed."""

def _airline(form, field):
airline = get_airline(field.data)
airline = get_airline(field.data.capitalize())

if not airline:
raise ValidationError(message)
Expand Down
3 changes: 1 addition & 2 deletions routelookup/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from wtforms.widgets import html_params

from Config import config
from form_validators import AtLength


# widget and field
Expand Down Expand Up @@ -62,7 +61,7 @@ def process_formdata(self, data):
# forms
class AirlineInitForm(FlaskForm):
initializer = StringField(
validators=[InputRequired("Missing Input"), AtLength(3, "ICAO code")],
validators=[InputRequired("Missing Input")],
id="airline-input",
render_kw={
"class": "form-control-sm",
Expand Down
3 changes: 2 additions & 1 deletion routelookup/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Config_NavigraphEnableForm,
Config_RefreshTable,
)
from routeparser import get_airline

# routes
FOLDER_DIR = Path(__file__).resolve().parent / "templates"
Expand All @@ -35,7 +36,7 @@ def main():
init_form.add_validator_to("initializer", AirlineRequired(url_for("api.airlines")))

if init_form.validate_on_submit():
icao = init_form.initializer.data.capitalize()
icao = get_airline(init_form.initializer.data.capitalize())["ICAO"]

return redirect(url_for("api.generate", icao=icao), code=307)

Expand Down

0 comments on commit 4cb8cfb

Please sign in to comment.