chore: remove view filter validation while creating or updating view (#836)

This commit is contained in:
pablohashescobar 2023-04-17 11:15:38 +05:30 committed by GitHub
parent 5a36a7931f
commit 61761fedc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,22 +25,18 @@ class IssueViewSerializer(BaseSerializer):
def create(self, validated_data): def create(self, validated_data):
query_params = validated_data.get("query_data", {}) query_params = validated_data.get("query_data", {})
if bool(query_params):
if not bool(query_params): validated_data["query"] = issue_filters(query_params, "POST")
raise serializers.ValidationError( else:
{"query_data": ["Query data field cannot be empty"]} validated_data["query"] = dict()
)
validated_data["query"] = issue_filters(query_params, "POST")
return IssueView.objects.create(**validated_data) return IssueView.objects.create(**validated_data)
def update(self, instance, validated_data): def update(self, instance, validated_data):
query_params = validated_data.get("query_data", {}) query_params = validated_data.get("query_data", {})
if not bool(query_params): if bool(query_params):
raise serializers.ValidationError( validated_data["query"] = issue_filters(query_params, "POST")
{"query_data": ["Query data field cannot be empty"]} else:
) validated_data["query"] = dict()
validated_data["query"] = issue_filters(query_params, "PATCH") validated_data["query"] = issue_filters(query_params, "PATCH")
return super().update(instance, validated_data) return super().update(instance, validated_data)