当前位置: 首页>>代码示例>>Python>>正文


Python Session.add方法代码示例

本文整理汇总了Python中freepybx.model.meta.Session.add方法的典型用法代码示例。如果您正苦于以下问题:Python Session.add方法的具体用法?Python Session.add怎么用?Python Session.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在freepybx.model.meta.Session的用法示例。


在下文中一共展示了Session.add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: edit_crm_account

# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import add [as 别名]
    def edit_crm_account(self, **kw):
        schema = CrmAccountForm()
        try:
            form_result = schema.to_python(request.params)
            ca = CrmAccount.query.filter(id=form_result["id"]).filter(customer_id=session["customer_id"]).first()
            ca.first_name = form_result.get("first_name", "Unknown")
            ca.last_name = form_result.get("last_name", "Unknown")
            ca.customer = form_result.get("customer")
            ca.title = form_result.get("title")
            ca.email = form_result.get("email")
            ca.address = form_result.get("address")
            ca.address_2 = form_result.get("address_2")
            ca.city = form_result.get("city")
            ca.state = form_result.get("state")
            ca.zip = form_result.get("zip")
            ca.tel = form_result.get("tel")
            ca.tel_ext = form_result.get("tel_ext")
            ca.mobile = form_result.get("mobile")
            if request.params.has_key("active"):
                ca.active = True
            else:
                ca.active = False
            ca.customer_id = session["customer_id"]
            ca.user_id = session["user_id"]
            ca.crm_campaign_id = form_result.get("crm_campaign_name")
            ca.crm_account_status_type_id = form_result.get("status_type_name")
            ca.crm_lead_type_id = form_result.get("crm_lead_type_name")

            db.add(ca)
            db.commit()
            db.flush()
        except validators.Invalid, error:
            return "Error: %s" % error
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:35,代码来源:crm.py

示例2: update_campaign_grid

# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import add [as 别名]
    def update_campaign_grid(self, **kw):

        w = loads(urllib.unquote_plus(request.params.get("data")))

        try:
            for i in w["modified"]:
                sg = (
                    CrmCampaignGroup.query.filter(CrmCampaignGroup.crm_campaign_id == i["id"])
                    .filter(CrmCampaignGroup.context == session["context"])
                    .first()
                )
                CrmGroupMember.query.filter(CrmGroupMember.crm_group_id == sg.crm_group_id).delete()

                for gm in i["members"].split(","):
                    if not gm.strip().isdigit():
                        continue
                    sm = CrmGroupMember()
                    sm.crm_group_id = sg.crm_group_id
                    sm.extension = gm.strip()
                    sm.context = session["context"]

                    db.add(sm)
                    db.commit()
                    db.flush()
        except:
            db.remove()
            return "Error updating campaign."

        return "Successfully updated campaign."
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:31,代码来源:crm.py

示例3: add_crm_account_note

# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import add [as 别名]
    def add_crm_account_note(self, **kw):

        try:
            cn = CrmNote()
            cn.note = request.params.get("crm_note")
            cn.crm_account_id = request.params.get("crm_acct_id")
            cn.created = datetime.now()

            db.add(cn)
            db.commit()
            db.flush()

        except validators.Invalid, error:
            db.remove()
            return "Error: %s" % error
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:17,代码来源:crm.py

示例4: register_login

# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import add [as 别名]
    def register_login(class_, username, session, request):
        user = User.query.filter_by(username=username).first()
        if user:
            now = datetime.now()
            user.last_login = now
            user.session_id = session.id
            user.remote_addr = request.environ["HTTP_REMOTE_EU"]
            db.commit()
            db.flush()

            if True:
                s = Shift(session.id, user.id, 1)
                db.add(s)
                db.commit()
                db.flush()
        db.remove()
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:18,代码来源:core.py

示例5: ccq_add

# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import add [as 别名]
    def ccq_add(self):
        schema = QueueForm()
        try:
            form_result = schema.to_python(request.params)
            ccq = CallCenterQueue()
            ccq.name = form_result["name"]
            ccq.context = session["context"]
            ccq.domain = session["context"]
            ccq.audio_type = form_result.get("audio_name").split(",")[0]
            ccq.audio_name = form_result.get("audio_name").split(",")[1]
            ccq.moh_sound = form_result.get("moh_sound", "local_stream://moh")
            ccq.time_base_score = form_result.get("time_base_score", "system")
            ccq.max_wait_time = form_result.get("max_wait_time", 0)
            ccq.max_wait_time_with_no_agent = form_result.get("max_wait_time_with_no_agent", 0)
            ccq.max_wait_time_with_no_agent_reached = form_result.get("max_wait_time_with_no_agent_reached", 5)
            ccq.tier_rules_apply = form_result.get("tier_rules_apply", False)
            ccq.tier_rule_wait_second = form_result.get("tier_rule_wait_second", 300)
            ccq.tier_rule_wait_multiply_level = form_result.get("tier_rule_wait_multiply_level", False)
            ccq.tier_rule_agent_no_wait = form_result.get("tier_rule_agent_no_wait", False)
            ccq.discard_abandoned_after = form_result.get("discard_abandoned_after", 1800)
            ccq.abandoned_resume_allowed = form_result.get("abandoned_resume_allowed", False)
            ccq.strategy = form_result.get("strategy", "callback")
            ccq.failed_route_id = form_result.get("failed_route_id", 0)
            ccq.record_calls = form_result.get("record_calls", False)
            ccq.announce_position = form_result.get("announce_position", False)
            ccq.announce_sound = form_result.get("announce_sound").split(",")[1]
            ccq.announce_frequency = form_result.get("announce_frequency")

            db.add(ccq)
            db.commit()
            db.flush()

            dir = fs_vm_dir + session["context"] + "/queue-recordings/" + ccq.name

            if not os.path.exists(dir):
                os.makedirs(dir)

        except validators.Invalid, error:
            db.remove()
            return "Error: %s." % error
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:42,代码来源:call_center.py

