Skip to content

Comments

[WEB-2928] feat: Home Quick links CRUD#6290

Merged
sriramveeraghanta merged 7 commits intopreviewfrom
feat-home-quick-links
Dec 31, 2024
Merged

[WEB-2928] feat: Home Quick links CRUD#6290
sriramveeraghanta merged 7 commits intopreviewfrom
feat-home-quick-links

Conversation

@sangeethailango
Copy link
Member

@sangeethailango sangeethailango commented Dec 30, 2024

Description

This PR contains API endpoints of quick links

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added quick links management functionality for workspaces.
    • Introduced ability to create, list, update, and delete workspace quick links.
    • Implemented a new serializer for workspace user links.
    • Enhanced URL validation for quick links to ensure proper formatting.
  • Bug Fixes

    • Improved URL input validation to prevent incorrect link formats.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 30, 2024

Walkthrough

This pull request introduces functionality for managing quick links within workspaces. It adds a new serializer (WorkspaceUserLinkSerializer) for handling workspace user links, a view set (QuickLinkViewSet) to manage these links, and corresponding URL routing. The changes enable the creation, listing, updating, and deletion of quick links associated with a workspace, incorporating URL validation and access control.

Changes

File Change Summary
apiserver/plane/app/serializers/__init__.py Added import for WorkspaceUserLinkSerializer
apiserver/plane/app/serializers/workspace.py New WorkspaceUserLinkSerializer with URL validation and processing methods
apiserver/plane/app/urls/workspace.py Added URL patterns for quick link operations
apiserver/plane/app/views/__init__.py Imported QuickLinkViewSet
apiserver/plane/app/views/workspace/quick_link.py New QuickLinkViewSet with create, partial update, retrieve, and destroy methods

Possibly related PRs

  • chore: quick link migration #6274: This PR introduces the WorkspaceUserLink model, which is directly related to the WorkspaceUserLinkSerializer added in the main PR, as both involve the WorkspaceUserLink entity and its functionality.

Suggested labels

🌐frontend, ⚙️backend, 🌟improvement

Suggested reviewers

  • sriramveeraghanta
  • pablohashescobar
  • SatishGandham

Poem

🐰 Hop, hop, quick links take flight,
Workspace magic, shining bright!
URLs validated with care,
Serializers dancing everywhere,
A rabbit's code, a digital delight! 🌟

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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: 2

🧹 Nitpick comments (6)
apiserver/plane/app/views/workspace/quick_link.py (2)

11-11: Consider adding a docstring for QuickLinkViewSet.

Providing a brief class-level docstring documenting the purpose of this view set would improve clarity for future maintainers.


29-29: Line length hint from static analysis (93 > 88).

Although not a functional error, you can break the line for readability if your project conventions encourage strict adherence to line length limits.

🧰 Tools
🪛 Ruff (0.8.2)

29-29: Line too long (93 > 88)

(E501)

apiserver/plane/app/urls/workspace.py (3)

218-218: Consider making the comment more descriptive.
Right now, it's just “# quick link”. A short sentence or docstring in the code might provide better clarity on purpose or usage.


219-223: Remove the trailing space from the route name.
There is an extra space after "workspace-quick-links " which could lead to confusion or naming inconsistencies.

- name="workspace-quick-links "
+ name="workspace-quick-links"

224-228: Consider adding a ‘retrieve’ action for improved REST coverage.
Currently, the endpoint for a specific quick link supports partial_update and destroy actions but not get (retrieve). If you need to view individual quick links in subsequent features (or to follow standard CRUD patterns more closely), consider adding a retrieve action to the as_view() mapping.

apiserver/plane/app/serializers/workspace.py (1)

127-134: Nitpick: Align error key with field name.
Returning {"error": "Invalid URL format."} is valid, but consider returning {"url": "Invalid URL format."} to consistently associate the validation error with the url field.

- raise serializers.ValidationError({"error": "Invalid URL format."})
+ raise serializers.ValidationError({"url": "Invalid URL format."})
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94f421f and 2c4541f.

📒 Files selected for processing (5)
  • apiserver/plane/app/serializers/__init__.py (1 hunks)
  • apiserver/plane/app/serializers/workspace.py (2 hunks)
  • apiserver/plane/app/urls/workspace.py (2 hunks)
  • apiserver/plane/app/views/__init__.py (1 hunks)
  • apiserver/plane/app/views/workspace/quick_link.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
