Skip to content

Commit

Permalink
Merge pull request #885 from weni-ai/feature/update-brain-on
Browse files Browse the repository at this point in the history
Feature: Update brain_on field to handle dynamic boolean values
  • Loading branch information
ericosta-dev authored Aug 15, 2024
2 parents 22783a2 + 01f163c commit 0b357d3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions connect/api/v2/projects/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Meta:
"authorization",
"project_type",
"description",
"brain_on"
]
ref_name = None

Expand All @@ -76,6 +77,7 @@ class Meta:

authorization = serializers.SerializerMethodField(style={"show": False})
project_type = serializers.SerializerMethodField()
brain_on = serializers.BooleanField(default=False)

def get_project_type(self, obj):
if obj.is_template:
Expand All @@ -89,21 +91,19 @@ def create(self, validated_data):

template_uuid = self.context["request"].data.get("uuid")
is_template = self.context["request"].data.get("template", False)
brain_on = self.context["request"].data.get('brain_on', False)

if extra_data:
template_uuid = extra_data.get("uuid", template_uuid)
is_template = extra_data.get("template", is_template)

brain_on = extra_data.get('brain_on', False)
project_template_type = None
template_name = "blank"
if is_template:
project_template_type_queryset = TemplateType.objects.filter(uuid=template_uuid)
if project_template_type_queryset.exists():
project_template_type = project_template_type_queryset.first()
template_name = project_template_type.name

# brain_on = True if template_name == "blank" else False
brain_on = False
instance = Project.objects.create(
name=validated_data.get("name"),
timezone=str(validated_data.get("timezone")),
Expand Down

0 comments on commit 0b357d3

Please sign in to comment.