Exemple #1
0
    def to_internal_value(self, data):
        if not isinstance(data, list):
            try:
                self._need_sync = str2bool(data['sync'])
                self._is_preview = str2bool(data.get('preview', False))
                data = data['data']
                if not isinstance(self._need_sync, bool):
                    raise Exception('sync value should be boolean')
                if not isinstance(data, list):
                    raise Exception('data value error')
            except Exception as e:
                raise ValidationError('Format Error {0}'.format(e))

        return super(ApplicationListSerializer, self).to_internal_value(data)
Exemple #2
0
 def func_wrapper(*args, **kwargs):
     queryset = func(*args, **kwargs)
     request = args[1]
     last_success = str2bool(request.query_params.get(param))
     if last_success:
         queryset = queryset.order_by('-created_at').filter(
             status=SUCCESS)[:1]
     return queryset
Exemple #3
0
 def func_wrapper(*args, **kwargs):
     queryset = func(*args, **kwargs)
     request = args[1]
     is_running = str2bool(request.query_params.get(param))
     if is_running is not None:
         if is_running:
             return queryset.exclude(status__in=HALTED)
         else:
             return queryset.filter(status__in=HALTED)
     return queryset
Exemple #4
0
 def func_wrapper(*args, **kwargs):
     queryset = func(*args, **kwargs)
     request = args[1]
     last_success = str2bool(request.query_params.get(param))
     if last_success:
         last_success_ids = queryset.filter(status=SUCCESS).annotate(
             max_pk=Max('pk'))
         queryset = queryset.filter(
             pk__in=last_success_ids.values('max_pk'))
     return queryset
Exemple #5
0
        def func_wrapper(*args, **kwargs):
            queryset = func(*args, **kwargs)
            request = args[1]
            fort_batch_id = None
            if isinstance(args[0], TarsFortDeployment):
                fort_batch_id = args[0].get_fort_batch().id
            is_fort_batch = str2bool(request.query_params.get(param))

            if is_fort_batch is not None:
                if is_fort_batch:
                    queryset = queryset.filter(id=fort_batch_id)
                else:
                    queryset = queryset.exclude(id=fort_batch_id)
            return queryset