Skip to content

Commit

Permalink
Merge pull request #723 from weni-ai/feature/eda-create-project-remov…
Browse files Browse the repository at this point in the history
…e-rest

revert extra fields migration
  • Loading branch information
AlisoSouza authored Sep 8, 2023
2 parents aa2905e + 104657f commit 2a0ea7e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 34 deletions.
2 changes: 1 addition & 1 deletion connect/api/v1/project/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def create(self, validated_data, request):
return data
else:
classifier_uuid = uuid.uuid4()

# Create Flow and Ticketer
if not settings.TESTING and not settings.USE_EDA:
rest_client = FlowsRESTClient()
Expand Down
24 changes: 11 additions & 13 deletions connect/api/v2/projects/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
import json
import uuid

from django.contrib.auth import get_user_model
from django.conf import settings
Expand Down Expand Up @@ -170,7 +169,7 @@ def create(self, validated_data):
project_template_type_queryset = TemplateType.objects.filter(name=extra_data.get("template_type"))
if project_template_type_queryset.exists():
project_template_type = project_template_type_queryset.first()

instance = Project.objects.create(
name=validated_data.get("name"),
timezone=str(validated_data.get("timezone")),
Expand Down Expand Up @@ -200,7 +199,6 @@ def create(self, validated_data):
return template_project

return instance


def _create(self, validated_data):
user = self.context["request"].user
Expand Down Expand Up @@ -290,16 +288,16 @@ def publish_create_project_message(self, instance):
authorizations.append({"email": authorization.user.email, "role": authorization.role})

message_body = {
"uuid": str(instance.uuid),
"name": instance.name,
"is_template": instance.is_template,
"user_email": instance.created_by.email if instance.created_by else None,
"date_format": instance.date_format,
"template_type_uuid": str(instance.project_template_type.uuid) if instance.project_template_type else None,
"timezone": str(instance.timezone),
"organization_id": instance.organization.inteligence_organization,
"extra_fields": instance.project_template_type.setup if instance.is_template else {},
}
"uuid": str(instance.uuid),
"name": instance.name,
"is_template": instance.is_template,
"user_email": instance.created_by.email if instance.created_by else None,
"date_format": instance.date_format,
"template_type_uuid": str(instance.project_template_type.uuid) if instance.project_template_type else None,
"timezone": str(instance.timezone),
"organization_id": instance.organization.inteligence_organization,
"extra_fields": self.context["request"].data.get("globals") if instance.is_template else {},
}

rabbitmq_publisher = RabbitmqPublisher()
rabbitmq_publisher.send_message(message_body, exchange="projects.topic", routing_key="")
Expand Down
2 changes: 0 additions & 2 deletions connect/common/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
from connect.api.v1.internal.intelligence.intelligence_rest_client import IntelligenceRESTClient
from connect.api.v1.internal.chats.chats_rest_client import ChatsRESTClient
from connect.common.tasks import update_user_permission_project
from requests.exceptions import HTTPError
from rest_framework.exceptions import APIException


logger = logging.getLogger("connect.common.signals")
Expand Down

This file was deleted.

0 comments on commit 2a0ea7e

Please sign in to comment.