예제 #1
0
    def agent_avail_endpoints(self):
        items = []
        ext = request.params.get('ext', None)
        if ext:
            items.append({'id': 0, 'extension': ext})
        for row in PbxEndpoint.query.filter_by(
                user_context=session['context']).order_by(
                    PbxEndpoint.auth_id).all():
            if CallCenterAgent.query.filter_by(
                    extension=row.auth_id).filter_by(
                        context=session['context']).count() > 0:
                continue

            items.append({'id': row.id, 'extension': row.auth_id})

        out = dict({
            'identifier': 'extension',
            'label': 'extension',
            'items': items
        })
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json; charset=UTF-8'),
        ]

        return response(request.environ, self.start_response)
예제 #2
0
파일: crm.py 프로젝트: Kirembu/FreePyBX
    def account_by_id(self, id):
        items = []
        for account in (
            CrmAccount.query.join(CrmCampaign)
            .filter(CrmAccount.customer_id == session["customer_id"])
            .filter(CrmAccount.user_id == session["user_id"])
            .filter(CrmCampaign.name == id)
            .all()
        ):
            items.append(
                {
                    "id": account.id,
                    "name": str(account.first_name) + " " + str(account.last_name),
                    "address": account.address,
                    "city": account.city,
                    "state": account.state,
                    "zip": account.zip,
                    "tel": account.tel,
                    "mobile": account.mobile,
                    "email": account.email,
                    "crm_campaign_id": account.crm_campaign_id,
                }
            )
        db.remove()

        out = dict({"identifier": "id", "label": "name", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json")]

        return response(request.environ, self.start_response)
예제 #3
0
파일: crm.py 프로젝트: malakhA/FreePyBX
    def campaigns(self):
        items = []
        members = []
        for campaign in CrmCampaign.query.filter(
                context=session['context']).all():
            for member in CrmGroupMember.query.join(CrmGroup).join(
                    CrmCampaignGroup).filter(
                        CrmCampaignGroup.crm_campaign_id == campaign.id).all():
                members.append(member.extension)
            items.append({
                'id': campaign.id,
                'name': campaign.name,
                'members': ",".join(members)
            })
            members = []

        db.remove()

        out = dict({'identifier': 'id', 'label': 'name', 'items': items})
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json'),
        ]

        return response(request.environ, self.start_response)
예제 #4
0
    def ad_audio(self):
        items = []
        dir = fs_vm_dir + session['context'] + "/recordings/"
        try:
            for i in os.listdir(dir):
                fo = generateFileObject(i, "", dir)
                items.append({
                    'id': '1,' + fo["name"],
                    'name': 'Recording: ' + fo["name"],
                    'data': fo["path"],
                    'type': 1,
                    'real_id': ""
                })

            db.remove()
        except:
            pass
        out = dict({'identifier': 'id', 'label': 'name', 'items': items})

        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json; charset=UTF-8'),
        ]

        return response(request.environ, self.start_response)
예제 #5
0
    def ad_audio(self):
        items = []
        dir = fs_vm_dir + session["context"] + "/recordings/"
        try:
            for i in os.listdir(dir):
                fo = generateFileObject(i, "", dir)
                items.append(
                    {
                        "id": "1," + fo["name"],
                        "name": "Recording: " + fo["name"],
                        "data": fo["path"],
                        "type": 1,
                        "real_id": "",
                    }
                )

            db.remove()
        except:
            pass
        out = dict({"identifier": "id", "label": "name", "items": items})

        response = make_response(out)
        response.headers = [("Content-type", "application/json; charset=UTF-8")]

        return response(request.environ, self.start_response)
예제 #6
0
    def get_queue_calls(self):
        log.debug(request.params.get("sid"))
        user = User.query.filter_by(
            session_id=request.params.get("sid")).first()
        if user:
            context = user.get_context()
        else:
            return ""
        items = []
        sql = "SELECT * FROM call_center_callers WHERE queue like '%@{0}'".format(
            context)

        for call in db.execute(sql):
            items.append({
                'queue': call.queue.split("@")[0],
                'cid_name': call.cid_name,
                'cid_number': call.cid_number,
                'agent': call.serving_agent.split("@")[0],
                'state': call.state,
                'uuid': call.uuid
            })

        if not len(items) == 0:
            return ""

        out = items
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json; charset=UTF-8'),
        ]

        return response(request.environ, self.start_response)
