feat: removed created_by from read_only serializer field, and ProjectMemberEndpoint updates#5260
Conversation
…spacememberendpoint to projectmemberendpoint
WalkthroughThis update enhances the API by streamlining serialization fields and transitioning member-related endpoints to a project-focused context. The Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant API
participant Database
User->>API: Request to create issue
API->>Database: Validate and save issue
Database-->>API: Confirmation of issue creation
API-->>User: Response with issue details
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 4
Outside diff range, codebase verification and nitpick comments (4)
apiserver/plane/api/views/member.py (1)
Line range hint
54-147:
Improve readability and reduce redundancy.The method can be refactored to improve readability and reduce redundancy.
- def post(self, request, slug, project_id): - if ( - request.data.get("email") is None - or request.data.get("display_name") is None - ): - return Response( - { - "error": "Expected email, display_name, workspace_slug, project_id, one or more of the fields are missing." - }, - status=status.HTTP_400_BAD_REQUEST, - ) - - email = request.data.get("email") - - try: - validate_email(email) - except ValidationError: - return Response( - {"error": "Invalid email provided"}, - status=status.HTTP_400_BAD_REQUEST, - ) - - workspace = Workspace.objects.filter(slug=slug).first() - project = Project.objects.filter(pk=project_id).first() - - if not workspace or not project: - return Response( - {"error": "Provided workspace or project does not exist"}, - status=status.HTTP_400_BAD_REQUEST, - ) - - user = User.objects.filter(email=email).first() - workspace_member = WorkspaceMember.objects.filter( - workspace=workspace, member=user - ).first() if user else None - project_member = ProjectMember.objects.filter( - project=project, member=user - ).first() if user else None - - if user and project_member: - return Response( - { - "error": "User is already part of the workspace and project" - }, - status=status.HTTP_400_BAD_REQUEST, - ) - - if not user: - user = User.objects.create( - email=email, - display_name=request.data.get("display_name"), - first_name=request.data.get("first_name", ""), - last_name=request.data.get("last_name", ""), - username=uuid.uuid4().hex, - password=make_password(uuid.uuid4().hex), - is_password_autoset=True, - is_active=False, - ) - - if not workspace_member: - workspace_member = WorkspaceMember.objects.create( - workspace=workspace, - member=user, - role=request.data.get("role", 10), - ) - - if not project_member: - project_member = ProjectMember.objects.create( - project=project, - member=user, - role=request.data.get("role", 10), - ) - - user_data = UserLiteSerializer(user).data - - return Response(user_data, status=status.HTTP_201_CREATED) + def post(self, request, slug, project_id): + required_fields = ["email", "display_name"] + if any(field not in request.data for field in required_fields): + return Response( + { + "error": "Expected email, display_name, workspace_slug, project_id, one or more of the fields are missing." + }, + status=status.HTTP_400_BAD_REQUEST, + ) + + email = request.data.get("email") + try: + validate_email(email) + except ValidationError: + return Response( + {"error": "Invalid email provided"}, + status=status.HTTP_400_BAD_REQUEST, + ) + + workspace = Workspace.objects.filter(slug=slug).first() + project = Project.objects.filter(pk=project_id).first() + + if not workspace or not project: + return Response( + {"error": "Provided workspace or project does not exist"}, + status=status.HTTP_400_BAD_REQUEST, + ) + + user = User.objects.filter(email=email).first() + if user: + workspace_member = WorkspaceMember.objects.filter( + workspace=workspace, member=user + ).first() + project_member = ProjectMember.objects.filter( + project=project, member=user + ).first() + if project_member: + return Response( + { + "error": "User is already part of the workspace and project" + }, + status=status.HTTP_400_BAD_REQUEST, + ) + else: + user = User.objects.create( + email=email, + display_name=request.data.get("display_name"), + first_name=request.data.get("first_name", ""), + last_name=request.data.get("last_name", ""), + username=uuid.uuid4().hex, + password=make_password(uuid.uuid4().hex), + is_password_autoset=True, + is_active=False, + ) + + if not WorkspaceMember.objects.filter(workspace=workspace, member=user).exists(): + WorkspaceMember.objects.create( + workspace=workspace, + member=user, + role=request.data.get("role", 10), + ) + + if not ProjectMember.objects.filter(project=project, member=user).exists(): + ProjectMember.objects.create( + project=project, + member=user, + role=request.data.get("role", 10), + ) + + user_data = UserLiteSerializer(user).data + return Response(user_data, status=status.HTTP_201_CREATED)apiserver/plane/api/serializers/issue.py (1)
433-433: Critical dependencies found forcreated_byandcreated_atfieldsThe
created_byandcreated_atfields are heavily used across various parts of the codebase, including serializers, views, models, migrations, and utility functions. Removing these fields from serialization could have significant implications on the application's functionality and data integrity.
- Serializers: The fields are included in multiple serializers, which means they are crucial for data representation.
- Views: They are used in various views, indicating their importance in request handling and response generation.
- Models: The fields are part of the data models, which suggests they are essential for maintaining data integrity.
- Migrations: The fields are present in migrations, indicating that they are part of the database schema.
- Utility Functions: The fields are used in utility functions, which implies they are important for various backend operations.
Please re-evaluate the removal of these fields to ensure no critical functionality is affected.
Analysis chain
Verify the impact of removing
created_byandcreated_atfields from serialization.Ensure that removing these fields does not affect any critical functionality or data representation in the application.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `created_by` and `created_at` fields in the codebase. # Test: Search for the usage of `created_by` and `created_at` fields. Expect: No critical dependencies. rg --type python -A 5 $'created_by' rg --type python -A 5 $'created_at'Length of output: 131
Script:
#!/bin/bash # Description: Verify the usage of `created_by` and `created_at` fields in the codebase. # Test: Search for the usage of `created_by` and `created_at` fields. Expect: No critical dependencies. rg -t py -A 5 'created_by' rg -t py -A 5 'created_at'Length of output: 462768
apiserver/plane/api/views/issue.py (1)
42-42: Inconsistent usage of the corrected import statement forissue_activity.The import statement for
issue_activityhas been corrected tofrom plane.bgtasks.issue_activities_task import issue_activityin some places but remains incorrect (from plane.bgtasks.issue_activites_task import issue_activity) in several other files. Please update the import statement in the following files to ensure consistency:
apiserver/plane/space/views/inbox.pyapiserver/plane/space/views/issue.pyapiserver/plane/api/views/module.pyapiserver/plane/api/views/inbox.pyapiserver/plane/bgtasks/issue_automation_task.pyapiserver/plane/app/views/module/issue.pyapiserver/plane/app/views/module/base.pyapiserver/plane/app/views/issue/draft.pyapiserver/plane/app/views/issue/sub_issue.pyapiserver/plane/app/views/issue/relation.pyapiserver/plane/app/views/issue/reaction.pyapiserver/plane/app/views/issue/link.pyapiserver/plane/app/views/issue/bulk_operations.pyapiserver/plane/app/views/issue/base.pyapiserver/plane/app/views/issue/attachment.pyapiserver/plane/app/views/issue/archive.pyapiserver/plane/app/views/inbox/base.pyapiserver/plane/app/views/cycle/issue.pyapiserver/plane/app/views/cycle/base.pyapiserver/plane/app/views/issue/comment.pyAnalysis chain
Verify the consistency of the corrected import statement for
issue_activity.The import statement for
issue_activityhas been corrected fromissue_activites_tasktoissue_activities_task. Ensure that the corrected import statement is used consistently throughout the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the consistency of the corrected import statement for `issue_activity`. # Test: Search for the usage of the `issue_activity` import statement. Expect: Consistent usage of the corrected import statement. rg --type python -A 5 $'issue_activity'Length of output: 69
Script:
#!/bin/bash # Description: Verify the consistency of the corrected import statement for `issue_activity`. # Test: Search for the usage of the `issue_activity` import statement. Expect: Consistent usage of the corrected import statement. rg --type py -A 5 $'issue_activity'Length of output: 96080
apiserver/plane/api/views/cycle.py (1)
663-663: Remove or replace theThe
- print("cycle name", cycle.name) + # Use proper logging instead of print for production code. + logger.debug(f"Cycle name: {cycle.name}")
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- apiserver/plane/api/serializers/issue.py (3 hunks)
- apiserver/plane/api/urls/member.py (1 hunks)
- apiserver/plane/api/views/init.py (1 hunks)
- apiserver/plane/api/views/cycle.py (3 hunks)
- apiserver/plane/api/views/issue.py (7 hunks)
- apiserver/plane/api/views/member.py (3 hunks)
- apiserver/plane/bgtasks/issue_activites_task.py (2 hunks)
Additional context used
Ruff
apiserver/plane/api/views/__init__.py
28-28:
.member.ProjectMemberAPIEndpointimported but unused; consider removing, adding to__all__, or using a redundant alias(F401)
30-30:
.inbox.InboxIssueAPIEndpointimported but unused; consider removing, adding to__all__, or using a redundant alias(F401)
Additional comments not posted (16)
apiserver/plane/api/urls/member.py (2)
4-4: Import change approved.The import statement has been correctly updated to import
ProjectMemberAPIEndpoint.
9-10: URL pattern change approved.The URL pattern has been correctly updated to include
project_idand useProjectMemberAPIEndpoint.apiserver/plane/api/views/__init__.py (1)
28-28: Import change approved.The import statement has been correctly updated to import
ProjectMemberAPIEndpoint.Tools
Ruff
28-28:
.member.ProjectMemberAPIEndpointimported but unused; consider removing, adding to__all__, or using a redundant alias(F401)
apiserver/plane/api/views/member.py (3)
26-26: Class rename approved.The class has been correctly renamed from
WorkspaceMemberAPIEndpointtoProjectMemberAPIEndpoint.
28-28: Method update approved.The
getmethod has been correctly updated to includeproject_idand retrieve project members.
54-54: Method update approved.The
postmethod has been correctly updated to includeproject_idand assign users to projects.apiserver/plane/api/views/issue.py (4)
350-351: Ensure correctness of updates to thecreated_byfield forIssueentities.The changes ensure that the creator's ID is correctly assigned during the creation process. Verify that the
created_byfield is correctly handled and does not introduce any issues.Verification successful
The
created_byfield is correctly handled forIssueentities.The updates ensure that the creator's ID is correctly assigned during the creation process. The
created_byfield is consistently used and updated across multiple files, confirming its correct handling.
apiserver/plane/api/views/issue.pylines 350-351: Correctly assignscreated_byfromrequest.dataand saves it.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of updates to the `created_by` field for `Issue` entities. # Test: Search for the usage of the `created_by` field in the `post` method. Expect: Correct handling of the `created_by` field. rg --type python -A 5 $'created_by'Length of output: 65
Script:
#!/bin/bash # Description: Verify the correctness of updates to the `created_by` field for `Issue` entities. # Test: Search for the usage of the `created_by` field in the `post` method. Expect: Correct handling of the `created_by` field. rg --type py -A 5 $'created_by'Length of output: 252878
816-818: Ensure correctness of updates to thecreated_byfield forIssueCommententities.The changes ensure that the creator's ID is correctly assigned during the creation process. Verify that the
created_byfield is correctly handled and does not introduce any issues.Verification successful
Ensure correctness of updates to the
created_byfield forIssueCommententities.The
created_byfield is correctly assigned and saved during the creation process in thepostmethod of theIssueCommentViewclass. No issues were found with the handling of thecreated_byfield.
apiserver/plane/api/views/issue.py: Lines 816-818Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of updates to the `created_by` field for `IssueComment` entities. # Test: Search for the usage of the `created_by` field in the `post` method. Expect: Correct handling of the `created_by` field. rg --type python -A 5 $'created_by'Length of output: 65
Script:
#!/bin/bash # Description: Verify the correctness of updates to the `created_by` field for `IssueComment` entities. # Test: Search for the usage of the `created_by` field in the `post` method. Expect: Correct handling of the `created_by` field. rg --type py -A 5 'created_by'Length of output: 252878
155-184: Ensure robustness and correctness of new logic for handlingexternal_idandexternal_sourceparameters.The new logic includes error handling for scenarios where the issue is not found or multiple issues are returned. Ensure that this logic is correctly implemented and does not introduce any security or performance issues.
Verification successful
The new logic for handling
external_idandexternal_sourceparameters is robust and correctly implemented.The error handling for scenarios where the issue is not found or multiple issues are returned is appropriate and aligns with common practices. No security or performance issues were identified.
- The usage of
external_idandexternal_sourceis consistent across the codebase.- The error handling for
ObjectDoesNotExistandMultipleObjectsReturnedis correctly implemented.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of the new logic for handling `external_id` and `external_source` parameters. # Test: Search for the usage of `external_id` and `external_source` parameters. Expect: No security or performance issues. rg --type python -A 5 $'external_id' rg --type python -A 5 $'external_source'Length of output: 137
Script:
#!/bin/bash # Description: Verify the correctness of the new logic for handling `external_id` and `external_source` parameters. # Test: Search for the usage of `external_id` and `external_source` parameters in Python files. Expect: No security or performance issues. rg 'external_id' -g '*.py' -A 5 rg 'external_source' -g '*.py' -A 5Length of output: 64196
646-649: Ensure correctness of updates to thecreated_byfield forIssueLinkentities.The changes ensure that the creator's ID is correctly assigned during the creation process. Verify that the
created_byfield is correctly handled and does not introduce any issues.apiserver/plane/api/views/cycle.py (4)
677-688: Ensure correctness of refactored logic for handling cycle issues.The refactored logic includes a negation query to exclude issues already associated with the current cycle and separates existing and new issues for better tracking. Verify that the refactored logic is correctly implemented and does not introduce any issues.
Verification successful
The refactored logic for handling cycle issues is correctly implemented and does not introduce any issues.
The logic correctly excludes issues already associated with the current cycle and separates existing and new issues for better tracking.
apiserver/plane/api/views/cycle.pylines 677-688Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of the refactored logic for handling cycle issues. # Test: Search for the usage of the refactored logic for handling cycle issues. Expect: Correct implementation of the refactored logic. rg --type python -A 5 $'cycle_id'Length of output: 63
Script:
#!/bin/bash # Description: Verify the correctness of the refactored logic for handling cycle issues. # Test: Search for the usage of the refactored logic for handling cycle issues. Expect: Correct implementation of the refactored logic. rg -t py -A 5 'cycle_id'Length of output: 71908
665-674: Ensure correctness of enhanced validation for the cycle's end date.The enhanced validation prevents the addition of new issues if the cycle has already been completed. Verify that the validation is correctly implemented and does not introduce any issues.
Verification successful
The previous script failed due to an unrecognized file type. The
rgcommand should usepyinstead ofpythonfor the file type. Let's correct this and rerun the script to verify the usage of the cycle's end date validation.
The enhanced validation for the cycle's end date is correctly implemented.
The validation logic prevents the addition of new issues if the cycle has already been completed. The implementation is consistent and correctly applied across the codebase.
apiserver/plane/api/views/cycle.py: Lines 665-674Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of the enhanced validation for the cycle's end date. # Test: Search for the usage of the cycle's end date validation. Expect: Correct implementation of the validation. rg --type python -A 5 $'end_date'Length of output: 63
Script:
#!/bin/bash # Description: Verify the correctness of the enhanced validation for the cycle's end date. # Test: Search for the usage of the cycle's end date validation. Expect: Correct implementation of the validation. rg --type py -A 5 $'end_date'Length of output: 28568
740-740: Ensure correctness of updates to thecreated_cycle_issuesfield.The
created_cycle_issuesfield has been updated to reflect the new structure of created records. Verify that the updates to thecreated_cycle_issuesfield are correctly implemented.Verification successful
Ensure correctness of updates to the
created_cycle_issuesfield.The
created_cycle_issuesfield has been updated to reflect the new structure of created records. The updates to thecreated_cycle_issuesfield are correctly implemented.
- Files and lines to verify:
apiserver/plane/api/views/cycle.pyapiserver/plane/bgtasks/issue_activites_task.pyapiserver/plane/app/views/cycle/issue.pyapiserver/plane/app/views/cycle/base.pyScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of updates to the `created_cycle_issues` field. # Test: Search for the usage of the `created_cycle_issues` field. Expect: Correct implementation of the updates. rg --type python -A 5 $'created_cycle_issues'Length of output: 75
Script:
#!/bin/bash # Description: Verify the correctness of updates to the `created_cycle_issues` field. # Test: Search for the usage of the `created_cycle_issues` field. Expect: Correct implementation of the updates. rg -t py -A 5 'created_cycle_issues'Length of output: 2325
732-746: Ensure correctness of updates to theissue_activity.delayfunction.The invocation of the
issue_activity.delayfunction has been updated to reflect the new structures of created and updated records. Verify that the updates to theissue_activity.delayfunction are correctly implemented.Verification successful
Ensure correctness of updates to the
issue_activity.delayfunction.The invocation of the
issue_activity.delayfunction has been updated to reflect the new structures of created and updated records. The extensive usage of this function across multiple files with consistent parameters confirms that the updates are correctly implemented.
apiserver/plane/api/views/cycle.py(lines 732-746)Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of updates to the `issue_activity.delay` function. # Test: Search for the usage of the `issue_activity.delay` function. Expect: Correct implementation of the updates. rg --type python -A 5 $'issue_activity.delay'Length of output: 75
Script:
#!/bin/bash # Description: Verify the correctness of updates to the `issue_activity.delay` function. # Test: Search for the usage of the `issue_activity.delay` function. Expect: Correct implementation of the updates. rg -t py -A 5 'issue_activity.delay'Length of output: 36112
apiserver/plane/bgtasks/issue_activites_task.py (2)
596-597: LGTM!The addition of
actor_idassignment ensures better attribution of actions to users.
1777-1777: LGTM!The changes in
create_issue_activitywill enhance the tracking of issue activities.
apiserver/plane/api/views/member.py
Outdated
| project_members = ProjectMember.objects.filter( | ||
| project_id=project_id, workspace_id=workspace.id |
There was a problem hiding this comment.
Optimize query performance.
The query can be optimized by using select_related to reduce the number of database hits.
- project_members = ProjectMember.objects.filter(
- project_id=project_id, workspace_id=workspace.id
- )
+ project_members = ProjectMember.objects.filter(
+ project_id=project_id, workspace_id=workspace.id
+ ).select_related('member')Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| project_members = ProjectMember.objects.filter( | |
| project_id=project_id, workspace_id=workspace.id | |
| project_members = ProjectMember.objects.filter( | |
| project_id=project_id, workspace_id=workspace.id | |
| ).select_related('member') |
There was a problem hiding this comment.
Actionable comments posted: 1
Outside diff range, codebase verification and nitpick comments (1)
apiserver/plane/api/views/issue.py (1)
155-172: Error handling for issue retrieval is missing.The
getmethod does not handle scenarios where the issue is not found (ObjectDoesNotExist) or when multiple issues are returned (MultipleObjectsReturned). Please add appropriate error handling to ensure robustness.
apiserver/plane/api/views/issue.pyAnalysis chain
Verify error handling for issue retrieval.
Ensure that error handling is in place for scenarios where the issue is not found (
ObjectDoesNotExist) or when multiple issues are returned (MultipleObjectsReturned).Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify error handling for issue retrieval. # Test: Search for error handling in the `get` method. Expect: Error handling for ObjectDoesNotExist and MultipleObjectsReturned. rg --type python -A 5 'def get(self, request, slug, project_id, pk=None)' | grep -E 'ObjectDoesNotExist|MultipleObjectsReturned'Length of output: 161
Script:
#!/bin/bash # Description: Verify error handling for issue retrieval. # Test: Search for error handling in the `get` method. Expect: Error handling for ObjectDoesNotExist and MultipleObjectsReturned. rg --type py -A 5 'def get(self, request, slug, project_id, pk=None)' | grep -E 'ObjectDoesNotExist|MultipleObjectsReturned'Length of output: 126
Script:
#!/bin/bash # Description: Verify error handling for issue retrieval. # Test: Search for error handling in the entire file. Expect: Error handling for ObjectDoesNotExist and MultipleObjectsReturned. rg 'ObjectDoesNotExist|MultipleObjectsReturned' apiserver/plane/api/views/issue.pyLength of output: 163
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- apiserver/plane/api/views/cycle.py (3 hunks)
- apiserver/plane/api/views/issue.py (7 hunks)
Files skipped from review as they are similar to previous changes (1)
- apiserver/plane/api/views/cycle.py
Additional context used
Ruff
apiserver/plane/api/views/issue.py
7-7:
django.core.exceptions.ObjectDoesNotExistimported but unusedRemove unused import
(F401)
7-7:
django.core.exceptions.MultipleObjectsReturnedimported but unusedRemove unused import
(F401)
Additional comments not posted (5)
apiserver/plane/api/views/issue.py (5)
338-339: LGTM!The changes ensure that the
created_byfield is correctly assigned during the creation process.
633-638: LGTM!The code correctly fetches the issue to retrieve the
created_byID for logging purposes.
800-807: LGTM!The changes ensure that the
created_byfield is correctly assigned during the creation process.
7-7: Remove unused imports.The
ObjectDoesNotExistandMultipleObjectsReturnedimports are not used in thegetmethod.Tools
Ruff
7-7:
django.core.exceptions.ObjectDoesNotExistimported but unusedRemove unused import
(F401)
7-7:
django.core.exceptions.MultipleObjectsReturnedimported but unusedRemove unused import
(F401)
155-172: Verify error handling for issue retrieval.Ensure that error handling is in place for scenarios where the issue is not found (
ObjectDoesNotExist) or when multiple issues are returned (MultipleObjectsReturned).
apiserver/plane/api/views/issue.py
Outdated
| from django.core.serializers.json import DjangoJSONEncoder | ||
|
|
||
| # Django imports | ||
| from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned |
There was a problem hiding this comment.
Remove unused imports.
The ObjectDoesNotExist and MultipleObjectsReturned imports are not used in the code.
- from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturnedCommittable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned |
Tools
Ruff
7-7:
django.core.exceptions.ObjectDoesNotExistimported but unusedRemove unused import
(F401)
7-7:
django.core.exceptions.MultipleObjectsReturnedimported but unusedRemove unused import
(F401)
There was a problem hiding this comment.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
There was a problem hiding this comment.
Actionable comments posted: 2
Outside diff range, codebase verification and nitpick comments (1)
apiserver/plane/api/views/member.py (1)
44-44: Improve ReadabilityConsider adding a comment to explain the purpose of filtering users by
project_members.+ # Filter users by project members
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- apiserver/plane/api/views/issue.py (6 hunks)
- apiserver/plane/api/views/member.py (4 hunks)
Additional comments not posted (7)
apiserver/plane/api/views/member.py (4)
26-26: Class Name ChangeThe class name has been updated to
ProjectMemberAPIEndpoint, reflecting the transition from workspace to project context.
28-28: Method Signature UpdateThe
getmethod now includes theproject_idparameter, ensuring project-specific member retrieval.
52-52: Method Signature UpdateThe
postmethod now includes theproject_idparameter, ensuring project-specific user assignment.
78-78: Remove Redundant CheckThe check for both
workspaceandprojectcan be simplified.- if not all([workspace, project]): + if not workspace or not project:Likely invalid or redundant comment.
apiserver/plane/api/views/issue.py (3)
154-156: New Parameters for Issue RetrievalThe
getmethod now includes parameters forexternal_idandexternal_source, enhancing the API's robustness.
337-338: Updatecreated_byFieldThe
postmethod now updates thecreated_byfield, ensuring accurate tracking of the issue creator.
799-805: Updatecreated_byFieldThe
postmethod now updates thecreated_byfield for issue comments, ensuring accurate tracking of the comment creator.
There was a problem hiding this comment.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- apiserver/plane/api/views/cycle.py (1 hunks)
- apiserver/plane/api/views/issue.py (4 hunks)
- apiserver/plane/api/views/member.py (4 hunks)
Files skipped from review as they are similar to previous changes (2)
- apiserver/plane/api/views/cycle.py
- apiserver/plane/api/views/member.py
Additional comments not posted (4)
apiserver/plane/api/views/issue.py (4)
157-171: Handle Non-Existent Issues GracefullyConsider handling the case where the issue with the given
external_idandexternal_sourcedoes not exist.- issue = Issue.objects.get( - external_id=external_id, - external_source=external_source, - workspace__slug=slug, - project_id=project_id, - ) - return Response( - IssueSerializer( - issue, - fields=self.fields, - expand=self.expand, - ).data, - status=status.HTTP_200_OK, - ) + try: + issue = Issue.objects.get( + external_id=external_id, + external_source=external_source, + workspace__slug=slug, + project_id=project_id, + ) + return Response( + IssueSerializer( + issue, + fields=self.fields, + expand=self.expand, + ).data, + status=status.HTTP_200_OK, + ) + except Issue.DoesNotExist: + return Response( + {"error": "Issue not found"}, + status=status.HTTP_404_NOT_FOUND, + )
337-341: Verify the correctness of settingcreated_atandcreated_by.Ensure that
created_atandcreated_byfields are correctly set for theIssue.- issue.created_at = request.data.get("created_at", timezone.now()) - issue.created_by_id = request.data.get( - "created_by", request.user.id - ) - issue.save(update_fields=["created_at", "created_by"])
637-640: Verify the correctness of settingcreated_by.Ensure that
created_byfield is correctly set for theIssueLink.- link.created_by_id = request.data.get( - "created_by", request.user.id - ) - link.save(update_fields=["created_by"])
806-812: Verify the correctness of settingcreated_atandcreated_by.Ensure that
created_atandcreated_byfields are correctly set for theIssueComment.- issue_comment.created_at = request.data.get( - "created_at", timezone.now() - ) - issue_comment.created_by_id = request.data.get( - "created_by", request.user.id - ) - issue_comment.save(update_fields=["created_at", "created_by"])
Tasks
WorkspaceMemberEndpointtoProjectMemberEndpointfor fetching and creating new usersSummary by CodeRabbit
New Features
external_idandexternal_source.Improvements
Bug Fixes
Refactor