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

[WEB-2092] chore: soft delete migration #5286

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

NarayanBavisetti
Copy link
Collaborator

@NarayanBavisetti NarayanBavisetti commented Aug 2, 2024

chore:

  • this pull request contains the migration for the table in which unique together constraints have been added, allowing entities that have been deleted to be created again with the same type.

Issue Link: WEB-2092

Summary by CodeRabbit

  • New Features

    • Enhanced data models to support soft deletions by adding deleted_at field in uniqueness constraints for several models.
    • Improved filtering logic to exclude deleted records from issue queries, enhancing data integrity.
    • Updated access control for page deletion, allowing greater user flexibility.
  • Bug Fixes

    • Adjusted deletion logic to ensure it adheres to soft deletion practices across various views, potentially preventing unauthorized deletions.
  • Documentation

    • Updated migration documentation to reflect changes in unique constraints and soft delete handling for improved clarity.

@NarayanBavisetti NarayanBavisetti added ⚙️backend 🔄migrations Contains Migration changes labels Aug 2, 2024
@NarayanBavisetti NarayanBavisetti added this to the v0.23-dev milestone Aug 2, 2024
Copy link
Contributor

coderabbitai bot commented Aug 2, 2024

Walkthrough

The recent changes enhance the management of soft deletions across various models in the application. By integrating a deleted_at field into uniqueness constraints, the system can effectively differentiate between active and logically deleted records, preserving data integrity. Additionally, modifications to serializers and simplifications in method calls streamline operations, facilitating better data handling practices throughout the application.

Changes

