Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit achievements #437

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4c58a85
edit_achievements
AleksandrKosmylev Jun 15, 2024
1dd4735
edit_achievements_addition
AleksandrKosmylev Jun 15, 2024
be4c7d1
Added common statistics in footer
AleksandrKosmylev Jun 18, 2024
df93d1a
Merge branch 'Hexlet:main' into edit_achievements
AleksandrKosmylev Jun 18, 2024
a68db2e
add test for contributors:contributor_achievements and minor linter fix
AleksandrKosmylev Jun 19, 2024
3b4a8fa
Merge remote-tracking branch 'origin/edit_achievements' into edit_ach…
AleksandrKosmylev Jun 20, 2024
883c439
Add helper function to calc achivements percentage
AleksandrKosmylev Jun 30, 2024
c43a264
fix inline styles
AleksandrKosmylev Jun 30, 2024
8ddf4bb
update common and personal stat
AleksandrKosmylev Aug 18, 2024
23abc8c
resolve conflict
AleksandrKosmylev Oct 6, 2024
eb11834
resolve wps
AleksandrKosmylev Oct 6, 2024
3849707
resolve wps editon 1
AleksandrKosmylev Oct 6, 2024
f9c26ed
resolve wps editon 2
AleksandrKosmylev Oct 6, 2024
fa49f24
resolve wps editon 3
AleksandrKosmylev Oct 6, 2024
a068fe8
resolve wps editon 4
AleksandrKosmylev Oct 6, 2024
439944b
resolve wps editon 6
AleksandrKosmylev Oct 6, 2024
be1689c
resolve wps editon 7
AleksandrKosmylev Oct 6, 2024
023b76d
Merge branch 'Hexlet:main' into edit_achievements
AleksandrKosmylev Oct 6, 2024
91289fb
fix linter notifications
AleksandrKosmylev Oct 27, 2024
130b868
fix linter notifications
AleksandrKosmylev Oct 27, 2024
4b3067c
refactor contributor_achievements.py
AleksandrKosmylev Nov 17, 2024
8c312f8
delete sum brackets
AleksandrKosmylev Nov 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add helper function to calc achivements percentage
  • Loading branch information
AleksandrKosmylev committed Jun 30, 2024
commit 883c43942b63841ead902cab371cbb1504476fdd
10 changes: 10 additions & 0 deletions contributors/templatetags/contrib_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,13 @@ def get_canonical_url(context):
if request:
return request.build_absolute_uri(request.path)
return ''


@register.simple_tag
def calc_percent_achievement(numerator, denominator):
"""Get contributor statistics and required quantity."""
if numerator is not None:
if numerator / denominator > 1:
return 100.0
return numerator / denominator * 100
return 0
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ ignore =
WPS202
# WPS407 Found mutable module constant
WPS407
WPS335 Found incorrect `for` loop iter type
# WPS335 Found incorrect `for` loop iter type
WPS335


Expand Down
4 changes: 2 additions & 2 deletions templates/components/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<li><p class="h6">{% trans "Other projects" %}</p></li>
</div>
<div class="col">
<li> </li>
<li></li>
</div>
<div class="col">
<li><p class="h6">{% trans "Useful resources" %}</p></li>
Expand Down Expand Up @@ -44,7 +44,7 @@
<li><a target="_blank" href="http://ru.hexlet.io/blog">{% trans "Blog" %}</a></li>
</div>
<div class="col">
<li> </li>
<li></li>
</div>
</div>
</ul>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
{% load i18n static mathfilters %}
{% load i18n static contrib_extras %}

<div class="progress d-flex justify-content-between" style="height: max-content;">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

здесь тоже какой-то кастомный styel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

перенесено в base.css как кастомный стиль.

<div class="bg-info text-dark text-start aligns-items-center" role="progressbar" style="width: {{ contribution|div:achievement_made_count|mul:100|floatformat:0 }}%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
<div class="bg-info text-dark text-start aligns-items-center" role="progressbar" style="width: {% calc_percent_achievement contribution achievement_made_count %}%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
<dl class="p-2 fs-6 mb-0" style="width:50vw;">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут какой-то скастомный стиль используется. Давайте от такого избавляться (он инлайн стилей). Посмотрите, есть ли в бутстрапе похожий класс, если нет, то можно добавить кастомный класс, который именуется через префикс x-*, возможно есть другие кастомные классы уже, можно на них посмотреть.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А тут не поправили? Посмотрите, как в сикпе сделаны кастомные стили - https://github.com/Hexlet/hexlet-sicp/blob/f02ff453e6c8b045764f497fe536e8ecd24913b6/resources/sass/_custom.scss#L1-L23

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style="height: max-content и style="width:50vw перенесены в base.css как кастомные стили.

style="width: {{ contribution|div:achievement_made_count|mul:100|floatformat:0 }} используемый прогрессбаром остается, так как увидел подобное решение в образце от bootstrap

<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">
{% if contribution|div:achievement_made_count|mul:100 > 100 %}
100.0%
{% else %}
{{ contribution|div:achievement_made_count|mul:100|floatformat:1 }}%
{% endif %}
{% calc_percent_achievement contribution achievement_made_count %}%
</div>
</div>
Loading