Esempio n. 1
0
 def list_json_by_section(self, section):
     params = extract_select2_params(request.args)
     doc = self.service.get().get(section, {}).keys()
     term = params.get('search') or ''
     with_id = [{'id': key, 'text': key} for key in doc if term in key]
     params['limit'] = len(with_id)  # avoid pagination
     return jsonify(build_select2_response(with_id, len(with_id), params))
Esempio n. 2
0
 def list_json(self):
     params = extract_select2_params(request.args)
     doc = self.service.get()
     term = params.get('search') or ''
     with_id = [item for item in doc if term in item['text']]
     params['limit'] = len(with_id)  # avoid pagination
     return jsonify(build_select2_response(with_id, len(with_id), params))
Esempio n. 3
0
 def list_json(self):
     params = extract_select2_params(request.args)
     ivrs = self.service.list(**params)
     results = [{
         'id': ivr['id'],
         'text': ivr['name']
     } for ivr in ivrs['items']]
     return jsonify(build_select2_response(results, ivrs['total'], params))
Esempio n. 4
0
    def list_json(self):
        params = extract_select2_params(request.args)
        registrars = self.service.list()
        results = []
        for registrar in registrars['items']:
            results.append({'id': registrar['id'], 'text': registrar['name']})

        return jsonify(build_select2_response(results, registrars['total'], params))
Esempio n. 5
0
 def list_json(self):
     params = extract_select2_params(request.args)
     configs = self.service.list_device(**params)
     results = [{
         'id': config['id'],
         'text': config['label']
     } for config in configs['items']]
     return jsonify(
         build_select2_response(results, configs['total'], params))
Esempio n. 6
0
 def list_json(self):
     params = extract_select2_params(request.args)
     voicemails = self.service.list(**params)
     results = [{
         'id': vm['id'],
         'text': vm['name']
     } for vm in voicemails['items']]
     return jsonify(
         build_select2_response(results, voicemails['total'], params))
Esempio n. 7
0
 def list_json(self):
     params = extract_select2_params(request.args)
     switchboards = self.service.list(**params)
     results = [{
         'id': sw['uuid'],
         'text': sw['name']
     } for sw in switchboards['items']]
     return jsonify(
         build_select2_response(results, switchboards['total'], params))
Esempio n. 8
0
 def list_json(self):
     params = extract_select2_params(request.args)
     identities = self.service.list(**params)
     results = [{
         'id': identity['uuid'],
         'text': identity['username']
     } for identity in identities['items']]
     return jsonify(
         build_select2_response(results, identities['total'], params))
Esempio n. 9
0
 def list_json(self):
     params = extract_select2_params(request.args)
     plugins = self.service.list_installed(**params)
     results = [{'id': plugin['id'], 'text': plugin['id']} for plugin in plugins['items']]
     results = sorted(results, key=lambda value: value['id'])
     offset = params['offset']
     limit = params['limit']
     results = results[offset:offset + limit]
     return jsonify(build_select2_response(results, plugins['total'], params))
Esempio n. 10
0
 def list_json(self):
     params = extract_select2_params(request.args)
     devices = self.service.list(**params)
     results = [{
         'id': device['id'],
         'text': device['mac']
     } for device in devices['items']]
     return jsonify(
         build_select2_response(results, devices['total'], params))
Esempio n. 11
0
 def list_json(self):
     params = extract_select2_params(request.args)
     callpermissions = self.service.list(**params)
     results = [{
         'id': callpermission['id'],
         'text': callpermission['name']
     } for callpermission in callpermissions['items']]
     return jsonify(
         build_select2_response(results, callpermissions['total'], params))
Esempio n. 12
0
 def list_json(self):
     params = extract_select2_params(request.args)
     musiconhold = self.service.list(**params)
     results = [{
         'id': moh['name'],
         'text': moh['name']
     } for moh in musiconhold['items']]
     return jsonify(
         build_select2_response(results, musiconhold['total'], params))
Esempio n. 13
0
 def list_json(self):
     params = extract_select2_params(request.args)
     tenants = self.service.list(**params)
     results = [{
         'id': tenant['uuid'],
         'text': tenant['name']
     } for tenant in tenants['items']]
     return jsonify(
         build_select2_response(results, tenants['total'], params))
Esempio n. 14
0
 def list_json(self):
     params = extract_select2_params(request.args)
     groups = self.service.list(**params)
     results = [{
         'id': group['uuid'],
         'text': group['name']
     } for group in groups['items']]
     return jsonify(build_select2_response(results, groups['total'],
                                           params))