Files Change Summary
apiserver/plane/app/serializers/issue.py Added deleted_at to serializer fields and read-only settings to enhance data integrity and manage deletion timestamps.
apiserver/plane/app/views/cycle/base.py, .../views/module/base.py, .../views/page/base.py, .../views/project/base.py, .../views/view/base.py Removed explicit soft deletion parameters in destroy methods, implying a potential shift in deletion behavior to support soft deletes by default.
apiserver/plane/db/migrations/0073_alter_commentreaction_unique_together_and_more.py Modified uniqueness constraints across multiple models to include deleted_at, allowing for soft deletion and preserving historical data integrity.
apiserver/plane/db/models/*.py (multiple files including cycle.py, dashboard.py, etc.) Enhanced uniqueness constraints to incorporate deleted_at, enabling soft deletes while maintaining active record integrity across various models like CycleUserProperties, Issue, etc.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant View
    participant Model

    User->>View: Request deletion of record
    View->>Model: Call delete() without soft parameter
    Model-->>View: Respond with deletion status
    View-->>User: Confirmation of deletion
Loading

🐇 In fields of code where bunnies play,
New rules for soft deletes came to stay.
With deleted_at now in sight,
Data's kept safe, oh what a delight!
Hopping through models, we cheer and sing,
For a future of records, soft deletion will bring!
🌼✨


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (3)
apiserver/plane/db/models/page.py (1)

237-244: Ensure deleted_at is considered in ProjectPage operations.

The operations involving the ProjectPage model do not currently account for the deleted_at field in their conditions. To respect the new uniqueness constraints, please update these operations to include conditions that ensure deleted_at is null when necessary.

  • apiserver/plane/bgtasks/dummy_data_task.py
  • apiserver/plane/app/views/search/base.py
  • apiserver/plane/app/views/page/base.py
  • apiserver/plane/app/serializers/page.py
Analysis chain

LGTM! But verify the function usage in the codebase.

The changes to the Meta class of ProjectPage are approved.

However, ensure that all queries and operations involving ProjectPage are updated to account for the new uniqueness constraints.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all queries and operations involving `ProjectPage` are updated to account for the new uniqueness constraints.

# Test: Search for the `ProjectPage` model usage. Expect: Queries and operations consider the new constraints.
rg --type python -A 5 $'ProjectPage'

Length of output: 66


Script:

#!/bin/bash
# Description: Verify all queries and operations involving `ProjectPage` are updated to account for the new uniqueness constraints.

# Test: Search for the `ProjectPage` model usage. Expect: Queries and operations consider the new constraints.
rg 'ProjectPage' --glob '*.py' -A 5

Length of output: 7423


Script:

#!/bin/bash
# Description: Verify all queries and operations involving `ProjectPage` are updated to account for the new uniqueness constraints.

# Test: Search for the usage of `ProjectPage` and check for conditions involving `deleted_at`.
rg 'ProjectPage' apiserver/plane/bgtasks/dummy_data_task.py -A 5
rg 'ProjectPage' apiserver/plane/app/views/search/base.py -A 5
rg 'ProjectPage' apiserver/plane/app/views/page/base.py -A 5
rg 'ProjectPage' apiserver/plane/app/serializers/page.py -A 5

Length of output: 1484

apiserver/plane/db/models/workspace.py (1)

220-227: Ensure deleted_at field is indexed.

The deleted_at field is not currently indexed in the WorkspaceMemberInvite model. Given its inclusion in the unique_together constraint and the new constraints list, indexing this field is crucial for performance. Please add an index to the deleted_at field.

  • File: apiserver/plane/db/models/workspace.py
  • Lines: 220-227
Analysis chain

Ensure deleted_at field exists and is indexed.

The addition of deleted_at to the unique_together constraint and the new constraints list is correct for handling soft deletions. Ensure that the deleted_at field exists in the model and is indexed for performance.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `deleted_at` field exists and is indexed in the `WorkspaceMemberInvite` model.

# Test: Search for the `deleted_at` field definition. Expect: The field should be defined and indexed.
rg --type python 'deleted_at' --context 5

Length of output: 72


Script:

#!/bin/bash
# Description: Verify that the `deleted_at` field exists and is indexed in the `WorkspaceMemberInvite` model.

# Test: Search for the `deleted_at` field definition. Expect: The field should be defined and indexed.
rg --type py 'deleted_at' --context 5

Length of output: 183000


Script:

#!/bin/bash
# Description: Verify if the `deleted_at` field is indexed in the `WorkspaceMemberInvite` model.

# Test: Search for index definitions on the `deleted_at` field in the `WorkspaceMemberInvite` model.
rg --type py 'deleted_at' --context 10 | grep -i 'index'

Length of output: 149

apiserver/plane/app/views/module/base.py (1)

843-843: Verify the deletion behavior.

The removal of the soft=False parameter from the delete method call in apiserver/plane/app/views/module/base.py changes the deletion behavior to a soft delete by default. This aligns with the implementation found in apiserver/plane/db/mixins.py, where the delete method performs a soft delete unless explicitly overridden. Ensure that this change aligns with the intended functionality.

  • File: apiserver/plane/app/views/module/base.py
  • Relevant Implementation: apiserver/plane/db/mixins.py (soft delete by default)
Analysis chain

Verify the deletion behavior.

The removal of the soft=False parameter from the delete method call potentially changes the deletion behavior to a soft delete. Ensure that this change aligns with the intended functionality.


Let's correct the previous script to properly search for the delete method implementation in the UserFavorite model.


Let's search for the delete method implementation across all Python files to locate its definition and understand its behavior.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the deletion behavior of the `delete` method on `UserFavorite` model.

# Test: Search for the `delete` method implementation in the `UserFavorite` model.
rg --type python -A 5 $'class UserFavorite' | rg 'def delete'

Length of output: 93


Script:

#!/bin/bash
# Description: Verify the deletion behavior of the `delete` method on `UserFavorite` model.

# Test: Search for the `delete` method implementation in the `UserFavorite` model.
rg --type py -A 5 'class UserFavorite' | rg 'def delete'

Length of output: 58


Script:

#!/bin/bash
# Description: Verify the deletion behavior of the `delete` method across the codebase.

# Test: Search for the `delete` method implementation across all Python files.
rg --type py 'def delete' -A 5

Length of output: 19956

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f55c135 and f6ea45f.

Files ignored due to path filters (1)
  • web/public/sw.js.map is excluded by !**/*.map
Files selected for processing (21)
  • apiserver/plane/app/serializers/issue.py (2 hunks)
  • apiserver/plane/app/views/cycle/base.py (1 hunks)
  • apiserver/plane/app/views/module/base.py (1 hunks)
  • apiserver/plane/app/views/page/base.py (2 hunks)
  • apiserver/plane/app/views/project/base.py (1 hunks)
  • apiserver/plane/app/views/search/issue.py (1 hunks)
  • apiserver/plane/app/views/view/base.py (1 hunks)
  • apiserver/plane/db/migrations/0073_alter_commentreaction_unique_together_and_more.py (1 hunks)
  • apiserver/plane/db/models/cycle.py (1 hunks)
  • apiserver/plane/db/models/dashboard.py (1 hunks)
  • apiserver/plane/db/models/deploy_board.py (1 hunks)
  • apiserver/plane/db/models/estimate.py (2 hunks)
  • apiserver/plane/db/models/favorite.py (1 hunks)
  • apiserver/plane/db/models/inbox.py (1 hunks)
  • apiserver/plane/db/models/issue.py (9 hunks)
  • apiserver/plane/db/models/issue_type.py (2 hunks)
  • apiserver/plane/db/models/module.py (3 hunks)
  • apiserver/plane/db/models/page.py (2 hunks)
  • apiserver/plane/db/models/project.py (2 hunks)
  • apiserver/plane/db/models/state.py (2 hunks)
  • apiserver/plane/db/models/workspace.py (6 hunks)
