Skip to content
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

14 скрытие части юзердаты от пользователя #23

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

gitfresnel
Copy link
Contributor

Изменения

Изменил класс Param и ручку param.get

Детали реализации

Добавил в класс Param поле is_hidden (по умолчанию True = скрыт).
Ручка param.get теперь работает следующим образом:

  1. проводим обязательную авторизацию (но скупы при этом не нужны), чтобы узнать скоупы пользователя
  2. достаём параметр по айди и проверяем флаг скрытости
  3. если он установлен в True, то достаём скоупы на чтение категории, скоупы юзера и ищем их разность
  4. если разность пустая, значит у пользователя есть скоупы и мы возвращаем ему параметр. Наоборот - возбуждаем ошибку

Пока я не тестил работу ручки, ибо затуп был лютый с аутентификацией и базой данных

Check-List

  • Вы проверили свой код перед отправкой запроса?
  • Вы написали тесты к реализованным функциям?
  • Вы не забыли применить форматирование black и isort для Back-End или Prettier для Front-End?

Copy link

github-actions bot commented Apr 2, 2024

💩 Code linting failed, use black and isort to fix it.

Copy link

github-actions bot commented Apr 2, 2024

Code Coverage

Coverage Report
FileStmtsMissCoverMissing
userdata_api
   __main__.py17170%1–26
   exceptions.py19195%18
userdata_api/models
   base.py65592%25–28, 76
   db.py58198%89
userdata_api/routes
   category.py41490%38, 71–73
   exc_handlers.py20195%25
   param.py53885%39, 59, 98–101, 106, 129
   source.py30197%35
userdata_api/schemas
   base.py8450%6–9
   user.py24771%22–28
userdata_api/schemas/types
   scope.py24675%26–28, 33, 36, 38
userdata_api/utils
   user.py81298%81, 85
TOTAL5385789% 

Summary

Tests Skipped Failures Errors Time
57 0 💤 0 ❌ 0 🔥 3.274s ⏱️

Copy link

github-actions bot commented Apr 3, 2024

💩 Code linting failed, use black and isort to fix it.

Copy link

github-actions bot commented Apr 3, 2024

💩 Code linting failed, use black and isort to fix it.

requirements.txt Outdated Show resolved Hide resolved
requirements.txt Outdated Show resolved Hide resolved
userdata_api/models/db.py Outdated Show resolved Hide resolved
userdata_api/routes/param.py Outdated Show resolved Hide resolved
userdata_api/routes/param.py Outdated Show resolved Hide resolved
Copy link

💩 Code linting failed, use black and isort to fix it.

1 similar comment
Copy link

💩 Code linting failed, use black and isort to fix it.

.idea/.gitignore Outdated Show resolved Hide resolved
userdata_api/routes/user.py Outdated Show resolved Hide resolved
userdata_api/schemas/param.py Show resolved Hide resolved
userdata_api/schemas/param.py Show resolved Hide resolved
userdata_api/utils/user.py Outdated Show resolved Hide resolved
userdata_api/utils/user.py Outdated Show resolved Hide resolved
Copy link
Member

@Temmmmmo Temmmmmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так, короче, давай откатим коммит, потому что я только сейчас увидел коммент Семена апрельский, где он говорил добавлять Query-параметр
Мне это показалось странным, так как не совпадало с изначальным ТЗ
Можешь просто откатить, по идее, коммит, и запросить мое ревью
Прошу прощения

@gitfresnel gitfresnel force-pushed the 14-скрытие-части-юзердаты-от-пользователя branch from 2682954 to b29ffd4 Compare August 18, 2024 12:51
Copy link

💩 Code linting failed, use black and isort to fix it.

Copy link

github-actions bot commented Sep 2, 2024

💩 Code linting failed, use black and isort to fix it.

@Temmmmmo
Copy link
Member

убери idea из коммента

userdata_api/utils/user.py Outdated Show resolved Hide resolved
userdata_api/routes/user.py Outdated Show resolved Hide resolved
cls,
source: type[Any],
) -> core_schema.CoreSchema:
def __get_pydantic_core_schema__(cls, source: type[Any], handler: Callable) -> core_schema.CoreSchema:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from pydantic import GetCoreSchemaHandler, TypeAdapter


class Username(str):
    @classmethod
    def __get_pydantic_core_schema__(
        cls, source_type: Any, handler: GetCoreSchemaHandler
    ) -> CoreSchema:
        return core_schema.no_info_after_validator_function(cls, handler(str))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нужно использовать тип GetCoreSchemaHandler а не Callable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Скрытие части юзердаты от пользователя
3 participants