Esempio n. 15
0
 def list_json(self):
     params = extract_select2_params(request.args)
     schedules = self.service.list(**params)
     results = [{
         'id': schedule['id'],
         'text': schedule['name']
     } for schedule in schedules['items']]
     return jsonify(
         build_select2_response(results, schedules['total'], params))
Esempio n. 16
0
 def list_json(self):
     params = extract_select2_params(request.args)
     agents = self.service.list(**params)
     results = [{
         'id': agent['id'],
         'text': agent['number']
     } for agent in agents['items']]
     return jsonify(build_select2_response(results, agents['total'],
                                           params))
Esempio n. 17
0
 def list_json(self):
     params = extract_select2_params(request.args)
     outcalls = self.service.list(**params)
     results = [{
         'id': outcall['id'],
         'text': outcall['name']
     } for outcall in outcalls['items']]
     return jsonify(
         build_select2_response(results, outcalls['total'], params))
Esempio n. 18
0
    def _list_json(self, field_id):
        params = extract_select2_params(request.args)
        conferences = self.service.list(**params)
        results = []
        for conference in conferences['items']:
            text = '{}'.format(conference['name'])
            results.append({'id': conference[field_id], 'text': text})

        return jsonify(
            build_select2_response(results, conferences['total'], params))
Esempio n. 19
0
 def list_json(self):
     params = extract_select2_params(request.args)
     timezones = self.service.list_timezones()['items']
     term = params.get('search') or ''
     results = []
     for tz in timezones:
         if term and term.lower() not in tz['zone_name'].lower():
             continue
         results.append({'id': tz['zone_name'], 'text': tz['zone_name']})
     params['limit'] = len(results)  # avoid pagination
     return jsonify(build_select2_response(results, len(results), params))
Esempio n. 20
0
 def list_json(self):
     params = extract_select2_params(request.args)
     callfilters = self.service.list(**params)
     results = [{
         'id': user['member_id'],
         'text': '{}{}'.format(
             user['firstname'],
             ' {}'.format(user['lastname'] if user['lastname'] else ''),
         ),
     } for callfilter in callfilters['items'] for user in callfilter['surrogates']['users']]
     return jsonify(build_select2_response(results, callfilters['total'], params))
Esempio n. 21
0
    def list_json(self):
        params = extract_select2_params(request.args)
        applications = self.service.list()
        results = []
        for application in applications['items']:
            results.append({
                'id': application['uuid'],
                'text': application['name']
            })

        return jsonify(
            build_select2_response(results, applications['total'], params))
Esempio n. 22
0
    def _list_json(self, type_=None, numeric_id=False):
        params = extract_select2_params(request.args)
        if type_:
            params['type'] = type_
        contexts = self.service.list(**params)

        results = []
        for context in contexts['items']:
            context_id = context['id'] if numeric_id else context['name']
            results.append({'id': context_id, 'text': context['label']})

        return jsonify(
            build_select2_response(results, contexts['total'], params))
Esempio n. 23
0
    def _list_json(self, field_id):
        params = extract_select2_params(request.args)
        users = self.service.list(**params)
        results = []
        for user in users['items']:
            if user.get('lastname'):
                text = '{} {}'.format(user['firstname'], user['lastname'])
            else:
                text = user['firstname']

            results.append({'id': user[field_id], 'text': text})

        return jsonify(build_select2_response(results, users['total'], params))
Esempio n. 24
0
    def _list_json(self, type_=None, numeric_id=False):
        params = extract_select2_params(request.args)
        if type_:
            params['type'] = type_
        access_features = self.service.list(**params)

        results = []
        for access_feature in access_features['items']:
            access_feature_id = (access_feature['id']
                                 if numeric_id else access_feature['name'])
            results.append({
                'id': access_feature_id,
                'text': access_feature['label']
            })

        return jsonify(
            build_select2_response(results, access_features['total'], params))
Esempio n. 25
0
 def list_json(self):
     params = extract_select2_params(request.args)
     lines = self.service.list(**params)
     results = self._populate_list(lines['items'])
     return jsonify(build_select2_response(results, lines['total'], params))
Esempio n. 26
0
 def list_json_by_section(self, section):
     params = extract_select2_params(request.args)
     doc = self.service.get().get(section, {}).keys()
     with_id = [{'id': key, 'text': key} for key in doc]
     return jsonify(build_select2_response(with_id, len(doc), params))