Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #304 from danokp/add_achievements_page_265
Add achievement list page
- Loading branch information
Showing
11 changed files
with
663 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ | |
'crispy_forms', | ||
"crispy_bootstrap5", | ||
'django_extensions', | ||
'mathfilters', | ||
'django_filters', | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from contributors.views import ( # noqa: WPS235 | ||
about, | ||
achievements, | ||
config, | ||
contributor, | ||
contributor_issues, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from django.views import generic | ||
|
||
from contributors.models import Contributor | ||
|
||
|
||
class AchievementListView(generic.ListView): | ||
"""Achievement list.""" | ||
|
||
template_name = 'achievements_list.html' | ||
model = Contributor | ||
contributors = Contributor.objects.with_contributions() | ||
|
||
pull_request_ranges_for_achievements = [100, 50, 25, 10, 1] | ||
commit_ranges_for_achievements = [200, 100, 50, 25, 1] | ||
issue_ranges_for_achievements = [50, 25, 10, 5, 1] | ||
comment_ranges_for_achievements = [200, 100, 50, 25, 1] | ||
edition_ranges_for_achievements = [1000, 500, 250, 100, 1] | ||
|
||
def get_context_data(self, **kwargs): | ||
"""Add context data for achievement list.""" | ||
self.contributors_amount = Contributor.objects.count() | ||
context = super().get_context_data(**kwargs) | ||
contributors = Contributor.objects.with_contributions() | ||
|
||
context['contributors_amount'] = self.contributors_amount | ||
context['contributors_with_any_contribution'] = ( | ||
contributors.filter(contribution_amount__gte=1).count() | ||
) | ||
|
||
# Pull request achievements: | ||
for pr_num in self.pull_request_ranges_for_achievements: | ||
context[f'contributors_pull_requests_gte_{pr_num}'] = ( | ||
contributors.filter(pull_requests__gte=pr_num).count() | ||
) | ||
|
||
# Commit achievements: | ||
for commit_num in self.commit_ranges_for_achievements: | ||
context[f'contributors_commits_gte_{commit_num}'] = ( | ||
contributors.filter(commits__gte=commit_num).count() | ||
) | ||
|
||
# Issue achievements: | ||
for issue_num in self.issue_ranges_for_achievements: | ||
context[f'contributors_issues_gte_{issue_num}'] = ( | ||
contributors.filter(issues__gte=issue_num).count() | ||
) | ||
|
||
# Comment achievements: | ||
for comment_num in self.comment_ranges_for_achievements: | ||
context[f'contributors_comments_gte_{comment_num}'] = ( | ||
contributors.filter(comments__gte=comment_num).count() | ||
) | ||
|
||
# Edition achievements: | ||
for ed_num in self.edition_ranges_for_achievements: | ||
context[f'contributors_editions_gte_{ed_num}'] = ( | ||
contributors.filter(editions__gte=ed_num).count() | ||
) | ||
|
||
return context |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% extends 'base.html' %} | ||
{% load i18n static %} | ||
|
||
{% block content %} | ||
<h1>Achievements</h1> | ||
|
||
{% include 'components/tables/achievements_list.html' %} | ||
|
||
{% endblock %} |
11 changes: 11 additions & 0 deletions
11
templates/components/tables/achievement_percentage_field.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% load i18n static mathfilters %} | ||
|
||
<div class="progress d-flex justify-content-between" style="height: max-content;"> | ||
<div class="bg-info text-dark text-start aligns-items-center" role="progressbar" style="width: {{ achievement_made_count|div:contributors_amount|mul:100|floatformat:0 }}%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"> | ||
<dl class="p-2 fs-6 mb-0" style="width:50vw;"> | ||
<dt>{% trans achievement_name %}</dt> | ||
<dd class="mb-0">{% trans achievement_description %}</dd> | ||
</dl> | ||
</div> | ||
<div class="p-2 fs-6 d-flex justify-content-center align-items-center">{{ achievement_made_count|div:contributors_amount|mul:100|floatformat:1 }}%</div> | ||
</div> |
Oops, something went wrong.