Fixes: OrderViewSet fixes
This commit is contained in:
parent
beb1673cbb
commit
17ae42a0b8
1 changed files with 12 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import uuid
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
|
@ -272,10 +273,18 @@ class OrderViewSet(EvibesViewSet):
|
||||||
return qs.filter(user=user)
|
return qs.filter(user=user)
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
lookup_val = self.kwargs.get(self.lookup_field)
|
lookup_val = self.kwargs[self.lookup_field]
|
||||||
|
qs = self.get_queryset()
|
||||||
|
|
||||||
|
try:
|
||||||
|
uuid.UUID(lookup_val)
|
||||||
|
uuid_q = Q(uuid=lookup_val)
|
||||||
|
except ValueError:
|
||||||
|
uuid_q = Q()
|
||||||
|
|
||||||
obj = get_object_or_404(
|
obj = get_object_or_404(
|
||||||
self.get_queryset(),
|
qs,
|
||||||
Q(uuid=lookup_val) | Q(human_readable_id=lookup_val)
|
uuid_q | Q(human_readable_id=lookup_val)
|
||||||
)
|
)
|
||||||
self.check_object_permissions(self.request, obj)
|
self.check_object_permissions(self.request, obj)
|
||||||
return obj
|
return obj
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue