Files
RasadDam_Backend/apps/core/mixins/admin_mixin.py

15 lines
459 B
Python
Raw Permalink Normal View History

2025-08-11 12:16:02 +03:30
from rest_framework.viewsets import GenericViewSet
from common.helpers import get_organization_by_user
class AdminFilterMixin:
admin_param_name = 'admin'
def get_query(self, queryset):
request = self.request # noqa
if request.query_params.get(self.admin_param_name):
return queryset.order_by('-create_date')
2025-08-11 12:16:02 +03:30
2025-08-11 12:20:58 +03:30
return queryset.filter(organization=get_organization_by_user(request.user)).order_by('-create_date')