import - inventory dashboard / incentive plan search
This commit is contained in:
@@ -399,7 +399,7 @@ class IncentivePlanViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearch
|
||||
queryset = product_models.IncentivePlan.objects.all()
|
||||
serializer_class = product_serializers.IncentivePlanSerializer
|
||||
filter_backends = [filters.SearchFilter]
|
||||
search_fields = ['plan_type', 'name']
|
||||
search_fields = ['plan_type', 'name', 'group']
|
||||
|
||||
@transaction.atomic
|
||||
def create(self, request, *args, **kwargs):
|
||||
@@ -443,7 +443,9 @@ class IncentivePlanViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearch
|
||||
Q(is_time_unlimited=False) |
|
||||
Q(start_date_limit__lte=today, end_date_limit__gte=today)
|
||||
)
|
||||
page = self.paginate_queryset(incentive_plans)
|
||||
|
||||
queryset = self.filter_queryset(incentive_plans)
|
||||
page = self.paginate_queryset(queryset)
|
||||
if page is not None:
|
||||
serializer = self.get_serializer(page, many=True)
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
@@ -523,6 +523,13 @@ class QuotaViewSet(BaseViewSet, SoftDeleteMixin, QuotaDashboardService, viewsets
|
||||
""" list of organization active quotas that have inventory entries """
|
||||
|
||||
org = get_organization_by_user(request.user)
|
||||
query_param = self.request.query_params # noqa
|
||||
base_query = {}
|
||||
|
||||
# filter by product
|
||||
product_id = query_param.get('product_id') if 'product_id' in query_param.keys() else None
|
||||
if product_id:
|
||||
base_query['product_id'] = product_id
|
||||
|
||||
queryset = self.filter_query(
|
||||
self.get_queryset(visibility_by_org_scope=True).filter(
|
||||
@@ -534,6 +541,7 @@ class QuotaViewSet(BaseViewSet, SoftDeleteMixin, QuotaDashboardService, viewsets
|
||||
Q(assigned_organizations=org) |
|
||||
Q(registerer_organization=org),
|
||||
org_quota_stats__inventory_received__gt=0,
|
||||
**base_query
|
||||
).order_by('-modify_date').distinct()
|
||||
)
|
||||
if page is not None: # noqa
|
||||
|
||||
Reference in New Issue
Block a user