From 3109d92adea4585842e766c3b17ed5eac9912c0a Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Wed, 19 Apr 2023 16:32:53 -0600 Subject: [PATCH] Add nullable filter --- src/filters.rs | 6 ++++++ templates/division_list.html | 4 ++-- templates/game_list.html | 6 +++--- templates/game_score_page.html | 4 ++-- templates/league_list.html | 2 +- templates/player_page.html | 4 ++-- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/filters.rs b/src/filters.rs index 1eee67a..3d84195 100644 --- a/src/filters.rs +++ b/src/filters.rs @@ -3,3 +3,9 @@ pub fn seconds_as_time(secs: &i32) -> ::askama::Result { let seconds = secs % 60; Ok(format!("{}:{}", minutes, seconds)) } +pub fn nullable(ot: &Option) -> ::askama::Result { + match ot { + Some(t) => Ok(format!("{}", t)), + None => Ok("NULL".to_string()) + } +} diff --git a/templates/division_list.html b/templates/division_list.html index f84b44a..d6d402a 100644 --- a/templates/division_list.html +++ b/templates/division_list.html @@ -3,10 +3,10 @@ {% block title %}Divisions{% endblock %} {% block content %} -

Divisions for the {{ league.name }}

+

Divisions for the {{ league.name.clone().unwrap_or("???".to_string()) }}

{% endblock %} diff --git a/templates/game_list.html b/templates/game_list.html index c8e0fe3..248d055 100644 --- a/templates/game_list.html +++ b/templates/game_list.html @@ -1,16 +1,16 @@ {% extends "master.html" %} -{% block title %}Games for {{ division.name }}{% endblock %} +{% block title %}Games for {{ division.name.clone().unwrap_or("???".to_string()) }}{% endblock %} {% block content %} -

Division: {{ division.name }}

+

Division: {{ division.name|nullable }}

{% if games.len() > 0 %}

Points

{{ iihf_team_stats_table|safe }}

Games

    {% for game in games %} -
  1. {{ game.name }}
  2. +
  3. {{ game.name|nullable }}
  4. {% endfor %}
{% else %} diff --git a/templates/game_score_page.html b/templates/game_score_page.html index 0037b9e..ed3f3de 100644 --- a/templates/game_score_page.html +++ b/templates/game_score_page.html @@ -1,9 +1,9 @@ {% extends "master.html" %} -{% block title %}{{ game.name }}{% endblock %} +{% block title %}{{ game.name.clone().unwrap() }}{% endblock %} {% block content %} -

{{ localize("game-of-division", game: game.name.clone(), division: division.name.clone()) }}

+

{{ localize("game-of-division", game: game.name.clone().unwrap(), division: division.name.clone().unwrap()) }}

{{ localize("team") }}

{{ team_stats|safe }}

{{ localize("individual") }}

diff --git a/templates/league_list.html b/templates/league_list.html index a89e571..8da684b 100644 --- a/templates/league_list.html +++ b/templates/league_list.html @@ -6,7 +6,7 @@

{{ localize("league_ibihf") }}

    {% for league in leagues %} -
  1. {{ league.name }}
  2. +
  3. {{ league.name|nullable }}
  4. {% endfor %}
{% endblock %} diff --git a/templates/player_page.html b/templates/player_page.html index 0a7edc3..5bea5af 100644 --- a/templates/player_page.html +++ b/templates/player_page.html @@ -1,8 +1,8 @@ {% extends "master.html" %} {% block content %} -

{{ player.name }}

-

Latest Competition: {{ league.name }}

+

{{ player.first_names }}

+

Latest Competition: {{ league.name|nullable }}

{{ league_stats.points }}