-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* dev: views initiated * dev: refactor filtering logic * dev: move state grouping filter to util function * dev: view issues create endpoint and update on filters for time * dev: rename views to issue views * dev: rename in serilaizer and views * dev: update issue filters * dev: update filter * feat: create issue favorites * dev: update query keys * dev: update create and update method
- Loading branch information
1 parent
46f6b61
commit b6ee197
Showing
9 changed files
with
495 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,55 @@ | ||
# Third party imports | ||
from rest_framework import serializers | ||
|
||
# Module imports | ||
from .base import BaseSerializer | ||
|
||
from plane.db.models import View | ||
from plane.db.models import IssueView, IssueViewFavorite | ||
from plane.utils.issue_filters import issue_filters | ||
|
||
|
||
class IssueViewSerializer(BaseSerializer): | ||
is_favorite = serializers.BooleanField(read_only=True) | ||
|
||
class Meta: | ||
model = IssueView | ||
fields = "__all__" | ||
read_only_fields = [ | ||
"workspace", | ||
"project", | ||
"query", | ||
] | ||
|
||
def create(self, validated_data): | ||
query_params = validated_data.get("query_data", {}) | ||
|
||
if not bool(query_params): | ||
raise serializers.ValidationError( | ||
{"query_data": ["Query data field cannot be empty"]} | ||
) | ||
|
||
validated_data["query"] = issue_filters(query_params, "POST") | ||
return IssueView.objects.create(**validated_data) | ||
|
||
def update(self, instance, validated_data): | ||
query_params = validated_data.get("query_data", {}) | ||
if not bool(query_params): | ||
raise serializers.ValidationError( | ||
{"query_data": ["Query data field cannot be empty"]} | ||
) | ||
|
||
validated_data["query"] = issue_filters(query_params, "PATCH") | ||
return super().update(instance, validated_data) | ||
|
||
|
||
class IssueViewFavoriteSerializer(BaseSerializer): | ||
view_detail = IssueViewSerializer(source="issue_view", read_only=True) | ||
|
||
class ViewSerializer(BaseSerializer): | ||
class Meta: | ||
model = View | ||
model = IssueViewFavorite | ||
fields = "__all__" | ||
read_only_fields = [ | ||
"workspace", | ||
"project", | ||
"user", | ||
] |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.