Skip to content

Commit

Permalink
feature: individual tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanJaeger committed Feb 4, 2025
1 parent 3abcab8 commit 7750855
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions chats/apps/api/v1/projects/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,29 @@ def partial_update(self, request, uuid=None):
project.save()
return Response(ProjectSerializer(project).data, status=status.HTTP_200_OK)

@action(
detail=True,
methods=["post"],
url_path="set-project-principal",
)
def set_project_as_principal(self, request, *args, **kwargs):
project = self.get_object()

config = project.config or {}
config["its_principal"] = True
project.config = config
project.save()

org_projects = Project.objects.filter(org=project.org).exclude(pk=project.pk)
org_projects.update(config={"its_secundary": True})

return Response(
{
"detail": "Project set as principal and other projects in the same org set as secondary."
},
status=status.HTTP_200_OK,
)


class ProjectPermissionViewset(viewsets.ReadOnlyModelViewSet):
queryset = (
Expand Down Expand Up @@ -536,26 +559,3 @@ def integrate_sectors(self, request, *args, **kwargs):
)

return Response("ticketers and topics integrated", status=status.HTTP_200_OK)

@action(
detail=False,
methods=["post"],
url_path="set-project-principal",
)
def set_project_as_principal(self, request, *args, **kwargs):
project = request.query_params.get("project")

config = project.config or {}
config["its_principal"] = True
project.config = config
project.save()

org_projects = Project.objects.filter(org=project.org).exclude(pk=project.pk)
org_projects.update(config={"its_secundary": True})

return Response(
{
"detail": "Project set as principal and other projects in the same org set as secondary."
},
status=status.HTTP_200_OK,
)

0 comments on commit 7750855

Please sign in to comment.