示例6: tier_add

# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import add [as 别名]
    def tier_add(self):
        schema = TierForm()
        try:
            form_result = schema.to_python(request.params)

            log.debug("######################" + form_result.get("queue_name"))

            cca = (
                CallCenterAgent.query.filter_by(extension=form_result.get("agent_extension", None))
                .filter_by(context=session["context"])
                .first()
            )
            cur_cct = CallCenterTier.query.filter_by(agent=cca.name).first()
            ccq = CallCenterQueue.query.filter_by(name=form_result.get("queue_name", None)).first()

            if cur_cct:
                return "Agent in tier already exists!"

            cct = CallCenterTier()

            cct.extension = cca.extension
            cct.queue_id = ccq.id
            cct.agent_id = cca.id
            cct.queue = str(ccq.name) + "@" + session["context"]
            cct.agent = str(cca.extension) + "@" + session["context"]
            cct.level = form_result.get("level", 1)
            cct.state = "Ready"
            cct.position = form_result.get("position", 1)
            cct.context = session["context"]
            cct.domain = session["context"]

            db.add(cct)
            db.commit()
            db.flush()

        except validators.Invalid, error:
            db.remove()
            return "Error: %s." % error
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:40,代码来源:call_center.py

示例7: agent_add

# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import add [as 别名]
    def agent_add(self):
        schema = AgentForm()
        try:
            form_result = schema.to_python(request.params)
            cca = CallCenterAgent()
            cca.extension = form_result.get("extension")
            e = (
                PbxEndpoint.query.filter_by(user_context=session["context"])
                .filter(PbxEndpoint.auth_id == cca.extension)
                .first()
            )
            cca.context = session["context"]
            cca.domain = session["context"]
            cca.type = "callback"
            cca.system = "single_box"
            cca.name = cca.extension + "@" + session["context"]
            cca.timeout = form_result.get("timeout", 30)
            cca.contact = "[call_timeout=" + cca.timeout + "]user/" + cca.name
            cca.max_no_answer = form_result.get("max_no_answer", 3)
            cca.wrap_up_time = form_result.get("wrap_up_time", 30)
            cca.reject_delay_time = form_result.get("reject_delay_time", 30)
            cca.busy_delay_time = form_result.get("busy_delay_time", 0)
            cca.no_answer_delay_time = form_result.get("no_answer_delay_time", 5)
            cca.record_calls = form_result.get("record_calls", 0)
            cca.status = "Available"
            cca.state = "Waiting"
            cca.user_id = e.user_id
            cca.pbx_endpoint_id = e.id

            db.add(cca)
            db.commit()
            db.flush()

        except validators.Invalid, error:
            db.remove()
            return "Error: %s." % error
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:38,代码来源:call_center.py

示例8: campaign_add

# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import add [as 别名]
    def campaign_add(self, **kw):
        schema = CrmCampaignForm()
        try:
            form_result = schema.to_python(request.params)
            cc = CrmCampaign()
            cc.name = form_result.get("campaign_name")
            cc.context = session["context"]

            db.add(cc)
            db.commit()
            db.flush()

            cg = CrmGroup()
            cg.name = form_result.get("campaign_name")
            db.add(cg)
            db.commit()
            db.flush()

            ccg = CrmCampaignGroup()
            ccg.name = form_result.get("campaign_name")
            ccg.crm_group_id = cg.id
            ccg.crm_campaign_id = cc.id
            ccg.context = session["context"]
            db.add(ccg)
            db.commit()
            db.flush()

            for i in form_result.get("campaign_extensions").split(","):
                if not i.isdigit():
                    continue
                gm = CrmGroupMember()
                gm.crm_group_id = cg.id
                gm.context = session["context"]
                gm.extension = i

                db.add(gm)
                db.commit()
                db.flush()

        except validators.Invalid, error:
            db.remove()
            return "Error: %s" % error
开发者ID:Kirembu,项目名称:FreePyBX,代码行数:44,代码来源:crm.py


注:本文中的freepybx.model.meta.Session.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。