Skip to content

Commit

Permalink
Merge pull request #139 from null-open-security-community/company_fix
Browse files Browse the repository at this point in the history
not exist sending blank data
  • Loading branch information
YogeshUpdhyay authored Dec 25, 2024
2 parents 3b04b04 + 0021adc commit d6126a6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions apps/jobs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,18 @@ def create(self, request, *args, **kwargs):

@action(detail=False, methods=["get"])
def me(self, request):
if request.user.is_anonymous or not request.user.is_profile_completed:
if request.user.is_anonymous:
raise exceptions.PermissionDenied()

# fetch user profile which has the company associated
company = Company.objects.get(creator=request.user)

return Response(self.serializer_class(company).data)
try:
# Attempt to fetch the company associated with the user
company = Company.objects.get(creator=request.user)
serializer = self.serializer_class(company)
return Response(serializer.data)
except Company.DoesNotExist:
# Return an empty serializer when no company is found
serializer = self.serializer_class()
return Response(serializer.data, status=status.HTTP_200_OK)


class ContactUsViewSet(viewsets.ModelViewSet):
Expand Down

0 comments on commit d6126a6

Please sign in to comment.