import - incentive plan filter by group
This commit is contained in:
@@ -437,11 +437,20 @@ class IncentivePlanViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSearch
|
||||
def active_plans(self, request):
|
||||
""" return active incentive plans """
|
||||
|
||||
query_param = self.request.query_param # noqa
|
||||
|
||||
group = query_param.get('group') if 'group' in query_param.keys() else None
|
||||
base_query = {}
|
||||
|
||||
if group:
|
||||
base_query['group'] = group
|
||||
|
||||
today = datetime.now().date()
|
||||
user_relations = product_models.UserRelations.objects.filter(user=request.user).first()
|
||||
incentive_plans = user_relations.incentive_plans.filter(
|
||||
Q(is_time_unlimited=False) |
|
||||
Q(start_date_limit__lte=today, end_date_limit__gte=today)
|
||||
Q(start_date_limit__lte=today, end_date_limit__gte=today),
|
||||
**base_query
|
||||
)
|
||||
|
||||
queryset = self.filter_queryset(incentive_plans)
|
||||
|
||||
Reference in New Issue
Block a user