apiserver/plane/app/views/workspace/quick_link.py

29-29: Line too long (93 > 88)

(E501)

🔇 Additional comments (7)
apiserver/plane/app/views/workspace/quick_link.py (1)

21-24: Serialization logic looks appropriate.

This creation flow effectively validates and saves new WorkspaceUserLink objects. Code is clear and consistent with common DRF best practices.

apiserver/plane/app/serializers/__init__.py (1)

22-22: New serializer import recognized.

The WorkspaceUserLinkSerializer import is consistent with the newly introduced logic for managing quick links. This looks good.

apiserver/plane/app/serializers/workspace.py (4)

14-14: Confirmed import usage for WorkspaceUserLink.
The WorkspaceUserLink model import is consistent with the new serializer below.


18-20: New Django imports for URL validation.
These imports (URLValidator, ValidationError) are appropriate for validating URLs within the serializer.


114-119: Serializer looks consistent with the existing patterns.
The WorkspaceUserLinkSerializer extends BaseSerializer and correctly configures its Meta class.


120-126: Consider partial updates and explicit partial=True handling.
to_internal_value ensures the URL has a valid prefix. For partial updates, confirm the rest of the fields remain optional.

Would you like me to generate a script to check usage of to_internal_value calls for partial updates throughout the codebase?

apiserver/plane/app/views/__init__.py (1)

75-75: New import for QuickLinkViewSet.
Adding QuickLinkViewSet is consistent with the new quick link functionality.

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

🧹 Nitpick comments (1)
apiserver/plane/app/views/workspace/quick_link.py (1)

32-37: Fix line length issues with proper formatting.

The following lines exceed the recommended length limit of 88 characters. Consider reformatting:

-            serializer = WorkspaceUserLinkSerializer(quick_link, data=request.data, partial=True)
+            serializer = WorkspaceUserLinkSerializer(
+                quick_link,
+                data=request.data,
+                partial=True
+            )
🧰 Tools
🪛 Ruff (0.8.2)

32-32: Line too long (97 > 88)

(E501)


36-36: Line too long (90 > 88)

(E501)


37-37: Line too long (94 > 88)

(E501)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2c4541f and 274612c.

📒 Files selected for processing (1)
  • apiserver/plane/app/views/workspace/quick_link.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
apiserver/plane/app/views/workspace/quick_link.py

32-32: Line too long (97 > 88)

(E501)


36-36: Line too long (90 > 88)

(E501)


37-37: Line too long (94 > 88)

(E501)

🔇 Additional comments (2)
apiserver/plane/app/views/workspace/quick_link.py (2)

1-16: LGTM! Clean and well-organized class structure.

The imports are properly organized, and the class is well-structured with clear model and serializer definitions.


17-24: Handle Workspace.DoesNotExist exception gracefully.

The workspace retrieval could raise an unhandled exception. Consider adding error handling:

-        workspace = Workspace.objects.get(slug=slug)
+        try:
+            workspace = Workspace.objects.get(slug=slug)
+        except Workspace.DoesNotExist:
+            return Response({"detail": "Workspace not found."}, status=status.HTTP_404_NOT_FOUND)

@sangeethailango sangeethailango changed the title Crud for quick links [Web-2928]feat: Quick links CRUD Dec 30, 2024
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: 2

🧹 Nitpick comments (2)
apiserver/plane/app/urls/workspace.py (2)

219-223: Fix typo in URL name.

Remove the trailing space in the URL name "workspace-quick-links ".

Apply this fix:

-        name="workspace-quick-links "
+        name="workspace-quick-links"

224-228: Differentiate URL pattern names.

Using the same name for different URL patterns can cause issues with URL reversing. Consider adding a suffix to distinguish the detail view.

Apply this fix:

-        name="workspace-quick-links"
+        name="workspace-quick-links-detail"
🧰 Tools
🪛 Ruff (0.8.2)

226-226: Line too long (103 > 88)

(E501)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 274612c and ecfbec8.

📒 Files selected for processing (2)
  • apiserver/plane/app/urls/workspace.py (2 hunks)
  • apiserver/plane/app/views/workspace/quick_link.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
apiserver/plane/app/views/workspace/quick_link.py

32-32: Line too long (97 > 88)

(E501)


36-36: Line too long (90 > 88)

(E501)


37-37: Line too long (94 > 88)

