Add option to filter launches by orbit
This commit is contained in:
parent
8032cd2ed4
commit
23aa70bb84
|
@ -39,6 +39,21 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>Orbit:
|
||||||
|
{% if request.args.orbit %}<a href="{{ request.path }}">🗙</a>{% endif %}
|
||||||
|
|
||||||
|
{% for name, abbrev in orbits | sort %}
|
||||||
|
{% if abbrev == request.args.orbit %}
|
||||||
|
<strong>{{ name }}</strong>
|
||||||
|
{% else %}
|
||||||
|
<a href="?orbit={{ abbrev }}" class="text-nowrap">
|
||||||
|
{{ name }}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if not loop.last %} | {% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</p>
|
||||||
|
|
||||||
{% for launch in launches %}
|
{% for launch in launches %}
|
||||||
{% set highlight =" bg-primary-subtle" if launch.slug in config.FOLLOW_LAUNCHES else "" %}
|
{% set highlight =" bg-primary-subtle" if launch.slug in config.FOLLOW_LAUNCHES else "" %}
|
||||||
{% set country = get_country(launch.country_code) %}
|
{% set country = get_country(launch.country_code) %}
|
||||||
|
|
12
web_view.py
12
web_view.py
|
@ -150,14 +150,21 @@ def launch_list() -> str:
|
||||||
data_dir = app.config["DATA_DIR"]
|
data_dir = app.config["DATA_DIR"]
|
||||||
rocket_dir = os.path.join(data_dir, "thespacedevs")
|
rocket_dir = os.path.join(data_dir, "thespacedevs")
|
||||||
launches = agenda.thespacedevs.get_launches(rocket_dir, limit=100)
|
launches = agenda.thespacedevs.get_launches(rocket_dir, limit=100)
|
||||||
|
assert launches
|
||||||
|
|
||||||
mission_type_filter = flask.request.args.get("type")
|
mission_type_filter = flask.request.args.get("type")
|
||||||
rocket_filter = flask.request.args.get("rocket")
|
rocket_filter = flask.request.args.get("rocket")
|
||||||
|
orbit_filter = flask.request.args.get("orbit")
|
||||||
|
|
||||||
mission_types = {
|
mission_types = {
|
||||||
launch["mission"]["type"] for launch in launches if launch["mission"]
|
launch["mission"]["type"] for launch in launches if launch["mission"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
orbits = {
|
||||||
|
(launch["orbit"]["name"], launch["orbit"]["abbrev"])
|
||||||
|
for launch in launches
|
||||||
|
if launch.get("orbit")
|
||||||
|
}
|
||||||
rockets = {launch["rocket"]["full_name"] for launch in launches}
|
rockets = {launch["rocket"]["full_name"] for launch in launches}
|
||||||
|
|
||||||
launches = [
|
launches = [
|
||||||
|
@ -168,6 +175,10 @@ def launch_list() -> str:
|
||||||
or (launch["mission"] and launch["mission"]["type"] == mission_type_filter)
|
or (launch["mission"] and launch["mission"]["type"] == mission_type_filter)
|
||||||
)
|
)
|
||||||
and (not rocket_filter or launch["rocket"]["full_name"] == rocket_filter)
|
and (not rocket_filter or launch["rocket"]["full_name"] == rocket_filter)
|
||||||
|
and (
|
||||||
|
not orbit_filter
|
||||||
|
or (launch.get("orbit") and launch["orbit"]["abbrev"] == orbit_filter)
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
return flask.render_template(
|
return flask.render_template(
|
||||||
|
@ -177,6 +188,7 @@ def launch_list() -> str:
|
||||||
now=now,
|
now=now,
|
||||||
get_country=agenda.get_country,
|
get_country=agenda.get_country,
|
||||||
mission_types=mission_types,
|
mission_types=mission_types,
|
||||||
|
orbits=orbits,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue