Skip to content

Commit

Permalink
get active contacts of all projects of a organization
Browse files Browse the repository at this point in the history
  • Loading branch information
BarbosaJackson committed Nov 5, 2021
1 parent 883826c commit 84ae0e4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions connect/api/v1/organization/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,28 @@ def get_contact_active(

return JsonResponse(data=result)

@action(
detail=True,
methods=["GET"],
url_name="get-contact-active-per-project",
url_path="contact-active-per-project/(?P<organization_uuid>[^/.]+)",
authentication_classes=[ExternalAuthentication],
permission_classes=[AllowAny],
)
def get_contacts_active_per_project(self, request, organization_uuid):
org = get_object_or_404(Organization, uuid=organization_uuid)
self.check_object_permissions(self.request, org)
response = {"projects": []}
for project in org.project.all():
response["projects"].append(
{
'project_uuid': project.uuid,
'project_name': project.name,
"active_contacts": project.contact_count
}
)
return JsonResponse(data=response)


class OrganizationAuthorizationViewSet(
MultipleFieldLookupMixin,
Expand Down

0 comments on commit 84ae0e4

Please sign in to comment.