(E501)


60-60: Line too long (94 > 88)

(E501)

apiserver/plane/app/urls/workspace.py

226-226: Line too long (103 > 88)

(E501)

🔇 Additional comments (4)
apiserver/plane/app/views/workspace/quick_link.py (4)

1-13: LGTM: Class setup and imports are well-organized.

The imports are properly structured and the class inherits from BaseViewSet with appropriate model specification.


14-15: LGTM: Serializer class method follows DRF conventions.


17-24: Handle Workspace.DoesNotExist exception gracefully.

Using Workspace.objects.get(slug=slug) might raise a Workspace.DoesNotExist exception.


27-37: Consider adding workspace-level access check.

The method should verify that the quick link belongs to the workspace specified in the URL.

🧰 Tools
🪛 Ruff (0.8.2)

32-32: Line too long (97 > 88)

(E501)


36-36: Line too long (90 > 88)

(E501)


37-37: Line too long (94 > 88)

(E501)

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

♻️ Duplicate comments (1)
apiserver/plane/app/views/workspace/quick_link.py (1)

17-24: ⚠️ Potential issue

Handle Workspace.DoesNotExist exception gracefully.

Using Workspace.objects.get(slug=slug) might raise a Workspace.DoesNotExist exception.

Apply this fix:

-        workspace = Workspace.objects.get(slug=slug)
+        try:
+            workspace = Workspace.objects.get(slug=slug)
+        except Workspace.DoesNotExist:
+            return Response({"detail": "Workspace not found."}, status=status.HTTP_404_NOT_FOUND)
🧹 Nitpick comments (3)
apiserver/plane/app/views/workspace/quick_link.py (3)

27-38: Improve code formatting for better readability.

The logic is correct, but let's fix the line length issues.

Apply this formatting:

-        quick_link = WorkspaceUserLink.objects.filter(pk=pk, workspace__slug=slug).first()
+        quick_link = WorkspaceUserLink.objects.filter(
+            pk=pk,
+            workspace__slug=slug
+        ).first()

-            serializer = WorkspaceUserLinkSerializer(quick_link, data=request.data, partial=True)
+            serializer = WorkspaceUserLinkSerializer(
+                quick_link,
+                data=request.data,
+                partial=True
+            )
🧰 Tools
🪛 Ruff (0.8.2)

29-29: Line too long (90 > 88)

(E501)


32-32: Line too long (97 > 88)

(E501)


36-36: Line too long (90 > 88)

(E501)


37-37: Line too long (94 > 88)

(E501)


54-61: Improve code formatting for better readability.

The logic is correct, but let's fix the line length issues.

Apply this formatting:

-        quick_link = WorkspaceUserLink.objects.filter(pk=pk, workspace__slug=slug).first()
+        quick_link = WorkspaceUserLink.objects.filter(
+            pk=pk,
+            workspace__slug=slug
+        ).first()
🧰 Tools
🪛 Ruff (0.8.2)

56-56: Line too long (90 > 88)

(E501)


61-61: Line too long (94 > 88)

(E501)


11-68: Consider architectural improvements for consistency and maintainability.

  1. Standardize error responses across all methods
  2. Add request validation middleware or utility methods
  3. Consider implementing a base exception handler for common exceptions

Example implementation for standardized error responses:

def error_response(message, status_code=status.HTTP_404_NOT_FOUND):
    return Response(
        {"error": message},
        status=status_code
    )

Would you like me to create an issue to track these architectural improvements?

🧰 Tools
🪛 Ruff (0.8.2)

29-29: Line too long (90 > 88)

(E501)


32-32: Line too long (97 > 88)

(E501)


36-36: Line too long (90 > 88)

(E501)


37-37: Line too long (94 > 88)

(E501)


56-56: Line too long (90 > 88)

(E501)


61-61: Line too long (94 > 88)

(E501)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ecfbec8 and a6a0da0.

📒 Files selected for processing (1)
  • apiserver/plane/app/views/workspace/quick_link.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
apiserver/plane/app/views/workspace/quick_link.py

29-29: Line too long (90 > 88)

(E501)


32-32: Line too long (97 > 88)

(E501)


36-36: Line too long (90 > 88)

(E501)


37-37: Line too long (94 > 88)

(E501)


56-56: Line too long (90 > 88)

(E501)


61-61: Line too long (94 > 88)

(E501)

