Skip to content

Commit

Permalink
refactor(contributors): use explicit is_month for tab activation
Browse files Browse the repository at this point in the history
Replaced the 'not is_week' condition with a more explicit 'is_month' for better code clarity and maintainability.
  • Loading branch information
NikGor committed Aug 15, 2023
1 parent 7097d56 commit 6d658cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 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 @@ -14,6 +14,7 @@ def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['dt_month_ago'] = misc.datetime_month_ago()
context['is_week'] = self.extra_context.get('period') == 'week'
context['is_month'] = self.extra_context.get('period') == 'month'
return context

def get_queryset(self): # noqa: WPS615
Expand Down
6 changes: 4 additions & 2 deletions templates/components/time_note.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

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

0 comments on commit 6d658cd

Please sign in to comment.