make commas jinja filter

pull/225/head
Aevann 2024-03-09 13:39:13 +02:00
parent 9bd3afe632
commit a86ea63681
8 changed files with 22 additions and 18 deletions

View File

@ -101,6 +101,10 @@ def expand_art(url):
if id < MIN_ART_ID_FOR_HQ: return url
return f"{SITE_FULL_IMAGES}/asset_submissions/art/original/{id}.webp"
@app.template_filter("commas")
def commas(number):
return "{:,}".format(number)
def current_registered_users():
return "{:,}".format(g.db.query(User).count())

View File

@ -14,7 +14,7 @@
<tr>
<td>{{loop.index}}</td>
<td>{% include "user_in_table.html" %}</td>
<td>{{"{:,}".format(user.truescore)}}</td>
<td>{{user.truescore|commas}}</td>
</tr>
{% endfor %}
</table>

View File

@ -21,8 +21,8 @@
<td>{{loop.index}}</td>
<td>{% include "user_in_table.html" %}</td>
<td>{{5 if user.id == CARP_ID else user.admin_level}}</td>
<td>{{"{:,}".format(user.truescore)}}</td>
<td><a href="/log?admin={{user.username}}">{{"{:,}".format(user.modaction_num)}}</a></td>
<td>{{user.truescore|commas}}</td>
<td><a href="/log?admin={{user.username}}">{{user.modaction_num|commas}}</a></td>
</tr>
{% endfor %}
</table>

View File

@ -26,11 +26,11 @@
<li class="mt-2">Number of hats you bought: {{v.num_of_owned_hats}}</li>
<li>Number of hats you designed: {{v.num_of_designed_hats}}</li>
<li>Number of hats: {{num_of_hats}}</li>
<li>Currency you spent on hats: {{"{:,}".format(v.currency_spent_on_hats)}}</li>
<li>Total currency spent on hats: {{"{:,}".format(sales)}}</li>
<li>Your current coins: {{"{:,}".format(v.coins)}}</li>
<li>Currency you spent on hats: {{v.currency_spent_on_hats|commas}}</li>
<li>Total currency spent on hats: {{sales|commas}}</li>
<li>Your current coins: {{v.coins|commas}}</li>
{% if FEATURES['MARSEYBUX'] %}
<li>Your current marseybux: {{"{:,}".format(v.marseybux)}}</li>
<li>Your current marseybux: {{v.marseybux|commas}}</li>
{% endif %}
</ul>
</header>

View File

@ -38,9 +38,9 @@
<td>{{position_no}}</td>
<td>{% include "user_in_table.html" %}</td>
{% if user_relative_url is not none %}
<td><a href="/@{{user.username}}/{{user_relative_url}}">{{"{:,}".format(value)}}</a></td>
<td><a href="/@{{user.username}}/{{user_relative_url}}">{{value|commas}}</a></td>
{% else %}
<td>{{"{:,}".format(value)}}</td>
<td>{{value|commas}}</td>
{% endif %}
</tr>
{% endmacro %}

View File

@ -8,7 +8,7 @@
<p><b>Link:</b> <a href="{{option.parent.permalink}}">{{option.parent.permalink}}</a></p>
<p><b>Author:</b> <a href="{{option.parent.author.url}}">@{{option.parent.author_name}}</a></p>
<p><b>Author Created At:</b> <span data-time="{{option.parent.author.created_utc}}"></span></p>
<p><b>Author Truescore:</b> {{"{:,}".format(option.parent.author.truescore)}}</p>
<p><b>Author Truescore:</b> {{option.parent.author.truescore|commas}}</p>
<p><b>Total voter truescore: </b>{{total_ts}}</p>
{% if total_patrons != None %}
<p><b>Total {{patron}}s: </b>{{total_patrons}} | ${{total_money}}</p>
@ -33,7 +33,7 @@
{% include "user_in_table.html" %}
{% endwith %}
</td>
<td>{{"{:,}".format(vote.user.truescore)}}</td>
<td>{{vote.user.truescore|commas}}</td>
<td data-time="{{vote.created_utc}}"></td>
</tr>
{% endfor %}

View File

@ -26,11 +26,11 @@
<li>Number of lootboxes you bought: {{v.lootboxes_bought}}</li>
{% endif %}
<li>Number of awards you bought: {{v.num_of_bought_awards}}</li>
<li>Currency you spent on awards: {{"{:,}".format(v.currency_spent_on_awards)}}</li>
<li>Total currency spent on awards: {{"{:,}".format(sales)}}</li>
<li>Your current coins: {{"{:,}".format(v.coins)}}</li>
<li>Currency you spent on awards: {{v.currency_spent_on_awards|commas}}</li>
<li>Total currency spent on awards: {{sales|commas}}</li>
<li>Your current coins: {{v.coins|commas}}</li>
{% if FEATURES['MARSEYBUX'] %}
<li>Your current marseybux: {{"{:,}".format(v.marseybux)}}</li>
<li>Your current marseybux: {{v.marseybux|commas}}</li>
{% endif %}
<li>Your total award discount: {{v.formatted_award_discount}}</li>
</ul>

View File

@ -6,7 +6,7 @@
<p><a href="{{obj.permalink}}">{{obj.permalink}}</a></p>
<p><b>Author:</b> <a href="{{obj.author.url}}">@{{obj.author.username}}</a></p>
<p><b>Author Created At:</b> <span data-time="{{obj.author.created_utc}}"></span></p>
<p><b>Author Truescore:</b> {{"{:,}".format(obj.author.truescore)}}</p>
<p><b>Author Truescore:</b> {{obj.author.truescore|commas}}</p>
<p><b>Upvotes: </b>{{ups | length}}</p>
<p><b>Downvotes: </b>{{downs | length}}</p>
@ -30,7 +30,7 @@
{% include "user_in_table.html" %}
{% endwith %}
</td>
<td>{{"{:,}".format(vote.user.truescore)}}</td>
<td>{{vote.user.truescore|commas}}</td>
<td {% if vote.created_utc > 1599343262 %}data-time="{{vote.created_utc}}"{% endif %}></td>
</tr>
{% endfor %}
@ -57,7 +57,7 @@
{% include "user_in_table.html" %}
{% endwith %}
</td>
<td>{{"{:,}".format(vote.user.truescore)}}</td>
<td>{{vote.user.truescore|commas}}</td>
<td {% if vote.created_utc > 1599343262 %}data-time="{{vote.created_utc}}"{% endif %}></td>
</tr>
{% endfor %}