fix-my devices - import new mixin of visible orgs
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.0 on 2025-11-02 12:13
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0080_quotafinalpricetypes_quotapricecalculationitems'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='historicalquotadistribution',
|
||||
name='description',
|
||||
field=models.TextField(blank=True, max_length=1000, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='quotadistribution',
|
||||
name='description',
|
||||
field=models.TextField(blank=True, max_length=1000, null=True),
|
||||
),
|
||||
]
|
||||
@@ -1,19 +1,21 @@
|
||||
import datetime
|
||||
from apps.product.web.api.v1.serializers import product_serializers as product_serializers
|
||||
from apps.product.web.api.v1.serializers import quota_serializers
|
||||
from apps.core.mixins.soft_delete_mixin import SoftDeleteMixin
|
||||
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||
from common.helpers import get_organization_by_user
|
||||
from rest_framework.exceptions import APIException
|
||||
from apps.product import models as product_models
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework import viewsets, filters
|
||||
from common.tools import CustomOperations
|
||||
from rest_framework import status
|
||||
from datetime import datetime
|
||||
|
||||
from django.db import transaction
|
||||
from django.db.models import Q
|
||||
from datetime import datetime
|
||||
from rest_framework import status
|
||||
from rest_framework import viewsets, filters
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.exceptions import APIException
|
||||
from rest_framework.response import Response
|
||||
|
||||
from apps.core.api import BaseViewSet
|
||||
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||
from apps.core.mixins.soft_delete_mixin import SoftDeleteMixin
|
||||
from apps.product import models as product_models
|
||||
from apps.product.web.api.v1.serializers import product_serializers as product_serializers
|
||||
from apps.product.web.api.v1.serializers import quota_serializers
|
||||
from common.helpers import get_organization_by_user
|
||||
|
||||
|
||||
def trash(queryset, pk): # noqa
|
||||
@@ -146,7 +148,7 @@ class ProductViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin)
|
||||
return Response(e, status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class ProductStatsViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
class ProductStatsViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
""" product statistics by its quotas """
|
||||
|
||||
queryset = product_models.ProductStats.objects.all()
|
||||
@@ -164,9 +166,11 @@ class ProductStatsViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearchM
|
||||
|
||||
try:
|
||||
organization = get_organization_by_user(request.user)
|
||||
product_stats = self.queryset.filter(organization=organization).order_by('-modify_date')
|
||||
product_stats = self.get_queryset(
|
||||
visibility_by_org_scope=True
|
||||
) if organization.free_visibility_by_scope else self.get_queryset()
|
||||
|
||||
page = self.paginate_queryset(product_stats) # noqa
|
||||
page = self.paginate_queryset(product_stats.order_by('-modify_date')) # noqa
|
||||
if page is not None:
|
||||
serializer = self.get_serializer(page, many=True)
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
Reference in New Issue
Block a user