* chore: paginated the issues in space app * chore: storing query using filters * chore: added filters for priority * chore: issue view model save function * chore: votes and reactions added in issues endpoint * chore: added filters in the public endpoint * chore: issue detail endpoint * chore: added labels, modules and assignees * refactor existing project publish in space app * fix clear all filters in space App * chore: removed the extra serialier * remove optional chaining and fallback to an empty array --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
# Third party imports
|
|
from rest_framework import serializers
|
|
|
|
# Module imports
|
|
from .base import DynamicBaseSerializer
|
|
from plane.db.models import IssueView
|
|
from plane.utils.issue_filters import issue_filters
|
|
|
|
|
|
class IssueViewSerializer(DynamicBaseSerializer):
|
|
is_favorite = serializers.BooleanField(read_only=True)
|
|
|
|
class Meta:
|
|
model = IssueView
|
|
fields = "__all__"
|
|
read_only_fields = [
|
|
"workspace",
|
|
"project",
|
|
"query",
|
|
"owned_by",
|
|
"access",
|
|
"is_locked",
|
|
]
|
|
|
|
def create(self, validated_data):
|
|
query_params = validated_data.get("filters", {})
|
|
if bool(query_params):
|
|
validated_data["query"] = issue_filters(query_params, "POST")
|
|
else:
|
|
validated_data["query"] = {}
|
|
return IssueView.objects.create(**validated_data)
|
|
|
|
def update(self, instance, validated_data):
|
|
query_params = validated_data.get("filters", {})
|
|
if bool(query_params):
|
|
validated_data["query"] = issue_filters(query_params, "POST")
|
|
else:
|
|
validated_data["query"] = {}
|
|
validated_data["query"] = issue_filters(query_params, "PATCH")
|
|
return super().update(instance, validated_data)
|