forked from github/plane
* dev: new proxy api setup * dev: updated endpoints with serializers and structure * dev: external apis for cycles, modules and inbox issue * dev: order by for all the apis * dev: enable webhooks for external apis * dev: fields and expand for the apis * dev: move authentication to proxy middleware * dev: fix imports * dev: api serializer updates and paginator * dev: renamed api to app * dev: renamed proxy to api * dev: validation for project, issues, modules and cycles * dev: remove favourites from project apis * dev: states api * dev: rewrite the url endpoints * dev: exception handling for the apis * dev: merge updated structure * dev: remove attachment apis * dev: issue activities endpoints
33 lines
804 B
Python
33 lines
804 B
Python
# Module imports
|
|
from .base import BaseSerializer
|
|
from plane.db.models import State
|
|
|
|
|
|
class StateSerializer(BaseSerializer):
|
|
def validate(self, data):
|
|
# If the default is being provided then make all other states default False
|
|
if data.get("default", False):
|
|
State.objects.filter(project_id=self.context.get("project_id")).update(
|
|
default=False
|
|
)
|
|
return data
|
|
|
|
class Meta:
|
|
model = State
|
|
fields = "__all__"
|
|
read_only_fields = [
|
|
"workspace",
|
|
"project",
|
|
]
|
|
|
|
|
|
class StateLiteSerializer(BaseSerializer):
|
|
class Meta:
|
|
model = State
|
|
fields = [
|
|
"id",
|
|
"name",
|
|
"color",
|
|
"group",
|
|
]
|
|
read_only_fields = fields |