Additional comments not posted (49)
apiserver/plane/db/models/issue_type.py (3)

3-3: Import statement for Q added.

The import statement for Q from django.db.models is necessary for the conditional unique constraint.


19-19: Update unique constraint to include deleted_at.

The unique_together constraint now includes deleted_at, allowing for multiple entries with the same name and project as long as they have different deleted_at values.


20-26: New unique constraint with condition added.

The new models.UniqueConstraint ensures that the combination of name and project remains unique only when deleted_at is null. This enhances the model's ability to handle soft deletions.

apiserver/plane/db/models/deploy_board.py (2)

49-49: Update unique constraint to include deleted_at.

The unique_together constraint now includes deleted_at, allowing for multiple entries with the same entity_name and entity_identifier as long as they have different deleted_at values.


50-56: New unique constraint with condition added.

The new models.UniqueConstraint ensures that the combination of entity_name and entity_identifier remains unique only when deleted_at is null. This enhances the model's ability to handle soft deletions.

apiserver/plane/db/models/estimate.py (3)

4-4: Import statement for Q added.

The import statement for Q from django.db.models is necessary for the conditional unique constraint.


23-23: Update unique constraint to include deleted_at.

The unique_together constraint now includes deleted_at, allowing for multiple entries with the same name and project as long as they have different deleted_at values.


24-30: New unique constraint with condition added.

The new models.UniqueConstraint ensures that the combination of name and project remains unique only when deleted_at is null. This enhances the model's ability to handle soft deletions.

apiserver/plane/db/models/favorite.py (2)

34-34: LGTM! The unique_together constraint update supports soft delete functionality.

The addition of the deleted_at field to the unique_together constraint ensures that the combination of entity_type, user, entity_identifier, and deleted_at is unique, which is crucial for implementing soft deletes.


35-41: LGTM! The new UniqueConstraint enhances data integrity.

The new UniqueConstraint ensures that the combination of entity_type, entity_identifier, and user is unique when deleted_at is null, which helps maintain data integrity by preventing conflicts between active and deleted records.

apiserver/plane/db/models/inbox.py (2)

22-22: LGTM! The unique_together constraint update supports soft delete functionality.

The addition of the deleted_at field to the unique_together constraint ensures that the combination of name, project, and deleted_at is unique, which is crucial for implementing soft deletes.


23-29: LGTM! The new UniqueConstraint enhances data integrity.

The new UniqueConstraint ensures that the combination of name and project is unique when deleted_at is null, which helps maintain data integrity by preventing conflicts between active and deleted records.

apiserver/plane/db/models/state.py (2)

40-40: LGTM! The unique_together constraint update supports soft delete functionality.

The addition of the deleted_at field to the unique_together constraint ensures that the combination of name, project, and deleted_at is unique, which is crucial for implementing soft deletes.


41-47: LGTM! The new UniqueConstraint enhances data integrity.

The new UniqueConstraint ensures that the combination of name and project is unique when deleted_at is null, which helps maintain data integrity by preventing conflicts between active and deleted records.

apiserver/plane/db/models/dashboard.py (2)

91-91: Enhance uniqueness constraint to include deleted_at.

Adding deleted_at to the unique_together constraint ensures that soft-deleted records do not violate uniqueness constraints. This is a good practice for handling soft deletions.


92-98: Introduce conditional uniqueness constraint for active records.

The new UniqueConstraint ensures that the combination of widget and dashboard is unique only when deleted_at is null. This prevents conflicts with active records while allowing soft-deleted records to coexist.

apiserver/plane/app/views/search/issue.py (2)

57-58: Enhance filtering logic to exclude soft-deleted related issues.

Adding issue_related__deleted_at__isnull=True ensures that only non-deleted related issues are considered. This improves the integrity of the data returned by the view.


61-62: Enhance filtering logic to exclude soft-deleted related issues.

Adding issue_related__deleted_at__isnull=True ensures that only non-deleted related issues are considered. This improves the integrity of the data returned by the view.

apiserver/plane/db/models/cycle.py (2)

164-164: Enhance uniqueness constraint to include deleted_at.

Adding deleted_at to the unique_together constraint ensures that soft-deleted records do not violate uniqueness constraints. This is a good practice for handling soft deletions.


165-171: Introduce conditional uniqueness constraint for active records.

