mirror of
https://github.com/FAUSheppy/tmnf-replay-server.git
synced 2025-12-06 07:01:37 +01:00
fix: current season selector tm2020
This commit is contained in:
28
server.py
28
server.py
@@ -22,6 +22,31 @@ app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
|||||||
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get("SQLITE_LOCATION") or "sqlite:///sqlite.db"
|
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get("SQLITE_LOCATION") or "sqlite:///sqlite.db"
|
||||||
db = SQLAlchemy(app)
|
db = SQLAlchemy(app)
|
||||||
|
|
||||||
|
SEASON_ORDERING = ["Spring", "Summer", "Fall", "Winter"]
|
||||||
|
def filter_for_current_season(maps):
|
||||||
|
|
||||||
|
maps = list(maps)
|
||||||
|
|
||||||
|
year = str(datetime.datetime.now().year)
|
||||||
|
|
||||||
|
season = 3
|
||||||
|
for m in maps:
|
||||||
|
|
||||||
|
if year not in m.mapname:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
for i, season_name in enumerate(SEASON_ORDERING):
|
||||||
|
print(i, season_name, m.mapname)
|
||||||
|
if season_name in m.mapname:
|
||||||
|
season = i
|
||||||
|
print(season)
|
||||||
|
|
||||||
|
print(SEASON_ORDERING[season])
|
||||||
|
print(maps)
|
||||||
|
maps_season = list(filter(lambda m: SEASON_ORDERING[season] in m.mapname, maps))
|
||||||
|
print(maps_season)
|
||||||
|
return maps_season
|
||||||
|
|
||||||
class Map(db.Model):
|
class Map(db.Model):
|
||||||
|
|
||||||
__tablename__ = "maps"
|
__tablename__ = "maps"
|
||||||
@@ -425,6 +450,9 @@ def mapnames():
|
|||||||
allowed = ("A", "B", "C", "D", "E", "Fall", "Winter", "Spring", "Summer")
|
allowed = ("A", "B", "C", "D", "E", "Fall", "Winter", "Spring", "Summer")
|
||||||
maps_filtered = filter(lambda m: m.mapname.startswith(allowed), maps)
|
maps_filtered = filter(lambda m: m.mapname.startswith(allowed), maps)
|
||||||
|
|
||||||
|
if settings.show_tm_2020_current:
|
||||||
|
maps_filtered = filter_for_current_season(maps_filtered)
|
||||||
|
|
||||||
return flask.render_template("index.html", maps=maps_filtered, player=player)
|
return flask.render_template("index.html", maps=maps_filtered, player=player)
|
||||||
|
|
||||||
@app.route("/open-info")
|
@app.route("/open-info")
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
{% include "upload-button.html" %}
|
{% include "upload-button.html" %}
|
||||||
|
|
||||||
<div class="user-settings">
|
<div class="user-settings">
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input class="form-check-input" type="checkbox" role="switch" id="show_tm_2020_current">
|
||||||
|
<label class="form-check-label" for="show_tm_2020_current">Only current TM2020</label>
|
||||||
|
</div>
|
||||||
<div class="form-check form-switch">
|
<div class="form-check form-switch">
|
||||||
<input class="form-check-input" type="checkbox" role="switch" id="show_tm_2020">
|
<input class="form-check-input" type="checkbox" role="switch" id="show_tm_2020">
|
||||||
<label class="form-check-label" for="show_tm_2020">Show All TM2020</label>
|
<label class="form-check-label" for="show_tm_2020">Show All TM2020</label>
|
||||||
|
|||||||
Reference in New Issue
Block a user