Exemple #1
0
    def get(self, request, args=None):
        '''

        :argument 管理页面数据展示

        :return

                {
                        'page': page_number,
                        'data': serializers.data,
                        'ding_switch': switch_dingding,
                        'mail_switch': switch_email
                }

        '''

        try:
            page = request.GET.get('page')
            con = json.loads(request.GET.get('con'))
        except KeyError as e:
            CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
            return HttpResponse(status=500)
        else:
            try:
                un_init = util.init_conf()
                custom_com = ast.literal_eval(un_init['other'])
                start = int(page) * 10 - 10
                end = int(page) * 10
                if con['valve']:
                    page_number = DatabaseList.objects.filter(
                        connection_name__contains=con['connection_name'],
                        computer_room__contains=con['computer_room']).count()
                    info = DatabaseList.objects.filter(
                        connection_name__contains=con['connection_name'],
                        computer_room__contains=con['computer_room']
                    )[start:end]
                else:
                    page_number = DatabaseList.objects.count()
                    if page_number == 0:
                        return Response({
                            'page': page_number,
                            'data': [],
                            'custom': custom_com['con_room']
                        })
                    info = DatabaseList.objects.all().order_by(
                        'connection_name')[start:end]
                serializers = Sqllist(info, many=True)

                return Response({
                    'page': page_number,
                    'data': serializers.data,
                    'custom': custom_com['con_room']
                })
            except Exception as e:
                print("调试########")
                CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
                return HttpResponse(status=500)
Exemple #2
0
    def get(self, request, args=None):
        '''

        :argument 管理页面数据展示

        :return

                {
                        'page': page_number,
                        'data': serializers.data,
                        'diclist': data,
                        'ding_switch': switch_dingding,
                        'mail_switch': switch_email
                }

        '''

        try:
            page = request.GET.get('page')
        except KeyError as e:
            CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
            return HttpResponse(status=500)
        else:
            try:
                page_number = DatabaseList.objects.aggregate(
                    alter_number=Count('id'))
                start = int(page) * 10 - 10
                end = int(page) * 10
                info = DatabaseList.objects.all()[start:end]
                serializers = Sqllist(info, many=True)
                data = SqlDictionary.objects.all().values('Name')
                data.query.group_by = ['Name']  # 不重复表名
                switch = globalpermissions.objects.filter(
                    authorization='global').first()
                switch_dingding = False
                switch_email = False
                if switch is not None:
                    if switch.dingding == 1:
                        switch_dingding = True
                    if switch.email == 1:
                        switch_email = True

                return Response({
                    'page': page_number,
                    'data': serializers.data,
                    'diclist': data,
                    'ding_switch': switch_dingding,
                    'mail_switch': switch_email
                })
            except Exception as e:
                CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
                return HttpResponse(status=500)
Exemple #3
0
    def get(self, request, args=None):
        '''

        :argument 管理页面数据展示

        :return

                {
                        'page': page_number,
                        'data': serializers.data,
                        'diclist': data,
                        'ding_switch': switch_dingding,
                        'mail_switch': switch_email
                }

        '''

        try:
            page = request.GET.get('page')
        except KeyError as e:
            CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
            return HttpResponse(status=500)
        else:
            try:
                un_init = util.init_conf()
                custom_com = ast.literal_eval(un_init['other'])
                page_number = DatabaseList.objects.count()
                start = int(page) * 10 - 10
                end = int(page) * 10
                info = DatabaseList.objects.all().order_by(
                    'connection_name')[start:end]
                serializers = Sqllist(info, many=True)
                data = SqlDictionary.objects.all().values('Name')
                data.query.group_by = ['Name']  # 不重复表名

                return Response({
                    'page': page_number,
                    'data': serializers.data,
                    'diclist': data,
                    'custom': custom_com['con_room']
                })
            except Exception as e:
                CUSTOM_ERROR.error(f'{e.__class__.__name__}: {e}')
                return HttpResponse(status=500)