-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat/mub roles+permissions #6
Conversation
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.
praise: Красивое решение очень интересной и объемной задачи!
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.
Пока так, тесты гляну после фиксов, потому что есть значительные
5e07b27
to
5d36bd5
Compare
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.
Интересное, поулчилось решение. Тут много копирования, так что напомню, твой код это твой код. Оправдание "так было в xi.backend" не работает, в xi.backend был flask, pip и по 6 декораторов на функцию
permissions: Mapped[list["RolePermission"]] = relationship( | ||
passive_deletes=True, cascade="all, delete-orphan", lazy="selectin" | ||
) |
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.
issue: ORM-каскады не совместимы с constraints на ForeignKey (ondelete="cascade")
community: Mapped[Community] = relationship(passive_deletes=True) | ||
permissions: Mapped[list["RolePermission"]] = relationship( |
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.
polish: Раз разделяем отношения пустыми строчками, перед permissions тоже
@property | ||
def permission_list(self) -> list[Permission]: # noqa |
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.
issue:
- Никогда нельзя использовать noqa без указания ошибки
- Линтер абсолютно прав, название фигня, списки списками не зовут
summary="Provide a role to a participant", | ||
) | ||
async def provide_role_to_participant( |
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.
issue: некорректный и неконсистентный неминг (а было лучше с assign)
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.
suggestion: Раз уж в participants точно такая же предзагрузка ролей, что в ролях для разрешений, можно и API совместить с participants_mub. Assign и deassign можно оставить отдельными методами, но получение добавить в модель для retrieve
exclude={ | ||
"permissions", | ||
} |
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.
polish: без запятой (или с запятой после }
) компактнее
if role_data.permissions: | ||
role.permissions.clear() | ||
role.permissions.extend( | ||
[ | ||
RolePermission(role_id=role.id, permission=permission) | ||
for permission in role_data.permissions | ||
] | ||
) |
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.
issue (repeat): сначала убрать всё, затем добавить всё. Нет
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.
Мы, кстати, обычно отношениями ORM не пользуемся
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.
Зачем эта логика в контроллере тоже особо не понимаю (может и меет место быть, но странно)
) | ||
if role_data.permissions: |
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.
issue (ну камон): if на непонятное условие. permissions это не bool, обязательно уточнять, что ты проверяешь. А тут это даже ведёт к некорректному поведению: невозможно отчистить список разрешений
permissions: list[Permission] | None | ||
|
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.
issue: Не используется PatchDefault, а должен. None тут не при делах
router = APIRouterExt(tags=["roles meta mub"]) | ||
|
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.
issue: теперь meta не имеет смысла
1c99138
to
96c5d21
Compare
Closed in favour of #25 |
No description provided.