The new UniqueConstraint ensures that the combination of cycle and user is unique only when deleted_at is null. This prevents conflicts with active records while allowing soft-deleted records to coexist.

apiserver/plane/db/models/module.py (3)

133-140: LGTM! But verify the function usage in the codebase.

The changes to the Meta class of ModuleMember are approved.

However, ensure that all queries and operations involving ModuleMember are updated to account for the new uniqueness constraints.


239-246: LGTM! But verify the function usage in the codebase.

The changes to the Meta class of ModuleUserProperties are approved.

However, ensure that all queries and operations involving ModuleUserProperties are updated to account for the new uniqueness constraints.


159-166: LGTM! But verify the function usage in the codebase.

The changes to the Meta class of ModuleIssue are approved.

However, ensure that all queries and operations involving ModuleIssue are updated to account for the new uniqueness constraints.

apiserver/plane/db/models/page.py (1)

266-273: LGTM! But verify the function usage in the codebase.

The changes to the Meta class of TeamPage are approved.

However, ensure that all queries and operations involving TeamPage are updated to account for the new uniqueness constraints.

apiserver/plane/db/models/project.py (2)

334-341: LGTM! But verify the function usage in the codebase.

The changes to the Meta class of ProjectPublicMember are approved.

However, ensure that all queries and operations involving ProjectPublicMember are updated to account for the new uniqueness constraints.


217-224: LGTM! But verify the function usage in the codebase.

The changes to the Meta class of ProjectMember are approved.

However, ensure that all queries and operations involving ProjectMember are updated to account for the new uniqueness constraints.

apiserver/plane/db/models/workspace.py (5)

188-195: Ensure deleted_at field exists and is indexed.

The addition of deleted_at to the unique_together constraint and the new constraints list is correct for handling soft deletions. Ensure that the deleted_at field exists in the model and is indexed for performance.


288-295: Ensure deleted_at field exists and is indexed.

The addition of deleted_at to the unique_together constraint and the new constraints list is correct for handling soft deletions. Ensure that the deleted_at field exists in the model and is indexed for performance.


257-264: Ensure deleted_at field exists and is indexed.

The addition of deleted_at to the unique_together constraint and the new constraints list is correct for handling soft deletions. Ensure that the deleted_at field exists in the model and is indexed for performance.


318-325: Ensure deleted_at field exists and is indexed.

The addition of deleted_at to the unique_together constraint and the new constraints list is correct for handling soft deletions. Ensure that the deleted_at field exists in the model and is indexed for performance.


350-357: Ensure deleted_at field exists and is indexed.

The addition of deleted_at to the unique_together constraint and the new constraints list is correct for handling soft deletions. Ensure that the deleted_at field exists in the model and is indexed for performance.

apiserver/plane/app/views/view/base.py (2)

Line range hint 389-389:
Verify the default behavior of delete method.

The removal of the soft=False argument suggests that the default behavior of the delete method will be used. Ensure that this aligns with the intended deletion behavior (soft or hard delete).


477-477: Verify the default behavior of delete method.

The removal of the soft=False argument suggests that the default behavior of the delete method will be used. Ensure that this aligns with the intended deletion behavior (soft or hard delete).

Verification successful

Verify the default behavior of delete method.

The default behavior of the delete method in the UserFavorite model is a soft delete, as indicated by the soft=True default parameter in the delete method defined in apiserver/plane/db/mixins.py. Ensure that this aligns with the intended deletion behavior (soft or hard delete).

  • File: apiserver/plane/db/mixins.py
  • Line: def delete(self, using=None, soft=True, *args, **kwargs):
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the default behavior of the `delete` method in the `UserFavorite` model.

# Test: Search for the `delete` method definition. Expect: The method should be defined with the correct default behavior.
rg --type python 'def delete' --context 5

Length of output: 74


Script:

#!/bin/bash
# Description: Verify the default behavior of the `delete` method in the `UserFavorite` model.

# Search for the `delete` method definition in Python files.
rg --type py 'def delete' --context 5

# Additionally, search for the `UserFavorite` model to narrow down the context.
rg --type py 'class UserFavorite' --context 10

Length of output: 36385

apiserver/plane/app/serializers/issue.py (2)

536-536: Approved: Added deleted_at to read_only_fields.

Including deleted_at in read_only_fields ensures the field is immutable through this serializer, which is appropriate for soft deletion.


555-555: Approved: Added deleted_at to read_only_fields.

Including deleted_at in read_only_fields ensures the field is immutable through this serializer, which is appropriate for soft deletion.

apiserver/plane/app/views/project/base.py (1)

602-602: Approved: Removed soft=False from delete method.

