Skip to content

Commit

Permalink
Merge branch 'feat/remove-org-external-calls' into merge/remove-org-e…
Browse files Browse the repository at this point in the history
…xternal-calls-delete-chats-permission
  • Loading branch information
AlisoSouza committed Dec 11, 2023
2 parents 6ab942c + 4e45145 commit 895b0ec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 36 deletions.
3 changes: 2 additions & 1 deletion connect/api/v2/organizations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from connect.api.v2.paginations import CustomCursorPagination
import pendulum


class OrganizationViewSet(
mixins.RetrieveModelMixin,
mixins.ListModelMixin,
Expand Down Expand Up @@ -94,7 +95,7 @@ def perform_destroy(self, instance):
user_email = self.request.user.email
instance.perform_destroy_ai_organization(user_email)
instance.delete()

@action(
detail=True,
methods=["GET"],
Expand Down
36 changes: 1 addition & 35 deletions connect/common/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,7 @@ def create_service_status(sender, instance, created, **kwargs):
project_auth = instance.get_user_authorization(authorization.user)
project_auth.role = authorization.role
project_auth.save()
if not settings.TESTING and project_auth.is_moderator:
RequestChatsPermission.objects.create(
email=project_auth.user.email,
role=ChatsRole.ADMIN.value,
project=project_auth.project,
created_by=project_auth.user
)

elif update_fields and "flow_organization" in update_fields:
for permission in instance.project_authorizations.all():
update_user_permission_project(
Expand Down Expand Up @@ -131,13 +125,6 @@ def org_authorizations(sender, instance, created, **kwargs):
if instance.role > project_perm.role:
project_perm.role = project_role
project_perm.save(update_fields=["role"])
if not settings.TESTING:
ai_client = IntelligenceRESTClient()
ai_client.update_user_permission_organization(
organization_id=instance.organization.inteligence_organization,
user_email=instance.user.email,
permission=instance.role
)


@receiver(post_delete, sender=OrganizationAuthorization)
Expand Down Expand Up @@ -228,34 +215,13 @@ def request_permission_project(sender, instance, created, **kwargs):
auth_user.role = instance.role
auth_user.save(update_fields=["role"])

if not settings.TESTING and auth_user.is_moderator:
RequestChatsPermission.objects.create(
email=instance.email,
role=ChatsRole.ADMIN.value,
project=instance.project,
created_by=instance.created_by
)
instance.delete()
instance.project.send_email_invite_project(email=instance.email)


@receiver(post_save, sender=ProjectAuthorization)
def project_authorization(sender, instance, created, **kwargs):
if created:
if instance.is_moderator:
RequestChatsPermission.objects.create(
email=instance.user.email,
role=ChatsRole.ADMIN.value,
project=instance.project,
created_by=instance.user
)
else:
RequestChatsPermission.objects.create(
email=instance.user.email,
role=ChatsRole.AGENT.value,
project=instance.project,
created_by=instance.user
)

RecentActivity.objects.create(
action="ADD",
Expand Down

0 comments on commit 895b0ec

Please sign in to comment.