Compare commits

...

4 Commits

Author SHA1 Message Date
e54f70eaac fix: correct ordering & remove debug prints
Some checks failed
Container Build for tmnf-replay-server / docker (push) Failing after 11s
2025-07-13 12:12:03 +02:00
a40bf057ee fix: don't use inbuild function name 2025-07-13 11:45:16 +02:00
807860351d whitespaces: trailing spaces 2025-07-13 11:45:03 +02:00
d89ccf42ff fix: current season selector tm2020 2025-07-13 11:44:33 +02:00
2 changed files with 33 additions and 5 deletions

View File

@@ -22,6 +22,27 @@ app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get("SQLITE_LOCATION") or "sqlite:///sqlite.db"
db = SQLAlchemy(app)
SEASON_ORDERING = ["Winter", "Spring", "Summer", "Fall"]
def filter_for_current_season(maps):
maps = list(maps)
year = str(datetime.datetime.now().year)
season = 0
for m in maps:
if year not in m.mapname:
continue
else:
for i, season_name in enumerate(SEASON_ORDERING):
if season_name in m.mapname and i > season:
season = i
filter_func = lambda m: SEASON_ORDERING[season] in m.mapname and year in m.mapname
maps_season = list(filter(filter_func, maps))
return maps_season
class Map(db.Model):
__tablename__ = "maps"
@@ -388,7 +409,7 @@ def ranks():
@app.route("/map-info")
def list():
def map_info():
player = flask.request.headers.get("X-Forwarded-Preferred-Username")
header_col = ["Player", "Time", "Date", "Replay"]
map_uid = flask.request.args.get("map_uid")
@@ -425,6 +446,9 @@ def mapnames():
allowed = ("A", "B", "C", "D", "E", "Fall", "Winter", "Spring", "Summer")
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)
@app.route("/open-info")

View File

@@ -5,6 +5,10 @@
{% include "upload-button.html" %}
<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">
<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>