Skip to content

Commit

Permalink
[#319] Fix to partner edit data fetch.
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomanuel committed May 31, 2021
1 parent d4ea42d commit 4f14eaa
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions api/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,6 @@ def get_queryset(self):
queryset = Partner.objects.filter(cooperative=self.request.user.cooperative_id)
return queryset

def get_object(self, pk):
try:
return Partner.objects.get(pk=pk)
except Partner.DoesNotExist:
raise Http404

@transaction.atomic
def create(self, request):
data = request.data
Expand Down Expand Up @@ -374,11 +368,7 @@ def send_email():
return Response('Partner asked to be created', status=status.HTTP_200_OK)

def destroy(self, request, *args, **kwargs):
partner = self.get_object(self.kwargs.get("pk", None))
if not partner:
partner = self.get_object()
partner_serializer = PartnerSerializer(data=partner)

partner = self.get_object()
if partner.id == request.user.id or partner.cooperative.id != request.user.cooperative.id:
return Response(_("Current logged in user can not delete itself."), status=status.HTTP_404_NOT_FOUND)

Expand Down

0 comments on commit 4f14eaa

Please sign in to comment.