Skip to content

Commit

Permalink
made project openai key non retrievable
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Sep 4, 2023
1 parent b1bc092 commit 641d500
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ayushma/serializers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@ class Meta:


class ProjectUpdateSerializer(serializers.ModelSerializer):
key_set = serializers.SerializerMethodField()

class Meta:
model = Project
fields = ProjectSerializer.Meta.fields + ("prompt", "open_ai_key")
fields = ProjectSerializer.Meta.fields + ("prompt", "open_ai_key", "key_set")
extra_kwargs = {
"open_ai_key": {"write_only": True},
}
read_only_fields = ("key_set",)

def update(self, instance, validated_data):
if validated_data.get("is_default", True):
Project.objects.all().update(is_default=False)
return super().update(instance, validated_data)

def get_key_set(self, obj):
return obj.open_ai_key is not None

0 comments on commit 641d500

Please sign in to comment.