Skip to content

Commit

Permalink
fix(contributors): fix 'for the past month' filter on contributors page
Browse files Browse the repository at this point in the history
Resolved issue #293 where the 'for the past month' filter on the contributors page was not working as expected.
  • Loading branch information
NikGor committed Aug 15, 2023
1 parent d74651a commit 7097d56
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
1 change: 1 addition & 0 deletions contributors/views/contributors_for_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def get_context_data(self, **kwargs):
"""Add context."""
context = super().get_context_data(**kwargs)
context['dt_month_ago'] = misc.datetime_month_ago()
context['is_week'] = self.extra_context.get('period') == 'week'
return context

def get_queryset(self): # noqa: WPS615
Expand Down
Binary file modified locale/ru/LC_MESSAGES/django.mo
Binary file not shown.
4 changes: 4 additions & 0 deletions locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@ msgstr "Пул-реквесты по"
msgid "Contributors for month"
msgstr "Участники за месяц"

#: templates/contributors_for_period.html
msgid "Contributors for week"
msgstr "Участники за неделю"

#: templates/home.html
msgid "Top 10 contributors"
msgstr "Топ 10 участников"
Expand Down
2 changes: 1 addition & 1 deletion templates/components/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{% trans "Contributors" %}
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="{% url 'contributors:contributors_for_month' %}">{% trans "For period" %}</a>
<a class="dropdown-item" href="{% url 'contributors:contributors_for_week' %}">{% trans "For period" %}</a>
<a class="dropdown-item" href="{% url 'contributors:contributors_list' %}">{% trans "All-time" %}</a>
</div>
</li>
Expand Down
18 changes: 6 additions & 12 deletions templates/components/time_note.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@

<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link time-note py-1 active" href="#"
name="top-week">
{% trans "for the past week" %}
</a>
<a class="nav-link time-note py-1 {% if is_week %}active{% endif %}" href="{% url 'contributors:contributors_for_week' %}" name="top-week">
{% trans "for the past week" %}
</a>
</li>
<li class="nav-item">
<a class="nav-link time-note py-1" href="#"
name="top-month">
{% trans "for the past month" %}
</a>
<a class="nav-link time-note py-1 {% if not is_week %}active{% endif %}" href="{% url 'contributors:contributors_for_month' %}" name="top-month">
{% trans "for the past month" %}
</a>
</li>
</ul>




27 changes: 24 additions & 3 deletions templates/contributors_for_period.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
{% extends 'base.html' %}
{% load i18n %}

{% block title %}{% trans "Contributors for month" %}{% endblock %}
{% block title %}
{% if is_week %}
{% trans "Contributors for week" %}
{% else %}
{% trans "Contributors for month" %}
{% endif %}
{% endblock %}

<!-- Open Graph tags -->
{% block og_title %}{% trans "Contributors for month" %}{% endblock og_title %}
{% block og_title %}
{% if is_week %}
{% trans "Contributors for week" %}
{% else %}
{% trans "Contributors for month" %}
{% endif %}
{% endblock og_title %}
<!-- End Open Graph tags -->
{% block header %}{% trans "Contributors" %}{% endblock %}

{% block header %}
{% if is_week %}
{% trans "Contributors for week" %}
{% else %}
{% trans "Contributors for month" %}
{% endif %}
{% endblock %}

{% block additional %}
{% include 'components/time_note.html' %}
{% endblock %}
Expand Down

0 comments on commit 7097d56

Please sign in to comment.