def get(self, request, *args, **kwargs):
if '<STR_LIT>' not in request.GET.keys():<EOL><INDENT>return Response({ '<STR_LIT>': _('<STR_LIT>') }, status=<NUM_LIT>)<EOL><DEDENT>service_code = request.GET['<STR_LIT>']<EOL>if service_code not in SERVICES.keys():<EOL><INDENT>return Response({ '<STR_LIT>': _('<STR_LIT>') }, status=<NUM_LIT>)<EOL><DEDENT>start_date = None<EOL>end_date = None<EOL>status = None<EOL>layer = None<EOL>STATUSES = {}<EOL>for status_type in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>STATUSES[status_type] = [k for k, v in STATUS.items() if v == status_type]<EOL><DEDENT>if '<STR_LIT>' in request.GET.keys():<EOL><INDENT>start_date = request.GET['<STR_LIT>']<EOL>if iso8601_REGEXP.match(start_date) is None:<EOL><INDENT>return Response({ '<STR_LIT>': _('<STR_LIT>') }, status=<NUM_LIT>)<EOL><DEDENT><DEDENT>if '<STR_LIT>' in request.GET.keys():<EOL><INDENT>end_date = request.GET['<STR_LIT>']<EOL>if iso8601_REGEXP.match(end_date) is None:<EOL><INDENT>return Response({ '<STR_LIT>': _('<STR_LIT>') }, status=<NUM_LIT>)<EOL><DEDENT><DEDENT>if '<STR_LIT:status>' in request.GET.keys():<EOL><INDENT>if request.GET['<STR_LIT:status>'] not in ('<STR_LIT>','<STR_LIT>'):<EOL><INDENT>return Response({ '<STR_LIT>': _('<STR_LIT>') }, status=<NUM_LIT>)<EOL><DEDENT>status = request.GET['<STR_LIT:status>']<EOL><DEDENT>if '<STR_LIT>' in request.GET.keys():<EOL><INDENT>layer = request.GET['<STR_LIT>']<EOL>node_layer = get_object_or_404(Layer, slug=layer)<EOL><DEDENT>service_model = MODELS[service_code]<EOL>if service_code in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>self.queryset = service_model.objects.none()<EOL><DEDENT>else:<EOL><INDENT>self.queryset = service_model.objects.all()<EOL>if layer is not None:<EOL><INDENT>self.queryset = self.queryset.filter(layer = node_layer)<EOL><DEDENT>if start_date is not None and end_date is not None:<EOL><INDENT>self.queryset = self.queryset.filter(added__gte = start_date).filter(added__lte = end_date)<EOL><DEDENT>if start_date is not None and end_date is None:<EOL><INDENT>self.queryset = self.queryset.filter(added__gte = start_date)<EOL><DEDENT>if start_date is None and end_date is not None:<EOL><INDENT>self.queryset = self.queryset.filter(added__lte = end_date)<EOL><DEDENT><DEDENT>if status is not None:<EOL><INDENT>q_list = [Q(status__slug__exact = s) for s in STATUSES[status]]<EOL>self.queryset = self.queryset.filter(reduce(operator.or_, q_list))<EOL><DEDENT>return self.list(request, *args, **kwargs)<EOL>
Retrieve list of service requests