Add filters for space launches
This commit is contained in:
parent
c41bcc3304
commit
b65d79cb63
3 changed files with 66 additions and 6 deletions
28
web_view.py
28
web_view.py
|
|
@ -145,10 +145,34 @@ def launch_list() -> str:
|
|||
now = datetime.now()
|
||||
data_dir = app.config["DATA_DIR"]
|
||||
rocket_dir = os.path.join(data_dir, "thespacedevs")
|
||||
rockets = agenda.thespacedevs.get_launches(rocket_dir, limit=100)
|
||||
launches = agenda.thespacedevs.get_launches(rocket_dir, limit=100)
|
||||
|
||||
mission_type_filter = flask.request.args.get("type")
|
||||
rocket_filter = flask.request.args.get("rocket")
|
||||
|
||||
mission_types = {
|
||||
launch["mission"]["type"] for launch in launches if launch["mission"]
|
||||
}
|
||||
|
||||
rockets = {launch["rocket"]["full_name"] for launch in launches}
|
||||
|
||||
launches = [
|
||||
launch
|
||||
for launch in launches
|
||||
if (
|
||||
not mission_type_filter
|
||||
or (launch["mission"] and launch["mission"]["type"] == mission_type_filter)
|
||||
)
|
||||
and (not rocket_filter or launch["rocket"]["full_name"] == rocket_filter)
|
||||
]
|
||||
|
||||
return flask.render_template(
|
||||
"launches.html", rockets=rockets, now=now, get_country=agenda.get_country
|
||||
"launches.html",
|
||||
launches=launches,
|
||||
rockets=rockets,
|
||||
now=now,
|
||||
get_country=agenda.get_country,
|
||||
mission_types=mission_types,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue