Skip to content

Commit

Permalink
Feature/add pre commit (#47)
Browse files Browse the repository at this point in the history
* Добавлены миграции

* Добавлен pre-commit

* Обновлен список зависимостей

* добавил аннотацию
  • Loading branch information
PetrNazarov authored Dec 12, 2023
1 parent cbed5d4 commit ab9c391
Show file tree
Hide file tree
Showing 28 changed files with 421 additions and 57 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/mypy_flake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
44 changes: 44 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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)$
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Федерация Адаптивного Хоккея

#### Описание
Проект для [Федерации адаптивного хоккея](https://paraicehockey.ru/)
Проект для [Федерации адаптивного хоккея](https://paraicehockey.ru/)

# Содержание

Expand Down
2 changes: 1 addition & 1 deletion adaptive_hockey_federation/main/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2023-12-06 21:06

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('main', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='player',
name='patronymic',
field=models.CharField(blank=True, default='', max_length=256, verbose_name='Отчество'),
),
]
Original file line number Diff line number Diff line change
@@ -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='Пол'),
),
]
45 changes: 22 additions & 23 deletions adaptive_hockey_federation/main/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.db import models
from django.db.models import (
CASCADE,
SET_NULL,
Expand All @@ -23,7 +24,7 @@ class BaseUniqueName(Model):
"""
Абстрактный класс с уникальным полем "Название" и методом отображения
"""
name = CharField(
name: models.CharField = CharField(
max_length=NAME_FIELD_LENGTH,
verbose_name='Название',
unique=True,
Expand Down Expand Up @@ -62,15 +63,15 @@ class Team(Model):
"""
Модель команды.
"""
name = CharField(max_length=NAME_FIELD_LENGTH, )
location = ForeignKey(
name: models.CharField = CharField(max_length=NAME_FIELD_LENGTH, )
location: models.ForeignKey = ForeignKey(
to=Location,
on_delete=SET_NULL,
blank=True,
null=True,
verbose_name='Локация команды',
)
discipline = ForeignKey(
discipline: models.ForeignKey = ForeignKey(
to=Discipline,
on_delete=SET_NULL,
blank=True,
Expand Down Expand Up @@ -139,15 +140,15 @@ class BasePerson(Model):
"""
Абстрактная модель с базовой персональной информацией
"""
name = CharField(
name: models.CharField = CharField(
max_length=BASE_PERSON_FIELD_LENGTH,
verbose_name='Имя',
)
surname = CharField(
surname: models.CharField = CharField(
max_length=BASE_PERSON_FIELD_LENGTH,
verbose_name='Фамилия',
)
patronymic = CharField(
patronymic: models.CharField = CharField(
max_length=BASE_PERSON_FIELD_LENGTH,
blank=True,
default='',
Expand All @@ -167,15 +168,14 @@ class Player(BasePerson):
Модель игрока. Связь с командой "многие ко многим" на случай включения
игрока в сборную, помимо основного состава.
"""
birth_date = DateField()
sex = CharField(
birth_date: models.DateField = DateField()
sex: models.CharField = CharField(
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='Команда'
Expand All @@ -197,36 +197,35 @@ class Health(Model):
"""
Информация по хронической дыхательной недостаточности.
"""
player = ForeignKey(
player: models.ForeignKey = ForeignKey(
to=Player,
related_name='health',
on_delete=CASCADE,
verbose_name='Игрок',
)
respiratory_failure = ForeignKey(
respiratory_failure: models.ForeignKey = ForeignKey(
to=RespiratoryFailure,
related_name='respiratory_failure_players',
on_delete=CASCADE,
verbose_name='Класс ХДН',
)
is_permanent = BooleanField(
is_permanent: models.BooleanField = BooleanField(
default=False,
verbose_name='Класс ХДН подтверждён перманентно',
)
revision = CharField(
revision: models.CharField = CharField(
max_length=NAME_FIELD_LENGTH,
blank=True,
null=True,
verbose_name='Пересмотр класса ХДН',
)
anamnesis = ForeignKey(
anamnesis: models.ForeignKey = ForeignKey(
to=Anamnesis,
on_delete=SET_NULL,
blank=True,
null=True,
verbose_name='Диагноз',
)
wheelchair = BooleanField(
wheelchair: models.BooleanField = BooleanField(
default=False,
verbose_name='На коляске'
)
Expand All @@ -241,34 +240,34 @@ class PlayerTeam(Model):
Связь "многие ко многим" игрока с командой с добавлением данных игрока
в этой команде.
"""
player = ForeignKey(
player: models.ForeignKey = ForeignKey(
to=Player,
related_name='player_teams',
on_delete=CASCADE,
verbose_name='Игрок',

)
team = ForeignKey(
team: models.ForeignKey = ForeignKey(
to=Team,
related_name='team_players',
on_delete=CASCADE,
verbose_name='Команда',
)
position = ForeignKey(
position: models.ForeignKey = ForeignKey(
to=Position,
on_delete=SET_NULL,
blank=True,
null=True,
verbose_name='Позиция игрока',
)
role = ForeignKey(
role: models.ForeignKey = ForeignKey(
to=Role,
on_delete=SET_NULL,
blank=True,
null=True,
verbose_name='Статус игрока',
)
number = CharField(
number: models.CharField = CharField(
max_length=NAME_FIELD_LENGTH,
verbose_name='Игровой номер',
)
1 change: 0 additions & 1 deletion adaptive_hockey_federation/main/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.shortcuts import render


# пример рендера таблиц, удалить после реализации вьюх
CONTEXT_EXAMPLE = {
'table_head': {
Expand Down
5 changes: 2 additions & 3 deletions adaptive_hockey_federation/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion adaptive_hockey_federation/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
</div>
</div>
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion adaptive_hockey_federation/templates/includes/button.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
{% if current_url_name == url_name %}bg-[#340061]{% else %}bg-[#64c2d1]{% endif %}">
{{ name }}
</a>
{% endwith %}
{% endwith %}
2 changes: 1 addition & 1 deletion adaptive_hockey_federation/templates/includes/drawer.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
</ul>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% with request.resolver_match.view_name as view_name %}

<li class="nav-item dropdown place-self-center p-0">
<a class="nav-link dropdown-toggle border border-primary bg-white w-44 text-slate-400 p-1.5 text-end" href="#"
<a class="nav-link dropdown-toggle border border-primary bg-white w-44 text-slate-400 p-1.5 text-end" href="#"
role="button" data-bs-toggle="dropdown" aria-expanded="false">
{% if view_name == 'main:users' %}Роль{% endif %}
{% if view_name == 'main:teams' %}Команда{% endif %}
Expand All @@ -16,4 +16,4 @@
<li><a class="dropdown-item" href="#">...</a></li>
</ul>
</li>
{% endwith %}
{% endwith %}
2 changes: 1 addition & 1 deletion adaptive_hockey_federation/templates/includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
</li>
</ul>
</div>
</nav>
</nav>
2 changes: 1 addition & 1 deletion adaptive_hockey_federation/templates/includes/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
</tr>
{% endfor %}
</tbody>
</table>
</table>
1 change: 0 additions & 1 deletion adaptive_hockey_federation/users/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.contrib import admin

from users.models import User


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading

0 comments on commit ab9c391

Please sign in to comment.