diff --git a/Makefile b/Makefile index c7af6ddd..e9d2b27d 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ shell: # Need to have GNU gettext installed transprepare: @poetry run django-admin makemessages --add-location file + @poetry run django-admin makemessages --add-location file --domain djangojs transcompile: @poetry run django-admin compilemessages diff --git a/config/urls.py b/config/urls.py index b180eca9..5de6c6ec 100644 --- a/config/urls.py +++ b/config/urls.py @@ -1,10 +1,12 @@ from django.urls import include, path +from django.views.i18n import JavaScriptCatalog from contributors.admin.custom import site urlpatterns = [ path('admin/', site.urls), path('i18n/', include('django.conf.urls.i18n')), + path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript_catalog'), path('auth/', include('django.contrib.auth.urls')), path('auth/', include('auth.urls')), path('', include('contributors.urls')), diff --git a/contributors/migrations/0003_auto_20200317_0729.py b/contributors/migrations/0003_auto_20200317_0729.py new file mode 100644 index 00000000..e8062b3e --- /dev/null +++ b/contributors/migrations/0003_auto_20200317_0729.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.11 on 2020-03-17 04:29 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('contributors', '0002_issueinfo'), + ] + + operations = [ + migrations.AlterField( + model_name='issueinfo', + name='issue', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='info', to='contributors.Contribution', verbose_name='issue'), + ), + ] diff --git a/locale/ru/LC_MESSAGES/django.mo b/locale/ru/LC_MESSAGES/django.mo index 694ea1ad..5fddf501 100644 Binary files a/locale/ru/LC_MESSAGES/django.mo and b/locale/ru/LC_MESSAGES/django.mo differ diff --git a/locale/ru/LC_MESSAGES/django.po b/locale/ru/LC_MESSAGES/django.po index ff7277d1..5e406b07 100644 --- a/locale/ru/LC_MESSAGES/django.po +++ b/locale/ru/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-08 12:00+0500\n" +"POT-Creation-Date: 2020-03-27 17:10+0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -248,14 +248,16 @@ msgstr "Рекомендованные книги" msgid "Blog" msgstr "Блог" -#: templates/components/navbar.html templates/organization_details.html -#: templates/organizations_list.html templates/repositories_list.html +#: templates/components/navbar.html +#: templates/components/tables/organizations_list.html +#: templates/organization_details.html templates/repositories_list.html msgid "Repositories" msgstr "Репозитории" -#: templates/components/navbar.html templates/contributors_list.html -#: templates/organization_details.html templates/repositories_list.html -#: templates/repository_details.html +#: templates/components/navbar.html +#: templates/components/tables/organization_details.html +#: templates/components/tables/repositories_list.html +#: templates/contributors_list.html templates/repository_details.html msgid "Contributors" msgstr "Контрибьюторы" @@ -271,56 +273,75 @@ msgstr "Администрирование" msgid "Log out" msgstr "Выйти" -#: templates/components/navbar.html templates/registration/login.html -msgid "Log in" -msgstr "Войти" +#: templates/components/tables/contributors_list.html +#: templates/components/tables/recent_contributors.html +#: templates/components/tables/repository_details.html +msgid "Login" +msgstr "Логин" -#: templates/components/navbar.html templates/registration/registration.html -msgid "Register" -msgstr "Зарегистрироваться" +#: templates/components/tables/contributors_list.html +#: templates/components/tables/organization_details.html +#: templates/components/tables/organizations_list.html +#: templates/components/tables/recent_contributors.html +#: templates/components/tables/repositories_list.html +#: templates/components/tables/repository_details.html +msgid "Name" +msgstr "Имя" -#: templates/contributor_details.html templates/contributors_list.html -#: templates/home.html templates/repository_details.html +#: templates/components/tables/contributors_list.html +#: templates/components/tables/recent_contributors.html +#: templates/components/tables/repository_details.html +#: templates/contributor_details.html msgid "Commits" msgstr "Коммиты" -#: templates/contributor_details.html templates/contributors_list.html -#: templates/home.html templates/repository_details.html +#: templates/components/tables/contributors_list.html +#: templates/components/tables/recent_contributors.html +#: templates/components/tables/repository_details.html +#: templates/contributor_details.html msgid "Additions" msgstr "Добавления" -#: templates/contributor_details.html templates/contributors_list.html -#: templates/home.html templates/repository_details.html +#: templates/components/tables/contributors_list.html +#: templates/components/tables/recent_contributors.html +#: templates/components/tables/repository_details.html +#: templates/contributor_details.html msgid "Deletions" msgstr "Удаления" -#: templates/contributor_details.html templates/contributors_list.html -#: templates/home.html templates/organization_details.html -#: templates/repositories_list.html templates/repository_details.html +#: templates/components/tables/contributors_list.html +#: templates/components/tables/organization_details.html +#: templates/components/tables/recent_contributors.html +#: templates/components/tables/repositories_list.html +#: templates/components/tables/repository_details.html +#: templates/contributor_details.html msgid "Pull requests" msgstr "Запросы на включение" -#: templates/contributor_details.html templates/contributors_list.html -#: templates/home.html templates/organization_details.html -#: templates/repositories_list.html templates/repository_details.html +#: templates/components/tables/contributors_list.html +#: templates/components/tables/organization_details.html +#: templates/components/tables/recent_contributors.html +#: templates/components/tables/repositories_list.html +#: templates/components/tables/repository_details.html +#: templates/contributor_details.html msgid "Issues" msgstr "Проблемы" -#: templates/contributor_details.html templates/contributors_list.html -#: templates/home.html templates/repository_details.html +#: templates/components/tables/contributors_list.html +#: templates/components/tables/recent_contributors.html +#: templates/components/tables/repository_details.html +#: templates/contributor_details.html msgid "Comments" msgstr "Комментарии" -#: templates/contributors_list.html templates/home.html +#: templates/components/tables/repositories_list.html #: templates/repository_details.html -msgid "Login" -msgstr "Логин" +msgid "Organization" +msgstr "Организация" -#: templates/contributors_list.html templates/home.html -#: templates/organization_details.html templates/organizations_list.html -#: templates/repositories_list.html templates/repository_details.html -msgid "Name" -msgstr "Имя" +#: templates/home.html +msgid "Past year activity" +msgstr "Активность за год" #: templates/home.html msgid "Recently active contributors" @@ -339,10 +360,14 @@ msgctxt "logon" msgid "Login" msgstr "Вход" +#: templates/registration/login.html +msgid "Log in" +msgstr "Войти" + #: templates/registration/registration.html msgid "Registration" msgstr "Регистрация" -#: templates/repositories_list.html templates/repository_details.html -msgid "Organization" -msgstr "Организация" +#: templates/registration/registration.html +msgid "Register" +msgstr "Зарегистрироваться" diff --git a/locale/ru/LC_MESSAGES/djangojs.mo b/locale/ru/LC_MESSAGES/djangojs.mo new file mode 100644 index 00000000..fd484cf2 Binary files /dev/null and b/locale/ru/LC_MESSAGES/djangojs.mo differ diff --git a/locale/ru/LC_MESSAGES/djangojs.po b/locale/ru/LC_MESSAGES/djangojs.po new file mode 100644 index 00000000..7b7faf48 --- /dev/null +++ b/locale/ru/LC_MESSAGES/djangojs.po @@ -0,0 +1,37 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-03-27 19:11+0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: Russian\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n" +"%100>=11 && n%100<=14)? 2 : 3);\n" + +#: static/js/yearActivityChart.js +msgid "Commits" +msgstr "Коммиты" + +#: static/js/yearActivityChart.js +msgid "Pull requests" +msgstr "Запросы на включение" + +#: static/js/yearActivityChart.js +msgid "Issues" +msgstr "Проблемы" + +#: static/js/yearActivityChart.js +msgid "Comments" +msgstr "Комментарии" diff --git a/static/js/scripts.js b/static/js/scripts.js index b8986d0e..ef08a1da 100644 --- a/static/js/scripts.js +++ b/static/js/scripts.js @@ -28,3 +28,15 @@ $(document).ready(function () { $(document).ready(function () { $('[data-toggle="tooltip"]').tooltip(); }); + +// Language selector +function switchLanguage(e) { + e.preventDefault(); + const langForm = document.querySelector('#language-form'); + const selector = langForm.querySelector('select'); + selector.value = e.target.innerText.trim().toLowerCase(); + langForm.submit(); +} + +const langLinks = document.querySelectorAll('.inactive-lang-link'); +langLinks.forEach((link) => link.addEventListener('click', switchLanguage)); diff --git a/static/js/yearActivityChart.js b/static/js/yearActivityChart.js new file mode 100644 index 00000000..ff9dfcf0 --- /dev/null +++ b/static/js/yearActivityChart.js @@ -0,0 +1,56 @@ +function generateMonths() { +const months = []; +for (let i = 1; i <= 12; i += 1) { + months.push(moment().add(i,'months').format('MMM')); +} +return months; +} + +const contributions = JSON.parse(document.getElementById('contributions').textContent); + +const ctx = document.getElementById('yearActivityChart').getContext('2d'); +const yearActivityChart = new Chart(ctx, { +type: 'bar', +data: { + labels: generateMonths(), + datasets: [ + { + label: gettext('Commits'), + data: contributions.commits, + backgroundColor: 'rgba(87, 173, 219, 0.7)', + }, + { + label: gettext('Pull requests'), + data: contributions.pull_requests, + backgroundColor: 'rgba(82, 206, 97, 0.7)', + }, + { + label: gettext('Issues'), + data: contributions.issues, + backgroundColor: 'rgba(226, 113, 90, 0.7)', + }, + { + label: gettext('Comments'), + data: contributions.comments, + backgroundColor: 'rgba(242, 232, 96, 0.7)', + }, + ], +}, +options: { + tooltips: { + mode: 'index', + intersect: false, + }, + animation: { + duration: 0, + }, + scales: { + xAxes: [{ + stacked: true, + }], + yAxes: [{ + stacked: true, + }], + }, +}, +}); diff --git a/templates/base.html b/templates/base.html index af5e7d87..02e28175 100644 --- a/templates/base.html +++ b/templates/base.html @@ -9,6 +9,8 @@ + + {% block head_scripts %}{% endblock %} {% if GTM_ID %} - -{{ contributions|json_script:'contributions' }} - +
+ diff --git a/templates/home.html b/templates/home.html index b83a98b1..2ad33649 100644 --- a/templates/home.html +++ b/templates/home.html @@ -1,6 +1,11 @@ {% extends 'base.html' %} {% load i18n %} +{% block head_scripts %} + + + {{ contributions|json_script:'contributions' }} +{% endblock head_scripts %} {% block header %}{% endblock %} {% block content %}

{% trans "Past year activity" %}