예제 #7
0
    def get_queue_calls(self):
        log.debug(request.params.get("sid"))
        user = User.query.filter_by(session_id=request.params.get("sid")).first()
        if user:
            context = user.get_context()
        else:
            return ""
        items = []
        sql = "SELECT * FROM call_center_callers WHERE queue like '%@{0}'".format(context)

        for call in db.execute(sql):
            items.append(
                {
                    "queue": call.queue.split("@")[0],
                    "cid_name": call.cid_name,
                    "cid_number": call.cid_number,
                    "agent": call.serving_agent.split("@")[0],
                    "state": call.state,
                    "uuid": call.uuid,
                }
            )

        if not len(items) == 0:
            return ""

        out = items
        response = make_response(out)
        response.headers = [("Content-type", "application/json; charset=UTF-8")]

        return response(request.environ, self.start_response)
예제 #8
0
    def ccq_by_id(self, id, **kw):
        items = []
        for ccq in CallCenterQueue.query.filter_by(context=session["context"]).filter_by(id=id).all():
            items.append(
                {
                    "id": ccq.id,
                    "name": ccq.name,
                    "audio_type": ccq.audio_type,
                    "audio_name": str(ccq.audio_type) + "," + str(ccq.audio_name),
                    "moh_sound": ccq.moh_sound,
                    "time_base_score": ccq.time_base_score,
                    "max_wait_time": ccq.max_wait_time,
                    "max_wait_time_with_no_agent": ccq.max_wait_time_with_no_agent,
                    "max_wait_time_with_no_agent_reached": ccq.max_wait_time_with_no_agent_reached,
                    "tier_rules_apply": ccq.tier_rules_apply,
                    "tier_rule_wait_second": ccq.tier_rule_wait_second,
                    "tier_rule_wait_multiply_level": ccq.tier_rule_wait_multiply_level,
                    "tier_rule_agent_no_wait": ccq.tier_rule_agent_no_wait,
                    "discard_abandoned_after": ccq.discard_abandoned_after,
                    "abandoned_resume_allowed": ccq.abandoned_resume_allowed,
                    "strategy": ccq.strategy,
                    "failed_route_id": ccq.failed_route_id,
                    "record_calls": ccq.record_calls,
                    "announce_position": ccq.announce_position,
                    "announce_sound": "1," + ccq.announce_sound,
                    "announce_frequency": ccq.announce_frequency,
                }
            )

        out = dict({"identifier": "id", "label": "name", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json; charset=UTF-8")]

        return response(request.environ, self.start_response)
예제 #9
0
파일: pymp.py 프로젝트: JoneXiong/FreePyBX
    def get_folder_list(self, **kw):
        p = Pymap(session['email'], session['email_password'], session['email_server'])
        folders = p.get_folder_list()

        response = make_response(folders)
        response.headers = [("Content-type", 'application/json'),]

        return response(request.environ, self.start_response)
예제 #10
0
    def ccq_by_id(self, id, **kw):
        items = []
        for ccq in CallCenterQueue.query.filter_by(
                context=session['context']).filter_by(id=id).all():
            items.append({
                'id':
                ccq.id,
                'name':
                ccq.name,
                'audio_type':
                ccq.audio_type,
                'audio_name':
                str(ccq.audio_type) + "," + str(ccq.audio_name),
                'moh_sound':
                ccq.moh_sound,
                'time_base_score':
                ccq.time_base_score,
                'max_wait_time':
                ccq.max_wait_time,
                'max_wait_time_with_no_agent':
                ccq.max_wait_time_with_no_agent,
                'max_wait_time_with_no_agent_reached':
                ccq.max_wait_time_with_no_agent_reached,
                'tier_rules_apply':
                ccq.tier_rules_apply,
                'tier_rule_wait_second':
                ccq.tier_rule_wait_second,
                'tier_rule_wait_multiply_level':
                ccq.tier_rule_wait_multiply_level,
                'tier_rule_agent_no_wait':
                ccq.tier_rule_agent_no_wait,
                'discard_abandoned_after':
                ccq.discard_abandoned_after,
                'abandoned_resume_allowed':
                ccq.abandoned_resume_allowed,
                'strategy':
                ccq.strategy,
                'failed_route_id':
                ccq.failed_route_id,
                'record_calls':
                ccq.record_calls,
                'announce_position':
                ccq.announce_position,
                'announce_sound':
                "1," + ccq.announce_sound,
                'announce_frequency':
                ccq.announce_frequency
            })

        out = dict({'identifier': 'id', 'label': 'name', 'items': items})
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json; charset=UTF-8'),
        ]

        return response(request.environ, self.start_response)
예제 #11
0
    def agent_endpoints(self):
        items = []
        for row in PbxEndpoint.query.filter_by(user_context=session["context"]).order_by(PbxEndpoint.auth_id).all():
            items.append({"id": row.id, "extension": row.auth_id})

        out = dict({"identifier": "extension", "label": "extension", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json; charset=UTF-8")]

        return response(request.environ, self.start_response)
예제 #12
0
    def agents(self):
        items = []
        for agent in CallCenterAgent.query.filter_by(context=session["context"]).all():
            items.append({"id": agent.id, "extension": agent.extension, "status": agent.status})

        out = dict({"identifier": "extension", "label": "extension", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json; charset=UTF-8")]

        return response(request.environ, self.start_response)
예제 #13
0
    def queues(self):
        items = []
        for queue in CallCenterQueue.query.filter_by(context=session["context"]).all():
            items.append({"id": queue.id, "name": queue.name})

        out = dict({"identifier": "name", "label": "name", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json; charset=UTF-8")]

        return response(request.environ, self.start_response)
예제 #14
0
파일: crm.py 프로젝트: Kirembu/FreePyBX
    def account_lead_types(self):
        items = []
        for act in CrmLeadType.query.filter(context=session["context"]).all():
            items.append({"id": act.id, "name": act.name, "desc": act.description})
        db.remove()

        out = dict({"identifier": "id", "label": "name", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json")]

        return response(request.environ, self.start_response)
예제 #15
0
    def get_folder_list(self, **kw):
        p = Pymap(session['email'], session['email_password'],
                  session['email_server'])
        folders = p.get_folder_list()

        response = make_response(folders)
        response.headers = [
            ("Content-type", 'application/json'),
        ]

        return response(request.environ, self.start_response)
예제 #16
0
    def billing_service_types(self):
        items=[]
        for bs in BillingServiceType.query.all():
            items.append({'id': bs.id, 'name': bs.name, 'description': bs.description})

        db.remove()

        out = dict({'identifier': 'id', 'label': 'name', 'items': items})
        response = make_response(out)
        response.headers = [("Content-type", 'application/json'),]

        return response(request.environ, self.start_response)
예제 #17
0
파일: crm.py 프로젝트: Kirembu/FreePyBX
    def campaigns_ids(self):
        names = []
        ids = []
        for row in CrmCampaign.query.filter(context=session["context"]).all():
            names.append(row.name)
            ids.append(row.id)
        db.remove()
        headers = [("Content-type", "application/json")]
        out = dict({"names": names, "ids": ids})
        response = make_response(out)

        return response(request.environ, self.start_response)
예제 #18
0
파일: crm.py 프로젝트: xuhai008/FreePyBX
    def accounts(self):
        items=[]
        try:
            for account in CrmAccount.query.filter(customer_id=session['customer_id']).filter(user_id=session['user_id']).all():
                items.append({'id': account.id, 'name': str(account.first_name)+" "+str(account.last_name), 'address': account.address, \
                              'city': account.city, 'state': account.state, 'zip': account.zip, 'tel': account.tel, 'mobile': account.mobile, \
                              'email': account.email, 'crm_campaign_id': account.crm_campaign_id})

            return response(request.environ, self.start_response)

        except Exception, e:
            return {'identifier': 'id', 'label': 'name', 'items': items}
예제 #19
0
    def queues(self):
        items = []
        for queue in CallCenterQueue.query.filter_by(
                context=session['context']).all():
            items.append({'id': queue.id, 'name': queue.name})

        out = dict({'identifier': 'name', 'label': 'name', 'items': items})
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json; charset=UTF-8'),
        ]

        return response(request.environ, self.start_response)
예제 #20
0
파일: crm.py 프로젝트: malakhA/FreePyBX
    def campaigns_ids(self):
        names = []
        ids = []
        for row in CrmCampaign.query.filter(context=session['context']).all():
            names.append(row.name)
            ids.append(row.id)
        db.remove()
        headers = [
            ("Content-type", 'application/json'),
        ]
        out = dict({'names': names, 'ids': ids})
        response = make_response(out)

        return response(request.environ, self.start_response)
예제 #21
0
파일: pymp.py 프로젝트: JoneXiong/FreePyBX
    def get_all_message_headers(self, folder='INBOX', **kw):

        p = Pymap(session['email'], session['email_password'], session['email_server'])
        f = p.get_folder_list()
        message_headers = {}

        for folder in f['items']:
            tmp = p.get_message_headers(folder)
            x = tmp.copy()
            message_headers.update(x)

        response = make_response(message_headers)
        response.headers = [("Content-type", 'application/json'),]

        return response(request.environ, self.start_response)
예제 #22
0
    def agent_avail_endpoints(self):
        items = []
        ext = request.params.get("ext", None)
        if ext:
            items.append({"id": 0, "extension": ext})
        for row in PbxEndpoint.query.filter_by(user_context=session["context"]).order_by(PbxEndpoint.auth_id).all():
            if CallCenterAgent.query.filter_by(extension=row.auth_id).filter_by(context=session["context"]).count() > 0:
                continue

            items.append({"id": row.id, "extension": row.auth_id})

        out = dict({"identifier": "extension", "label": "extension", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json; charset=UTF-8")]

        return response(request.environ, self.start_response)
예제 #23
0
파일: crm.py 프로젝트: malakhA/FreePyBX
    def account_by_id(self, id):
        items = []
        for account in CrmAccount.query.join(CrmCampaign).filter(CrmAccount.customer_id==session['customer_id'])\
                    .filter(CrmAccount.user_id==session['user_id']).filter(CrmCampaign.name==id).all():
            items.append({'id': account.id, 'name': str(account.first_name)+" "+str(account.last_name), 'address': account.address, \
                          'city': account.city, 'state': account.state, 'zip': account.zip, 'tel': account.tel, 'mobile': account.mobile, \
                          'email': account.email, 'crm_campaign_id': account.crm_campaign_id})
        db.remove()

        out = dict({'identifier': 'id', 'label': 'name', 'items': items})
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json'),
        ]

        return response(request.environ, self.start_response)
예제 #24
0
파일: crm.py 프로젝트: malakhA/FreePyBX
    def account_lead_types(self):
        items = []
        for act in CrmLeadType.query.filter(context=session['context']).all():
            items.append({
                'id': act.id,
                'name': act.name,
                'desc': act.description
            })
        db.remove()

        out = dict({'identifier': 'id', 'label': 'name', 'items': items})
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json'),
        ]

        return response(request.environ, self.start_response)
예제 #25
0
파일: pymp.py 프로젝트: JoneXiong/FreePyBX
    def contacts(self, **kw):
        items = []
        id=1
        log.debug(id)
        rows = meta.db.query(Contact).filter_by(user_id=id).all()

        if rows:
            for row in rows:
                items.append({'id': row.id, 'first_name': row.first_name,  \
                          'last_name': row.last_name, 'email': row.email})

        out = dict({'identifier': 'id', 'label': 'email', 'items': items})

        response = make_response(out)
        response.headers = [("Content-type", 'application/json'),]

        return response(request.environ, self.start_response)
예제 #26
0
파일: crm.py 프로젝트: Kirembu/FreePyBX
    def account_notes_by_id(self, id, **kw):
        items = []
        for note in CrmNote.query.filter(CrmNote.crm_account_id == id).all():
            items.append(
                {
                    "id": note.id,
                    "created": note.created.strftime("%m/%d/%Y %I:%M:%S %p"),
                    "note": note.note,
                    "crm_account_id": note.crm_account_id,
                }
            )
        db.remove()

        out = dict({"identifier": "id", "label": "name", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json")]

        return response(request.environ, self.start_response)
예제 #27
0
    def get_all_message_headers(self, folder='INBOX', **kw):

        p = Pymap(session['email'], session['email_password'],
                  session['email_server'])
        f = p.get_folder_list()
        message_headers = {}

        for folder in f['items']:
            tmp = p.get_message_headers(folder)
            x = tmp.copy()
            message_headers.update(x)

        response = make_response(message_headers)
        response.headers = [
            ("Content-type", 'application/json'),
        ]

        return response(request.environ, self.start_response)
예제 #28
0
파일: pymp.py 프로젝트: JoneXiong/FreePyBX
    def get_attachment(self, uid=0, folder="INBOX", filename=None):

        p = Pymap(session['email'], session['email_password'], session['email_server'])
        msg = p.get_message(uid, folder)
        data = PymapMime(msg)
        message = data.parse_message()
        content_type = None
        out = ""

        for att in message['attachments']:
            if att.name==filename:
                out += str(att.data)
                content_type=att.content_type

        response = make_response(out, content_type)
        response.headers = [("Content-type", content_type),]

        return response(request.environ, self.start_response)
예제 #29
0
    def agent_endpoints(self):
        items = []
        for row in PbxEndpoint.query.filter_by(
                user_context=session['context']).order_by(
                    PbxEndpoint.auth_id).all():
            items.append({'id': row.id, 'extension': row.auth_id})

        out = dict({
            'identifier': 'extension',
            'label': 'extension',
            'items': items
        })
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json; charset=UTF-8'),
        ]

        return response(request.environ, self.start_response)
예제 #30
0
    def billing_service_types(self):
        items = []
        for bs in BillingServiceType.query.all():
            items.append({
                'id': bs.id,
                'name': bs.name,
                'description': bs.description
            })

        db.remove()

        out = dict({'identifier': 'id', 'label': 'name', 'items': items})
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json'),
        ]

        return response(request.environ, self.start_response)
예제 #31
0
    def contacts(self, **kw):
        items = []
        id = 1
        log.debug(id)
        rows = meta.db.query(Contact).filter_by(user_id=id).all()

        if rows:
            for row in rows:
                items.append({'id': row.id, 'first_name': row.first_name,  \
                          'last_name': row.last_name, 'email': row.email})

        out = dict({'identifier': 'id', 'label': 'email', 'items': items})

        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json'),
        ]

        return response(request.environ, self.start_response)
예제 #32
0
    def get_queue_recordings(self):
        files = []
        queue = request.params.get("queue_name")

        dir = fs_vm_dir + session['context'] + "/queue-recordings/" + queue
        for i in os.listdir(dir):
            path = dir + "/" + i
            id = i.split(".")[3].strip()
            row = PbxCdr.query.filter(PbxCdr.uuid == id).first()
            if row:
                caller = row.caller_id_number[len(row.caller_id_number) - 10:]
                dest = row.destination_number
                agent = PbxCdr.query.filter(
                    PbxCdr.uuid == row.bleg_uuid).first()
                agent_ext = agent.destination_number
            else:
                agent_ext = "No CDR"
                dest = "No CDR"
                caller = "No CDR"

            tpath = "/vm/" + session[
                'context'] + "/queue-recordings/" + queue + "/" + i
            received = str(modification_date(path)).strip("\"")
            fsize = str(os.path.getsize(path))

            files.append({
                'name': caller,
                'queue': queue,
                'destination': dest,
                'agent': agent_ext,
                'path': tpath,
                'received': received,
                'size': fsize
            })

        db.remove()
        out = dict({'identifier': 'path', 'label': 'name', 'items': files})
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json; charset=UTF-8'),
        ]

        return response(request.environ, self.start_response)
예제 #33
0
파일: crm.py 프로젝트: malakhA/FreePyBX
    def account_by_id(self, id, **kw):
        items = []
        for crm in CrmAccount.query.filter(
                CrmAccount.customer_id == session['customer_id']).filter(
                    CrmAccount.id == id).all():
            items.append({'id': crm.id, 'first_name': crm.first_name, 'last_name': crm.last_name, 'address': crm.address, 'address_2': crm.address_2,\
                          'city': crm.city, 'state': crm.state, 'zip': crm.zip, 'title': crm.title, 'tel': crm.tel, 'mobile': crm.mobile,\
                          'tel_ext': crm.tel_ext, 'customer': crm.customer, 'email': crm.email, 'url': crm.url, 'crm_account_status_type_id': crm.crm_account_status_type_id,\
                          'crm_lead_type_id': crm.crm_lead_type_id, 'crm_campaign_id': crm.crm_campaign_id, 'created': crm.created.strftime("%m/%d/%Y %I:%M:%S %p"),\
                          'last_modified': crm.last_modified.strftime("%m/%d/%Y %I:%M:%S %p"), 'active': crm.active})
        db.remove()

        out = dict({'identifier': 'id', 'label': 'name', 'items': items})
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json'),
        ]

        return response(request.environ, self.start_response)
예제 #34
0
    def get_queue_recordings(self):
        files = []
        queue = request.params.get("queue_name")

        dir = fs_vm_dir + session["context"] + "/queue-recordings/" + queue
        for i in os.listdir(dir):
            path = dir + "/" + i
            id = i.split(".")[3].strip()
            row = PbxCdr.query.filter(PbxCdr.uuid == id).first()
            if row:
                caller = row.caller_id_number[len(row.caller_id_number) - 10 :]
                dest = row.destination_number
                agent = PbxCdr.query.filter(PbxCdr.uuid == row.bleg_uuid).first()
                agent_ext = agent.destination_number
            else:
                agent_ext = "No CDR"
                dest = "No CDR"
                caller = "No CDR"

            tpath = "/vm/" + session["context"] + "/queue-recordings/" + queue + "/" + i
            received = str(modification_date(path)).strip('"')
            fsize = str(os.path.getsize(path))

            files.append(
                {
                    "name": caller,
                    "queue": queue,
                    "destination": dest,
                    "agent": agent_ext,
                    "path": tpath,
                    "received": received,
                    "size": fsize,
                }
            )

        db.remove()
        out = dict({"identifier": "path", "label": "name", "items": files})
        response = make_response(out)
        response.headers = [("Content-type", "application/json; charset=UTF-8")]

        return response(request.environ, self.start_response)
예제 #35
0
    def agents(self):
        items = []
        for agent in CallCenterAgent.query.filter_by(
                context=session['context']).all():
            items.append({
                'id': agent.id,
                'extension': agent.extension,
                'status': agent.status
            })

        out = dict({
            'identifier': 'extension',
            'label': 'extension',
            'items': items
        })
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json; charset=UTF-8'),
        ]

        return response(request.environ, self.start_response)
예제 #36
0
파일: crm.py 프로젝트: Kirembu/FreePyBX
    def campaigns(self):
        items = []
        members = []
        for campaign in CrmCampaign.query.filter(context=session["context"]).all():
            for member in (
                CrmGroupMember.query.join(CrmGroup)
                .join(CrmCampaignGroup)
                .filter(CrmCampaignGroup.crm_campaign_id == campaign.id)
                .all()
            ):
                members.append(member.extension)
            items.append({"id": campaign.id, "name": campaign.name, "members": ",".join(members)})
            members = []

        db.remove()

        out = dict({"identifier": "id", "label": "name", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json")]

        return response(request.environ, self.start_response)
예제 #37
0
    def get_attachment(self, uid=0, folder="INBOX", filename=None):

        p = Pymap(session['email'], session['email_password'],
                  session['email_server'])
        msg = p.get_message(uid, folder)
        data = PymapMime(msg)
        message = data.parse_message()
        content_type = None
        out = ""

        for att in message['attachments']:
            if att.name == filename:
                out += str(att.data)
                content_type = att.content_type

        response = make_response(out, content_type)
        response.headers = [
            ("Content-type", content_type),
        ]

        return response(request.environ, self.start_response)
예제 #38
0
파일: crm.py 프로젝트: malakhA/FreePyBX
    def account_notes_by_id(self, id, **kw):
        items = []
        for note in CrmNote.query.filter(CrmNote.crm_account_id == id).all():
            items.append({
                'id':
                note.id,
                'created':
                note.created.strftime("%m/%d/%Y %I:%M:%S %p"),
                'note':
                note.note,
                'crm_account_id':
                note.crm_account_id
            })
        db.remove()

        out = dict({'identifier': 'id', 'label': 'name', 'items': items})
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json'),
        ]

        return response(request.environ, self.start_response)
예제 #39
0
    def cca_by_id(self, id, **kw):
        items = []
        for cca in CallCenterAgent.query.filter_by(context=session["context"]).filter_by(id=id).all():
            items.append(
                {
                    "id": cca.id,
                    "extension": cca.extension,
                    "type": cca.type,
                    "timeout": cca.timeout,
                    "max_no_answer": cca.max_no_answer,
                    "wrap_up_time": cca.wrap_up_time,
                    "reject_delay_time": cca.reject_delay_time,
                    "busy_delay_time": cca.busy_delay_time,
                    "no_answer_delay_time": cca.no_answer_delay_time,
                    "record_calls": cca.record_calls,
                }
            )

        out = dict({"identifier": "id", "label": "name", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json; charset=UTF-8")]

        return response(request.environ, self.start_response)
예제 #40
0
    def tiers(self):
        items = []

        for tier in CallCenterTier.query.join(CallCenterQueue).filter(
                CallCenterQueue.context == session['context']).all():
            agent = get_agent(tier.agent_id)
            queue = get_queue(tier.queue_id)
            items.append({
                'id': tier.id,
                'agent': agent.extension,
                'queue': queue.name,
                'level': tier.level,
                'position': tier.position,
                'state': tier.state
            })

        out = dict({'identifier': 'id', 'label': 'agent', 'items': items})
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json; charset=UTF-8'),
        ]

        return response(request.environ, self.start_response)
예제 #41
0
파일: crm.py 프로젝트: Kirembu/FreePyBX
    def account_by_id(self, id, **kw):
        items = []
        for crm in (
            CrmAccount.query.filter(CrmAccount.customer_id == session["customer_id"]).filter(CrmAccount.id == id).all()
        ):
            items.append(
                {
                    "id": crm.id,
                    "first_name": crm.first_name,
                    "last_name": crm.last_name,
                    "address": crm.address,
                    "address_2": crm.address_2,
                    "city": crm.city,
                    "state": crm.state,
                    "zip": crm.zip,
                    "title": crm.title,
                    "tel": crm.tel,
                    "mobile": crm.mobile,
                    "tel_ext": crm.tel_ext,
                    "customer": crm.customer,
                    "email": crm.email,
                    "url": crm.url,
                    "crm_account_status_type_id": crm.crm_account_status_type_id,
                    "crm_lead_type_id": crm.crm_lead_type_id,
                    "crm_campaign_id": crm.crm_campaign_id,
                    "created": crm.created.strftime("%m/%d/%Y %I:%M:%S %p"),
                    "last_modified": crm.last_modified.strftime("%m/%d/%Y %I:%M:%S %p"),
                    "active": crm.active,
                }
            )
        db.remove()

        out = dict({"identifier": "id", "label": "name", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json")]

        return response(request.environ, self.start_response)
예제 #42
0
    def cca_by_id(self, id, **kw):
        items = []
        for cca in CallCenterAgent.query.filter_by(
                context=session['context']).filter_by(id=id).all():
            items.append({
                'id': cca.id,
                'extension': cca.extension,
                'type': cca.type,
                'timeout': cca.timeout,
                'max_no_answer': cca.max_no_answer,
                'wrap_up_time': cca.wrap_up_time,
                'reject_delay_time': cca.reject_delay_time,
                'busy_delay_time': cca.busy_delay_time,
                'no_answer_delay_time': cca.no_answer_delay_time,
                'record_calls': cca.record_calls
            })

        out = dict({'identifier': 'id', 'label': 'name', 'items': items})
        response = make_response(out)
        response.headers = [
            ("Content-type", 'application/json; charset=UTF-8'),
        ]

        return response(request.environ, self.start_response)
예제 #43
0
    def tiers(self):
        items = []

        for tier in (
            CallCenterTier.query.join(CallCenterQueue).filter(CallCenterQueue.context == session["context"]).all()
        ):
            agent = get_agent(tier.agent_id)
            queue = get_queue(tier.queue_id)
            items.append(
                {
                    "id": tier.id,
                    "agent": agent.extension,
                    "queue": queue.name,
                    "level": tier.level,
                    "position": tier.position,
                    "state": tier.state,
                }
            )

        out = dict({"identifier": "id", "label": "agent", "items": items})
        response = make_response(out)
        response.headers = [("Content-type", "application/json; charset=UTF-8")]

        return response(request.environ, self.start_response)