🔇 Additional comments (2)
apiserver/plane/app/views/workspace/quick_link.py (2)

1-16: LGTM! Clean imports and class setup.

The imports are well-organized and the class structure follows Django REST framework patterns correctly.


39-52: LGTM! Well-implemented retrieve method.

The implementation uses proper error handling and includes workspace validation.

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

♻️ Duplicate comments (1)
apiserver/plane/app/views/workspace/quick_link.py (1)

17-24: ⚠️ Potential issue

Add exception handling for workspace retrieval.

The workspace retrieval could raise a DoesNotExist exception, leading to a 500 error instead of a proper 404 response.

Apply this fix:

-        workspace = Workspace.objects.get(slug=slug)
+        try:
+            workspace = Workspace.objects.get(slug=slug)
+        except Workspace.DoesNotExist:
+            return Response({"detail": "Workspace not found."}, status=status.HTTP_404_NOT_FOUND)
🧹 Nitpick comments (4)
apiserver/plane/app/views/workspace/quick_link.py (4)

27-37: Improve code formatting for better readability.

The logic is correct, but some lines exceed the recommended length limit.

Apply this formatting:

-        quick_link = WorkspaceUserLink.objects.filter(pk=pk, workspace__slug=slug).first()
+        quick_link = WorkspaceUserLink.objects.filter(
+            pk=pk,
+            workspace__slug=slug
+        ).first()

-            serializer = WorkspaceUserLinkSerializer(quick_link, data=request.data, partial=True)
+            serializer = WorkspaceUserLinkSerializer(
+                quick_link,
+                data=request.data,
+                partial=True
+            )
🧰 Tools
🪛 Ruff (0.8.2)

29-29: Line too long (90 > 88)

(E501)


32-32: Line too long (97 > 88)

(E501)


36-36: Line too long (90 > 88)

(E501)


37-37: Line too long (94 > 88)

(E501)


54-61: Improve code formatting in destroy method.

The logic is correct, but line lengths can be improved.

Apply this formatting:

-        quick_link = WorkspaceUserLink.objects.filter(pk=pk, workspace__slug=slug).first()
+        quick_link = WorkspaceUserLink.objects.filter(
+            pk=pk,
+            workspace__slug=slug
+        ).first()
🧰 Tools
🪛 Ruff (0.8.2)

56-56: Line too long (90 > 88)

(E501)


61-61: Line too long (94 > 88)

(E501)


63-68: Consider adding pagination for better performance.

The list method currently returns all quick links without pagination, which could impact performance with large datasets.

Consider implementing pagination:

     def list(self, request, slug):
         quick_links = WorkspaceUserLink.objects.filter(workspace__slug=slug)
-        
-        serializer = WorkspaceUserLinkSerializer(quick_links, many=True)
-        return Response(serializer.data, status=status.HTTP_200_OK)
+        return self.paginated_response(quick_links)

You'll need to add pagination settings in your DRF settings if not already configured.


11-68: Add docstrings and input validation.

The class implementation would benefit from:

  1. Class and method docstrings describing the purpose and parameters
  2. Input validation for the request data before processing

Example docstring format:

class QuickLinkViewSet(BaseViewSet):
    """ViewSet for managing workspace quick links.
    
    Provides CRUD operations for WorkspaceUserLink objects with proper
    permission checks at the workspace level.
    """
🧰 Tools
🪛 Ruff (0.8.2)

29-29: Line too long (90 > 88)

(E501)


32-32: Line too long (97 > 88)

(E501)


36-36: Line too long (90 > 88)

(E501)


37-37: Line too long (94 > 88)

(E501)


56-56: Line too long (90 > 88)

(E501)


61-61: Line too long (94 > 88)

(E501)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a6a0da0 and 0eee395.

📒 Files selected for processing (1)
  • apiserver/plane/app/views/workspace/quick_link.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
apiserver/plane/app/views/workspace/quick_link.py

29-29: Line too long (90 > 88)

(E501)


32-32: Line too long (97 > 88)

(E501)


36-36: Line too long (90 > 88)

(E501)


37-37: Line too long (94 > 88)

(E501)


56-56: Line too long (90 > 88)

(E501)


61-61: Line too long (94 > 88)

(E501)

🔇 Additional comments (2)
apiserver/plane/app/views/workspace/quick_link.py (2)

1-16: LGTM! Clean class setup with proper imports.

