-
Notifications
You must be signed in to change notification settings - Fork 0
Project rates finished refactoring #315
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
Conversation
project_rates/views.py
Outdated
| return Response(serialized_data, status=status.HTTP_200_OK) | ||
| except IndexError: | ||
| return Response( | ||
| {"error": "Нужный проект или программа не найдены"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
предлагаю завести файлик entities или constants и туда класть строчки с ошибками, в core можно положить какие то общие ошибки. но кажется в дрф и джанге часть ошибок в зависимости от локализации возвращается корректно, тут надо поресерчить и привести все к единому виду. Для начала давай просто вынесем их в файлик.
class Erros(enum.Enum):
PROJECT_OR_PROGRAM_NOT_FOUND = "..."There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
оговорили это, не актуально
| filled_values = sum( | ||
| 1 | ||
| for criteria in project_data["criterias"] | ||
| if criteria["name"] == "Комментарий" or criteria.get("value") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не понял логику проверки на заполненность
во первых почему мы сравниаем имя критерия с захардкоженным словом "Комментарий" и считаем что если имя комментарий то критерий заполнен?
То есть коммент может быть и пустым, но будет считаться как заполненное поле?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
комментарий идее опционален
project_rates/validators.py
Outdated
| min_value: float | None, max_value: float | None, value: str | ||
| ): | ||
| if min_value is not None and min_value > float(value): | ||
| raise ValueError("Оценка этого критерия принизила допустимые значения!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
принизила?) Мб просто Оценка этого критерия меньше допустимого значения
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
исправил
| criteria_to_get = [ | ||
| criterion["criterion_id"] for criterion in data | ||
| ] # is needed for validation later | ||
| for criterion in data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
как переводится criterion? непонятное слово какое то)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
criterion - критерий (единственное число)
criteria - критерии (множественное число)
criterias - критерии (хуйня которую я по незнанию английского придумал)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
criterion используется только при получении данных с фронта. мне лень было это везде на бэке исправлять, это ж модели ещё нужно менять...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ааа
закончил рефакторинг get запросов в приложении project_rates