From 0095acbfaa2caf811e6c86c4fd96858fcc4ed0d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D1=82=D1=80=20=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Sat, 9 Dec 2023 01:10:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20pre-commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/mypy_flake.yml | 8 ++-- .pre-commit-config.yaml | 44 +++++++++++++++++++ README.md | 2 +- .../main/migrations/0001_initial.py | 2 +- ..._alter_health_revision_alter_player_sex.py | 23 ++++++++++ adaptive_hockey_federation/main/models.py | 5 +-- adaptive_hockey_federation/main/views.py | 1 - adaptive_hockey_federation/parser/parser.py | 5 +-- .../templates/base.html | 2 +- .../templates/includes/button.html | 2 +- .../templates/includes/drawer.html | 2 +- .../templates/includes/dropdown_button.html | 4 +- .../templates/includes/header.html | 2 +- .../templates/includes/table.html | 2 +- adaptive_hockey_federation/users/admin.py | 1 - .../users/migrations/0001_initial.py | 2 +- ...er_user_first_name_alter_user_last_name.py | 23 ++++++++++ adaptive_hockey_federation/users/models.py | 2 - docker-compose.yaml | 2 +- entrypoint.sh | 2 +- nginx/default.conf | 2 +- pyproject.toml | 2 +- requirements/develop.txt | 17 +++++++ requirements/production.txt | 16 +++++++ setup.cfg | 3 +- 25 files changed, 146 insertions(+), 30 deletions(-) create mode 100644 .pre-commit-config.yaml create mode 100644 adaptive_hockey_federation/main/migrations/0003_alter_health_revision_alter_player_sex.py create mode 100644 adaptive_hockey_federation/users/migrations/0003_alter_user_first_name_alter_user_last_name.py create mode 100644 requirements/develop.txt create mode 100644 requirements/production.txt diff --git a/.github/workflows/mypy_flake.yml b/.github/workflows/mypy_flake.yml index b2eccabd..91951839 100644 --- a/.github/workflows/mypy_flake.yml +++ b/.github/workflows/mypy_flake.yml @@ -11,12 +11,12 @@ jobs: uses: actions/setup-python@v4 with: python-version: 3.11 - + - name: Установка Poetry uses: snok/install-poetry@v1 with: poetry-version: 1.7.0 - + - name: Извлечение репозитория uses: actions/checkout@v4 @@ -35,12 +35,12 @@ jobs: uses: actions/setup-python@v4 with: python-version: 3.11 - + - name: Установка Poetry uses: snok/install-poetry@v1 with: poetry-version: 1.7.0 - + - name: Извлечение репозитория uses: actions/checkout@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..20b57024 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,44 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-docstring-first + - id: check-merge-conflict + - id: end-of-file-fixer + - id: trailing-whitespace + + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort + + - repo: https://github.com/PyCQA/flake8 + rev: 6.1.0 + hooks: + - id: flake8 + exclude: migrations/|.*settings(\.py|/)? + additional_dependencies: + - flake8-isort + - flake8-django + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.6.0 + hooks: + - id: mypy + additional_dependencies: + - django-stubs + + - repo: local + hooks: + - id: export-dev-dependencies + name: Export dev Dependencies + language: system + pass_filenames: false + entry: poetry export --without-hashes --dev --output requirements/develop.txt + files: ^(pyproject.toml|poetry.lock)$ + - id: export-prod-dependencies + name: Export prod Dependencies + language: system + pass_filenames: false + entry: poetry export --without-hashes --output requirements/production.txt + files: ^(pyproject.toml|poetry.lock)$ diff --git a/README.md b/README.md index 4dc1d3a6..74c38cc7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Федерация Адаптивного Хоккея #### Описание -Проект для [Федерации адаптивного хоккея](https://paraicehockey.ru/) +Проект для [Федерации адаптивного хоккея](https://paraicehockey.ru/) # Содержание diff --git a/adaptive_hockey_federation/main/migrations/0001_initial.py b/adaptive_hockey_federation/main/migrations/0001_initial.py index 53c78927..d5f05415 100644 --- a/adaptive_hockey_federation/main/migrations/0001_initial.py +++ b/adaptive_hockey_federation/main/migrations/0001_initial.py @@ -1,7 +1,7 @@ # Generated by Django 4.2.6 on 2023-11-25 14:50 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/adaptive_hockey_federation/main/migrations/0003_alter_health_revision_alter_player_sex.py b/adaptive_hockey_federation/main/migrations/0003_alter_health_revision_alter_player_sex.py new file mode 100644 index 00000000..11528fc1 --- /dev/null +++ b/adaptive_hockey_federation/main/migrations/0003_alter_health_revision_alter_player_sex.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.7 on 2023-12-08 22:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0002_alter_player_patronymic'), + ] + + operations = [ + migrations.AlterField( + model_name='health', + name='revision', + field=models.CharField(blank=True, max_length=256, verbose_name='Пересмотр класса ХДН'), + ), + migrations.AlterField( + model_name='player', + name='sex', + field=models.CharField(blank=True, choices=[('male', 'Мужской'), ('female', 'Женский')], max_length=6, verbose_name='Пол'), + ), + ] diff --git a/adaptive_hockey_federation/main/models.py b/adaptive_hockey_federation/main/models.py index e1966369..8ec82a6f 100644 --- a/adaptive_hockey_federation/main/models.py +++ b/adaptive_hockey_federation/main/models.py @@ -1,3 +1,4 @@ +from django.db import models from django.db.models import ( CASCADE, SET_NULL, @@ -172,10 +173,9 @@ class Player(BasePerson): max_length=max(len(sex) for sex, _ in SEX_CHOICES), choices=SEX_CHOICES, blank=True, - null=True, verbose_name='Пол' ) - team = ManyToManyField( + team: models.ManyToManyField = ManyToManyField( to=Team, through='PlayerTeam', verbose_name='Команда' @@ -216,7 +216,6 @@ class Health(Model): revision = CharField( max_length=NAME_FIELD_LENGTH, blank=True, - null=True, verbose_name='Пересмотр класса ХДН', ) anamnesis = ForeignKey( diff --git a/adaptive_hockey_federation/main/views.py b/adaptive_hockey_federation/main/views.py index 492bd566..4758f17d 100644 --- a/adaptive_hockey_federation/main/views.py +++ b/adaptive_hockey_federation/main/views.py @@ -1,6 +1,5 @@ from django.shortcuts import render - # пример рендера таблиц, удалить после реализации вьюх CONTEXT_EXAMPLE = { 'table_head': { diff --git a/adaptive_hockey_federation/parser/parser.py b/adaptive_hockey_federation/parser/parser.py index 51f44f3f..7af5c221 100644 --- a/adaptive_hockey_federation/parser/parser.py +++ b/adaptive_hockey_federation/parser/parser.py @@ -82,9 +82,8 @@ def get_all_files(path: str) -> tuple[list[str], str | None]: if filename == NUMERIC_STATUSES: numeric_statuses_filepath = os.path.join(dirpath, filename) file, extension = os.path.splitext(filename) - if (not file.startswith('~') - and extension in FILES_EXTENSIONS - and file not in FILES_BLACK_LIST): + if (not file.startswith('~') and extension + in FILES_EXTENSIONS and file not in FILES_BLACK_LIST): files.append(os.path.join(dirpath, filename)) return files, numeric_statuses_filepath diff --git a/adaptive_hockey_federation/templates/base.html b/adaptive_hockey_federation/templates/base.html index 15790f06..8d135db0 100644 --- a/adaptive_hockey_federation/templates/base.html +++ b/adaptive_hockey_federation/templates/base.html @@ -57,4 +57,4 @@ - \ No newline at end of file + diff --git a/adaptive_hockey_federation/templates/includes/button.html b/adaptive_hockey_federation/templates/includes/button.html index d4f22f2f..4c83abd9 100644 --- a/adaptive_hockey_federation/templates/includes/button.html +++ b/adaptive_hockey_federation/templates/includes/button.html @@ -4,4 +4,4 @@ {% if current_url_name == url_name %}bg-[#340061]{% else %}bg-[#64c2d1]{% endif %}"> {{ name }} -{% endwith %} \ No newline at end of file +{% endwith %} diff --git a/adaptive_hockey_federation/templates/includes/drawer.html b/adaptive_hockey_federation/templates/includes/drawer.html index 64eb25d3..d3e9b748 100644 --- a/adaptive_hockey_federation/templates/includes/drawer.html +++ b/adaptive_hockey_federation/templates/includes/drawer.html @@ -41,4 +41,4 @@ - \ No newline at end of file + diff --git a/adaptive_hockey_federation/templates/includes/dropdown_button.html b/adaptive_hockey_federation/templates/includes/dropdown_button.html index 549ade18..37319e84 100644 --- a/adaptive_hockey_federation/templates/includes/dropdown_button.html +++ b/adaptive_hockey_federation/templates/includes/dropdown_button.html @@ -1,7 +1,7 @@ {% with request.resolver_match.view_name as view_name %}
  • ...
  • -{% endwith %} \ No newline at end of file +{% endwith %} diff --git a/adaptive_hockey_federation/templates/includes/header.html b/adaptive_hockey_federation/templates/includes/header.html index 5e89ba58..929d4d79 100644 --- a/adaptive_hockey_federation/templates/includes/header.html +++ b/adaptive_hockey_federation/templates/includes/header.html @@ -21,4 +21,4 @@ - \ No newline at end of file + diff --git a/adaptive_hockey_federation/templates/includes/table.html b/adaptive_hockey_federation/templates/includes/table.html index e3ca8373..e313279e 100644 --- a/adaptive_hockey_federation/templates/includes/table.html +++ b/adaptive_hockey_federation/templates/includes/table.html @@ -31,4 +31,4 @@ {% endfor %} - \ No newline at end of file + diff --git a/adaptive_hockey_federation/users/admin.py b/adaptive_hockey_federation/users/admin.py index 344accaa..93fb3d3e 100644 --- a/adaptive_hockey_federation/users/admin.py +++ b/adaptive_hockey_federation/users/admin.py @@ -1,5 +1,4 @@ from django.contrib import admin - from users.models import User diff --git a/adaptive_hockey_federation/users/migrations/0001_initial.py b/adaptive_hockey_federation/users/migrations/0001_initial.py index 110071e8..8d47432e 100644 --- a/adaptive_hockey_federation/users/migrations/0001_initial.py +++ b/adaptive_hockey_federation/users/migrations/0001_initial.py @@ -2,9 +2,9 @@ import django.contrib.auth.models import django.contrib.auth.validators -from django.db import migrations, models import django.db.models.deletion import django.utils.timezone +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/adaptive_hockey_federation/users/migrations/0003_alter_user_first_name_alter_user_last_name.py b/adaptive_hockey_federation/users/migrations/0003_alter_user_first_name_alter_user_last_name.py new file mode 100644 index 00000000..27f35978 --- /dev/null +++ b/adaptive_hockey_federation/users/migrations/0003_alter_user_first_name_alter_user_last_name.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.7 on 2023-12-08 22:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0002_alter_user_first_name_alter_user_last_name'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='first_name', + field=models.CharField(default='', max_length=256), + ), + migrations.AlterField( + model_name='user', + name='last_name', + field=models.CharField(default='', max_length=256), + ), + ] diff --git a/adaptive_hockey_federation/users/models.py b/adaptive_hockey_federation/users/models.py index 9bc5aa77..95f902a1 100644 --- a/adaptive_hockey_federation/users/models.py +++ b/adaptive_hockey_federation/users/models.py @@ -31,12 +31,10 @@ class User(AbstractUser): first_name = CharField( max_length=NAME_MAX_LENGTH, default='', - null=True, ) last_name = CharField( max_length=NAME_MAX_LENGTH, default='', - null=True, ) team = ForeignKey( to=Team, diff --git a/docker-compose.yaml b/docker-compose.yaml index 3f6a3409..4c223c42 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -23,4 +23,4 @@ services: volumes: static_value: - media_value: \ No newline at end of file + media_value: diff --git a/entrypoint.sh b/entrypoint.sh index 95c2b12b..4c61f440 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,4 +4,4 @@ sleep 5 app/.venv/bin/python manage.py collectstatic --noinput mv /static/* /app/static/ -exec "$@" \ No newline at end of file +exec "$@" diff --git a/nginx/default.conf b/nginx/default.conf index 4be5d03e..426c4f91 100644 --- a/nginx/default.conf +++ b/nginx/default.conf @@ -14,4 +14,4 @@ server { location / { proxy_pass http://site:8000; } -} \ No newline at end of file +} diff --git a/pyproject.toml b/pyproject.toml index 6bcf7838..17bf3c74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,4 +59,4 @@ django_settings_module = "adaptive_hockey_federation.settings" [tool.poetry.scripts] -parser = "adaptive_hockey_federation.parser.parser:parsing_file" \ No newline at end of file +parser = "adaptive_hockey_federation.parser.parser:parsing_file" diff --git a/requirements/develop.txt b/requirements/develop.txt new file mode 100644 index 00000000..7ef20acf --- /dev/null +++ b/requirements/develop.txt @@ -0,0 +1,17 @@ +asgiref==3.7.2 ; python_version >= "3.11" and python_version < "4.0" +click==8.1.7 ; python_version >= "3.11" and python_version < "4.0" +colorama==0.4.6 ; python_version >= "3.11" and python_version < "4.0" and platform_system == "Windows" +django==4.2.7 ; python_version >= "3.11" and python_version < "4.0" +et-xmlfile==1.1.0 ; python_version >= "3.11" and python_version < "4.0" +gunicorn==21.2.0 ; python_version >= "3.11" and python_version < "4.0" +isort==5.12.0 ; python_version >= "3.11" and python_version < "4.0" +mypy-extensions==1.0.0 ; python_version >= "3.11" and python_version < "4.0" +mypy==1.6.0 ; python_version >= "3.11" and python_version < "4.0" +openpyxl-stubs==0.1.25 ; python_version >= "3.11" and python_version < "4.0" +openpyxl==3.1.2 ; python_version >= "3.11" and python_version < "4.0" +packaging==23.2 ; python_version >= "3.11" and python_version < "4.0" +sqlparse==0.4.4 ; python_version >= "3.11" and python_version < "4.0" +types-openpyxl==3.1.0.27 ; python_version >= "3.11" and python_version < "4.0" +typing-extensions==4.8.0 ; python_version >= "3.11" and python_version < "4.0" +tzdata==2023.3 ; python_version >= "3.11" and python_version < "4.0" and sys_platform == "win32" +wrapt==1.16.0 ; python_version >= "3.11" and python_version < "4.0" diff --git a/requirements/production.txt b/requirements/production.txt new file mode 100644 index 00000000..9ce73fcc --- /dev/null +++ b/requirements/production.txt @@ -0,0 +1,16 @@ +asgiref==3.7.2 ; python_version >= "3.11" and python_version < "4.0" +click==8.1.7 ; python_version >= "3.11" and python_version < "4.0" +colorama==0.4.6 ; python_version >= "3.11" and python_version < "4.0" and platform_system == "Windows" +django==4.2.7 ; python_version >= "3.11" and python_version < "4.0" +et-xmlfile==1.1.0 ; python_version >= "3.11" and python_version < "4.0" +gunicorn==21.2.0 ; python_version >= "3.11" and python_version < "4.0" +mypy-extensions==1.0.0 ; python_version >= "3.11" and python_version < "4.0" +mypy==1.6.0 ; python_version >= "3.11" and python_version < "4.0" +openpyxl-stubs==0.1.25 ; python_version >= "3.11" and python_version < "4.0" +openpyxl==3.1.2 ; python_version >= "3.11" and python_version < "4.0" +packaging==23.2 ; python_version >= "3.11" and python_version < "4.0" +sqlparse==0.4.4 ; python_version >= "3.11" and python_version < "4.0" +types-openpyxl==3.1.0.27 ; python_version >= "3.11" and python_version < "4.0" +typing-extensions==4.8.0 ; python_version >= "3.11" and python_version < "4.0" +tzdata==2023.3 ; python_version >= "3.11" and python_version < "4.0" and sys_platform == "win32" +wrapt==1.16.0 ; python_version >= "3.11" and python_version < "4.0" diff --git a/setup.cfg b/setup.cfg index d534a744..9e61d1f1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,5 +9,4 @@ exclude = env/ per-file-ignores = */settings.py:E501 -max-complexity = 10 - +max-complexity = 10