The imports are well-organized, and the class structure follows DRF conventions with appropriate model and serializer configuration.


39-52: LGTM! Well-implemented retrieve method.

The implementation includes proper error handling and workspace filtering.

@sriramveeraghanta sriramveeraghanta changed the title [Web-2928]feat: Quick links CRUD [WEB-2928] feat: Quick links CRUD Dec 30, 2024
@sriramveeraghanta sriramveeraghanta changed the title [WEB-2928] feat: Quick links CRUD [WEB-2928] feat: Home Quick links CRUD Dec 30, 2024
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

🧹 Nitpick comments (3)
apiserver/plane/app/views/workspace/quick_link.py (3)

30-38: Improve code formatting for better readability.

The implementation is correct, but the line lengths exceed the recommended limit.

Consider reformatting for better readability:

-        quick_link = WorkspaceUserLink.objects.filter(pk=pk, workspace__slug=slug, owner=request.user).first()
+        quick_link = WorkspaceUserLink.objects.filter(
+            pk=pk,
+            workspace__slug=slug,
+            owner=request.user
+        ).first()

-            serializer = WorkspaceUserLinkSerializer(quick_link, data=request.data, partial=True)
+            serializer = WorkspaceUserLinkSerializer(
+                quick_link,
+                data=request.data,
+                partial=True
+            )
🧰 Tools
🪛 Ruff (0.8.2)

30-30: Line too long (110 > 88)

(E501)


33-33: Line too long (97 > 88)

(E501)


37-37: Line too long (90 > 88)

(E501)


38-38: Line too long (94 > 88)

(E501)


62-67: Consider adding pagination for scalability.

While the implementation is correct, consider adding pagination to handle large numbers of quick links efficiently.

You can leverage DRF's pagination by:

  1. Setting pagination class in settings.py
  2. Or adding pagination_class to the ViewSet:
from rest_framework.pagination import PageNumberPagination

class QuickLinkViewSet(BaseViewSet):
    pagination_class = PageNumberPagination
🧰 Tools
🪛 Ruff (0.8.2)

64-64: Line too long (96 > 88)

(E501)


11-13: Consider adding filtering and ordering capabilities.

The ViewSet could benefit from additional features to enhance its functionality.

Consider adding:

  1. Filtering by created date, title, etc.
  2. Ordering options
  3. Search functionality

Example implementation:

from rest_framework import filters
from django_filters.rest_framework import DjangoFilterBackend

class QuickLinkViewSet(BaseViewSet):
    filter_backends = [DjangoFilterBackend, filters.OrderingFilter, filters.SearchFilter]
    filterset_fields = ['created_at', 'title']
    ordering_fields = ['created_at', 'title']
    search_fields = ['title', 'url']
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0eee395 and ab0e8fe.

📒 Files selected for processing (1)
  • apiserver/plane/app/views/workspace/quick_link.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
apiserver/plane/app/views/workspace/quick_link.py

30-30: Line too long (110 > 88)

(E501)


33-33: Line too long (97 > 88)

(E501)


37-37: Line too long (90 > 88)

(E501)


38-38: Line too long (94 > 88)

(E501)


58-58: Line too long (99 > 88)

(E501)


64-64: Line too long (96 > 88)

(E501)

🔇 Additional comments (3)
apiserver/plane/app/views/workspace/quick_link.py (3)

1-16: LGTM! Well-structured class setup.

The imports are properly organized, and the class structure follows DRF conventions with clear model and serializer definitions.


40-55: LGTM! Well-implemented retrieve method.

The implementation includes proper error handling, validation, and follows DRF best practices.


19-19: ⚠️ Potential issue

Add error handling for workspace retrieval.

The direct use of get() could raise an exception if the workspace doesn't exist.

Apply this fix:

-        workspace = Workspace.objects.get(slug=slug, owner=request.user)
+        try:
+            workspace = Workspace.objects.get(slug=slug)
+        except Workspace.DoesNotExist:
+            return Response(
+                {"error": "Workspace not found"},
+                status=status.HTTP_404_NOT_FOUND
+            )

Likely invalid or redundant comment.

@sriramveeraghanta sriramveeraghanta merged commit 25f7d81 into preview Dec 31, 2024
10 of 11 checks passed
@sriramveeraghanta sriramveeraghanta deleted the feat-home-quick-links branch December 31, 2024 09:36
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