Removing the soft=False argument ensures that the default deletion behavior is used, aligning with the shift towards soft deletion.

apiserver/plane/db/models/issue.py (8)

298-305: Approved: Added deleted_at to unique_together and new constraints list.

Including deleted_at in the unique_together constraint and adding the new constraints list ensures that uniqueness is maintained only for non-deleted records, which is appropriate for soft deletion.


326-333: Approved: Added deleted_at to unique_together and new constraints list.

Including deleted_at in the unique_together constraint and adding the new constraints list ensures that uniqueness is maintained only for non-deleted records, which is appropriate for soft deletion.


354-361: Approved: Added deleted_at to unique_together and new constraints list.

Including deleted_at in the unique_together constraint and adding the new constraints list ensures that uniqueness is maintained only for non-deleted records, which is appropriate for soft deletion.


536-543: Approved: Added deleted_at to unique_together and new constraints list.

Including deleted_at in the unique_together constraint and adding the new constraints list ensures that uniqueness is maintained only for non-deleted records, which is appropriate for soft deletion.


641-648: Approved: Added deleted_at to unique_together and new constraints list.

Including deleted_at in the unique_together constraint and adding the new constraints list ensures that uniqueness is maintained only for non-deleted records, which is appropriate for soft deletion.


670-677: Approved: Added deleted_at to unique_together and new constraints list.

Including deleted_at in the unique_together constraint and adding the new constraints list ensures that uniqueness is maintained only for non-deleted records, which is appropriate for soft deletion.


701-708: Approved: Added deleted_at to unique_together and new constraints list.

Including deleted_at in the unique_together constraint and adding the new constraints list ensures that uniqueness is maintained only for non-deleted records, which is appropriate for soft deletion.


739-746: Approved: Added deleted_at to unique_together and new constraints list.

Including deleted_at in the unique_together constraint and adding the new constraints list ensures that uniqueness is maintained only for non-deleted records, which is appropriate for soft deletion.

apiserver/plane/db/migrations/0073_alter_commentreaction_unique_together_and_more.py (4)

8-10: LGTM!

The migration dependencies are correctly specified.


145-717: LGTM!

The deleted_at field is consistently added to multiple models with the correct field definition.


719-857: LGTM!

The unique constraints are correctly altered to include the deleted_at field, ensuring that soft-deleted records do not violate unique constraints.


858-1129: LGTM!

The unique constraints with conditions are correctly added to multiple models, ensuring uniqueness when deleted_at is null.

apiserver/plane/app/views/cycle/base.py (1)

1157-1157: Verify the deletion behavior.

The removal of the soft=False parameter from the delete method call potentially changes the deletion behavior to a soft delete. Ensure that this change aligns with the intended functionality.

@@ -401,7 +386,7 @@ def destroy(self, request, slug, project_id, pk):
entity_identifier=pk,
entity_type="page",
)
page_favorite.delete(soft=False)
page_favorite.delete()
Copy link
Contributor

Choose a reason for hiding this comment

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

Re-add access control check for page deletion.

The removal of the conditional check that restricted the deletion of a page to only its owner or an admin significantly alters the access control logic. This change potentially allows unauthorized deletions. Re-add the access control check to ensure only authorized users can delete a page.

-  if not page.owned_by_id != request.user.id and not (
-      ProjectMember.objects.filter(
-          workspace__slug=slug,
-          member=request.user,
-          role=20,
-          project_id=project_id,
-          is_active=True,
-      ).exists()
-  ):
-      return Response(
-          {"error": "Only admin or owner can delete the page"},
-          status=status.HTTP_403_FORBIDDEN,
-      )

Committable suggestion was skipped due to low confidence.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f6ea45f and fb8b751.

Files selected for processing (1)
  • apiserver/plane/app/views/page/base.py (3 hunks)
Additional comments not posted (3)
apiserver/plane/app/views/page/base.py (3)

336-340: Enhanced security: Ensure the page is archived before deletion.

The added check ensures that a page must be archived before it can be deleted, which improves the integrity of the deletion process.


Line range hint 342-348:
Enhanced security: Access control for page deletion.

The re-added access control check ensures that only the owner or an admin can delete a page, preventing unauthorized deletions.


389-389: LGTM! Simplified deletion of favorite pages.

The deletion of a favorite page is straightforward and does not require additional access control checks.

@pablohashescobar pablohashescobar merged commit 76983a5 into preview Aug 2, 2024
13 of 14 checks passed
@pablohashescobar pablohashescobar deleted the chore/soft-delete-migration branch August 2, 2024 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙️backend 🔄migrations Contains Migration changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants