Conversation
VeryBigSad
approved these changes
Nov 12, 2023
Contributor
VeryBigSad
left a comment
There was a problem hiding this comment.
в целом норм, но надо потом будет переделать штуку с новостями для трёх разных типов объектов
и очень надо просто протестить UserProjectsSeralizer
news/permissions.py
Outdated
Comment on lines
+39
to
+53
| if view.kwargs.get("project_pk"): | ||
| try: | ||
| project = Project.objects.get(pk=view.kwargs["project_pk"]) | ||
| if request.method in SAFE_METHODS or (request.user == project.leader): | ||
| return True | ||
| except Project.DoesNotExist: | ||
| return False | ||
|
|
||
| if view.kwargs.get("user_pk"): | ||
| try: | ||
| user = User.objects.get(pk=view.kwargs["user_pk"]) | ||
| if request.method in SAFE_METHODS or (request.user == user): | ||
| return True | ||
| except User.DoesNotExist: | ||
| return False |
Contributor
There was a problem hiding this comment.
надо бы будет эту штуку поприятнее сделать
просто метод который получил бы из kwargs объект или raise 404
Comment on lines
-223
to
+227
| user = self.context.get("request").user if self.context.get("user") is None else self.context.get("user") | ||
| user = self.context.get("request").user | ||
| try: | ||
| collaborator = project.collaborator_set.get(user=user) | ||
| except Collaborator.DoesNotExist: | ||
| return {} |
Contributor
There was a problem hiding this comment.
кажется, что в какой-то инициализации этого сериалайзера я передаю user как контекст, так что это может сломаться
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix user news creation, add NewsMapping class