Skip to content

Commit

Permalink
Merge pull request #231 from yuriy-kormin/210_correct_error_on_member…
Browse files Browse the repository at this point in the history
…_page

Correct an error on the members page #210
  • Loading branch information
emp7yhead committed Jan 20, 2023
2 parents fc4b38a + 93aead8 commit bdf7abc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
11 changes: 10 additions & 1 deletion contributors/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@
),
path(
'contributors/for-month',
views.contributors_for_month.ListView.as_view(),
views.contributors_for_period.ListView.as_view(
extra_context={'period': 'month'},
),
name='contributors_for_month',
),
path(
'contributors/for-week',
views.contributors_for_period.ListView.as_view(
extra_context={'period': 'week'},
),
name='contributors_for_week',
),
path(
'contributors/<slug:slug>',
views.contributor.DetailView.as_view(),
Expand Down
2 changes: 1 addition & 1 deletion contributors/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
contributor_issues,
contributor_prs,
contributors,
contributors_for_month,
contributors_for_period,
home,
issues,
organization,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
class ListView(contributors.ListView):
"""A list of contributors with monthly contributions."""

template_name = 'contributors_for_month.html'
template_name = 'contributors_for_period.html'
context_object_name = 'contributors_list'
queryset = Contributor.objects.visible_with_monthly_stats()

def get_context_data(self, **kwargs):
"""Add context."""
context = super().get_context_data(**kwargs)
context['dt_month_ago'] = misc.datetime_month_ago()
return context

def get_queryset(self): # noqa: WPS615
"""Modify queryset depending on extra_content.period value."""
if self.extra_context.get('period') == 'week':
self.queryset = Contributor.objects.visible_with_weekly_stats()
elif self.extra_context.get('period') == 'month':
self.queryset = Contributor.objects.visible_with_monthly_stats()
return super().get_queryset()
10 changes: 5 additions & 5 deletions templates/components/time_note.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link time-note py-1 active" href="javascript:void(0)"
name="top-week">
<a class="nav-link time-note py-1 {% if period == 'week' %}active{% endif %}" href="{% url "contributors:contributors_for_week" %}"
name="top-week">
{% trans "for the past week" %}
</a>
</a>
</li>
<li class="nav-item">
<a class="nav-link time-note py-1" href="javascript:void(0)"
name="top-month">
<a class="nav-link time-note py-1 {% if period == 'month' %}active{% endif %}" href="{% url "contributors:contributors_for_month" %}"
name="top-month">
{% trans "for the past month" %}
</a>
</li>
Expand Down
File renamed without changes.

0 comments on commit bdf7abc

Please sign in to comment.