diff --git a/.github/workflows/prod_deploy.yaml b/.github/workflows/prod_deploy.yaml index 21a315bd..406b5189 100644 --- a/.github/workflows/prod_deploy.yaml +++ b/.github/workflows/prod_deploy.yaml @@ -127,7 +127,6 @@ jobs: echo "${{ secrets.ENV_FILE }}" > .env cd infra/prod/ - sudo systemctl stop adaptive_hockey_federation.service docker system prune --force sudo cp -f /home/production/adaptive_hockey_federation/infra/prod/adaptive_hockey_federation.service /etc/systemd/system/adaptive_hockey_federation.service diff --git a/adaptive_hockey_federation/main/forms.py b/adaptive_hockey_federation/main/forms.py index f4baeedb..84cfc613 100644 --- a/adaptive_hockey_federation/main/forms.py +++ b/adaptive_hockey_federation/main/forms.py @@ -28,6 +28,7 @@ StaffTeamMember, Team, ) +from main.validators import validate_registr_diagnosis from users.models import User @@ -142,7 +143,10 @@ def clean_identity_document(self): def clean_diagnosis(self): """Метод, выполняющий валидацию поля с диагнозом.""" nosology = self.cleaned_data.get("nosology") - diagnosis = self.cleaned_data.get("diagnosis") + diagnosis = validate_registr_diagnosis( + self.cleaned_data.get("diagnosis"), + ) + if Diagnosis.objects.filter(name=diagnosis).exists(): diagnos = Diagnosis.objects.get(name=diagnosis) if diagnos.nosology != nosology: diff --git a/adaptive_hockey_federation/main/validators.py b/adaptive_hockey_federation/main/validators.py new file mode 100644 index 00000000..d3a40409 --- /dev/null +++ b/adaptive_hockey_federation/main/validators.py @@ -0,0 +1,14 @@ +import re + + +def validate_registr_diagnosis(diagnosis: str) -> str: + """ + Метод, проверяющий диагноз на соответствие коду МКБ-10. + + Если нет, то возвращает диагноз с заглавной буквы. + """ + pattern = r"^([A-Z]\d{2})(.\d)?$" + + if not re.match(pattern, diagnosis): + return diagnosis.capitalize() + return diagnosis