gold eggs backend
Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
This commit is contained in:
25
core/apps/eggs/views/history.py
Normal file
25
core/apps/eggs/views/history.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from rest_framework import viewsets
|
||||
|
||||
from core.apps.eggs.models import History
|
||||
from core.apps.eggs.serializers import HistorySerializer
|
||||
from core.http.permissions import IsRole
|
||||
|
||||
|
||||
class HistoryViewSet(viewsets.ModelViewSet):
|
||||
serializer_class = HistorySerializer
|
||||
http_method_names = ["get"]
|
||||
permission_classes = [IsRole(["admin", "sklad", "courier", "market"])]
|
||||
|
||||
def get_queryset(self):
|
||||
user = self.request.user
|
||||
action_param = self.request.query_params.get("action", None)
|
||||
|
||||
if user.role == "admin":
|
||||
queryset = History.objects.all()
|
||||
else:
|
||||
queryset = History.objects.filter(user_id=user.id)
|
||||
|
||||
if action_param:
|
||||
queryset = queryset.filter(action=action_param)
|
||||
|
||||
return queryset
|
||||
Reference in New Issue
Block a user