MCPcopy Index your code
hub / github.com/Flagsmith/flagsmith / create

Method create

api/organisations/views.py:118–131  ·  view source on GitHub ↗

Override create method to add new organisation to authenticated user

(self, request, **kwargs)

Source from the content-addressed store, hash-verified

116 return super(OrganisationViewSet, self).get_throttles()
117
118 def create(self, request, **kwargs): # type: ignore[no-untyped-def]
119 """
120 Override create method to add new organisation to authenticated user
121 """
122
123 user = request.user
124 serializer = OrganisationSerializerFull(data=request.data)
125 if serializer.is_valid():
126 org = serializer.save()
127 user.add_organisation(org, OrganisationRole.ADMIN)
128
129 return Response(serializer.data, status.HTTP_201_CREATED)
130 else:
131 return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
132
133 @action(
134 detail=False,

Callers 7

create_subscriptionMethod · 0.45
get_portal_urlFunction · 0.45
handleMethod · 0.45

Calls 4

is_validMethod · 0.80
add_organisationMethod · 0.80
saveMethod · 0.45

Tested by

no test coverage detected