Features: 1) Add permission-aware get_queryset method to OrderProductViewSet; 2) Add permission-aware get_queryset method to PromoCodeViewSet;
Fixes: None; Extra: None;
This commit is contained in:
parent
543594c2b8
commit
03c9874f63
1 changed files with 18 additions and 0 deletions
|
|
@ -377,6 +377,15 @@ class OrderProductViewSet(EvibesViewSet):
|
|||
"list": OrderProductSimpleSerializer,
|
||||
}
|
||||
|
||||
def get_queryset(self):
|
||||
qs = super().get_queryset()
|
||||
user = self.request.user
|
||||
|
||||
if user.has_perm("core.view_orderproduct"):
|
||||
return qs
|
||||
|
||||
return qs.filter(user=user)
|
||||
|
||||
|
||||
class ProductImageViewSet(EvibesViewSet):
|
||||
queryset = ProductImage.objects.all()
|
||||
|
|
@ -397,6 +406,15 @@ class PromoCodeViewSet(EvibesViewSet):
|
|||
"list": PromoCodeSimpleSerializer,
|
||||
}
|
||||
|
||||
def get_queryset(self):
|
||||
qs = super().get_queryset()
|
||||
user = self.request.user
|
||||
|
||||
if user.has_perm("core.view_promocode"):
|
||||
return qs
|
||||
|
||||
return qs.filter(user=user)
|
||||
|
||||
|
||||
class PromotionViewSet(EvibesViewSet):
|
||||
queryset = Promotion.objects.all()
|
||||
|
|
|
|||
Loading…
Reference in a new issue