Skip to content

Commit

Permalink
Round up in profile
Browse files Browse the repository at this point in the history
  • Loading branch information
vas3k committed Jan 5, 2021
1 parent a3ce519 commit 5eff8d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 6 additions & 6 deletions frontend/html/users/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
</div>
<a href="{% url "edit_payments" user.slug %}" class="profile-status">
{% if user.membership_days_left < 150 %}
<span class="profile-status-number">{% if user.membership_days_left < 10 %}😱{% else %}😋{% endif %} {{ user.membership_days_left | cool_number }}</span>
<span class="profile-status-text">{{ user.membership_days_left | rupluralize:"день,дня,дней" }}</span>
<span class="profile-status-number">{% if user.membership_days_left < 10 %}😱{% else %}😋{% endif %} {{ user.membership_days_left | ceil | cool_number }}</span>
<span class="profile-status-text">{{ user.membership_days_left | ceil | rupluralize:"день,дня,дней" }}</span>
{% elif user.membership_days_left < 700 %}
<span class="profile-status-number">😎 {{ user.membership_months_left | cool_number }}</span>
<span class="profile-status-text">{{ user.membership_months_left | rupluralize:"месяц,месяца,месяцев" }}</span>
<span class="profile-status-number">😎 {{ user.membership_months_left | ceil | cool_number }}</span>
<span class="profile-status-text">{{ user.membership_months_left | ceil | rupluralize:"месяц,месяца,месяцев" }}</span>
{% else %}
<span class="profile-status-number">💎 {{ user.membership_years_left | cool_number }}</span>
<span class="profile-status-text">{{ user.membership_years_left | rupluralize:"год,года,лет" }}</span>
<span class="profile-status-number">💎 {{ user.membership_years_left | ceil | cool_number }}</span>
<span class="profile-status-text">{{ user.membership_years_left | ceil | rupluralize:"год,года,лет" }}</span>
{% endif %}
</a>
<a href="{% url "edit_notifications" user.slug %}" class="profile-status">
Expand Down
6 changes: 6 additions & 0 deletions posts/templatetags/text_filters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import math
from datetime import datetime, timedelta

from django import template
Expand Down Expand Up @@ -28,6 +29,11 @@ def markdown(text):
return mark_safe(markdown_text(text))


@register.filter
def ceil(value):
return math.ceil(value or 0)


@register.filter
def cool_number(value, num_decimals=1):
"""
Expand Down

0 comments on commit 5eff8d3

Please sign in to comment.