Add nullable filter

master
Tait Hoyem 1 year ago
parent 21ad6975b8
commit 3109d92ade

@ -3,3 +3,9 @@ pub fn seconds_as_time(secs: &i32) -> ::askama::Result<String> {
let seconds = secs % 60;
Ok(format!("{}:{}", minutes, seconds))
}
pub fn nullable<T: std::fmt::Display>(ot: &Option<T>) -> ::askama::Result<String> {
match ot {
Some(t) => Ok(format!("{}", t)),
None => Ok("NULL".to_string())
}
}

@ -3,10 +3,10 @@
{% block title %}Divisions{% endblock %}
{% block content %}
<h1 id="first-heading">Divisions for the {{ league.name }}</h1>
<h1 id="first-heading">Divisions for the {{ league.name.clone().unwrap_or("???".to_string()) }}</h1>
<ul aria-labelledby="first-heading">
{% for division in divisions %}
<li><a href="/{{ lang }}/division/{{ division.id }}/">{{ division.name }}</a></li>
<li><a href="/{{ lang }}/division/{{ division.id }}/">{{ division.name.clone().unwrap_or("???".to_string()) }}</a></li>
{% endfor %}
</ul>
{% endblock %}

@ -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 %}
<h1>Division: {{ division.name }}</h1>
<h1>Division: {{ division.name|nullable }}</h1>
{% if games.len() > 0 %}
<h2 id="iihf_points">Points</h2>
{{ iihf_team_stats_table|safe }}
<h2 id="games">Games</h2>
<ol aria-labelledby="games">
{% for game in games %}
<li><a href="{{ localize("game_url_tmpl", lang: lang, id: game.id) }}">{{ game.name }}</a></li>
<li><a href="{{ localize("game_url_tmpl", lang: lang, id: game.id) }}">{{ game.name|nullable }}</a></li>
{% endfor %}
</ol>
{% else %}

@ -1,9 +1,9 @@
{% extends "master.html" %}
{% block title %}{{ game.name }}{% endblock %}
{% block title %}{{ game.name.clone().unwrap() }}{% endblock %}
{% block content %}
<h1>{{ localize("game-of-division", game: game.name.clone(), division: division.name.clone()) }}</h1>
<h1>{{ localize("game-of-division", game: game.name.clone().unwrap(), division: division.name.clone().unwrap()) }}</h1>
<h2>{{ localize("team") }}</h2>
{{ team_stats|safe }}
<h2>{{ localize("individual") }}</h2>

@ -6,7 +6,7 @@
<h1 id="leagues">{{ localize("league_ibihf") }}</h1>
<ol aria-labelledby="leagues">
{% for league in leagues %}
<li><a href="/{{ lang }}/league/{{ league.id }}/">{{ league.name }}</a></li>
<li><a href="/{{ lang }}/league/{{ league.id }}/">{{ league.name|nullable }}</a></li>
{% endfor %}
</ol>
{% endblock %}

@ -1,8 +1,8 @@
{% extends "master.html" %}
{% block content %}
<h1>{{ player.name }}</h1>
<h2>Latest Competition: {{ league.name }}</h2>
<h1>{{ player.first_names }}</h1>
<h2>Latest Competition: {{ league.name|nullable }}</h2>
<label for="league_points">Points</label>
<span id="league_points">{{ league_stats.points }}</span>
<label for="league_goals">Goals</label>

Loading…
Cancel
Save