Esempio n. 1
0
def answered_bridge():
    From = request.POST['From']
    to = request.POST['To']
    r = plivohelper.Response()
    g = r.addDial()
    g.addNumber(From, gateways="user/,user/")
    return jinja2_template('response_template.xml', response=r)
Esempio n. 2
0
def homepage():
    from mocrud.admin import admin
    return jinja2_template('admin/model_grup.html',
        panels=admin.get_panels(),
        model_grup = 'default',
        model_admins=admin.get_grup_admins('default'),
        **admin.template_helper.get_helper_context()
    )
Esempio n. 3
0
def homepage():
    from mocrud.admin import admin
    return jinja2_template('admin/model_grup.html',
#            model_admins=self.get_model_admins(),
        panels=admin.get_panels(),
        model_grup = 'crud_example',
        model_admins=admin.get_grup_admins('crud_example'),
        **admin.template_helper.get_model_admins()
    )
Esempio n. 4
0
def ivr_menus(fs_conf_path):
    u'''
    ivr_menus
    '''
    menus = funcs_models.Autoattendant.objects.all()
    m_data = jinja2_template('ivr_menus.xml',
                             template_lookup=[tpl_path],
                             menus=menus)
    m_file = os.path.join(fs_conf_path, 'ivr_menus', 'oe_ivr.xml')
    f = open(m_file, 'w+')
    f.write(m_data)
    f.close()
Esempio n. 5
0
def autoload_locations(fs_conf_path):
    u'''
    autoload_locations
    '''
    locations = base_models.Location.objects.all()
    m_data = jinja2_template('autoload_configs_locations.xml',
                             template_lookup=[tpl_path],
                             locations=locations)
    m_file = os.path.join(fs_conf_path, 'autoload_configs', 'oe_locations.xml')
    f = open(m_file, 'w+')
    f.write(m_data)
    f.close()
Esempio n. 6
0
def autoload_acl(fs_conf_path):
    u'''
    autoload_acl
    '''
    netlist = base_models.Netlist.objects.all()
    m_data = jinja2_template('autoload_configs_acl.xml',
                             template_lookup=[tpl_path],
                             netlist=netlist)
    m_file = os.path.join(fs_conf_path, 'autoload_configs', 'oe_acl.xml')
    f = open(m_file, 'w+')
    f.write(m_data)
    f.close()
Esempio n. 7
0
def autoload_conferences(fs_conf_path):
    u'''
    autoload_locations
    '''
    conferences = funcs_models.Conference.objects.all()
    m_data = jinja2_template('autoload_configs_conference.xml',
                             template_lookup=[tpl_path],
                             conferences=conferences)
    m_file = os.path.join(fs_conf_path, 'autoload_configs',
                          'oe_conferences.xml')
    f = open(m_file, 'w+')
    f.write(m_data)
    f.close()
Esempio n. 8
0
def sip_profiles(fs_conf_path):
    u'''
    sip_profiles
    '''
    profiles = base_models.SipInterface.objects.all()
    m_data = jinja2_template('sip_profiles.xml',
                             template_lookup=[tpl_path],
                             profiles=profiles,
                             odbc_credentials=odbc_credentials)
    m_file = os.path.join(fs_conf_path, 'sip_profiles', 'oe_profiles.xml')
    f = open(m_file, 'w+')
    f.write(m_data)
    f.close()
Esempio n. 9
0
def directory(fs_conf_path):
    u'''
    directory
    '''
    locations = base_models.Location.objects.all()
    voicemails = funcs_models.VoiceMail.objects.all()
    m_data = jinja2_template('directory.xml',
                             template_lookup=[tpl_path],
                             locations=locations,
                             voicemails=voicemails)
    m_file = os.path.join(fs_conf_path, 'directory', 'oe_directory.xml')
    f = open(m_file, 'w+')
    f.write(m_data)
    f.close()
Esempio n. 10
0
def phonemenu():
    u'''
    公司主菜单url
    '''
    # Default destination
    destination = 'default'
    # Get destination from url query string:
    # 'node' : destination
    # 'Digits' : input digits from user
    
    again_dest = request.args.get('again_dest', None)
    last_dest = request.args.get('last_dest', None)
    print '>>>>>>>>>>>',again_dest,last_dest
    
    if request.method == 'POST':
        node = request.args.get('node', None)
        dtmf = request.form.get('Digits', -1)
    else:
        node = request.args.get('node', None)
        dtmf = request.args.get('Digits', -1)
    if not node:
        node = 'default'
        
    if dtmf=='9':
        destination = "last"
    elif dtmf=='*':
        destination = "again"
    else:
        try:
            digits = int(dtmf)
        except ValueError:
            digits = -1
    
        if digits >= 0:
            try:
                destination = web[node][digits]
            except (KeyError, IndexError):
                destination = 'default'
        else:
            destination = node

    print "Destination %s" % str(destination)
    print "Digits %s" % str(dtmf)

    r = plivohelper.Response()
    #商业服务
    if destination == 'hours':
        r.addPlay( get_ggtts_url("平时,早上九点到下午五点") )
        r.addPlay( get_ggtts_url("周末,早上十点到下午三点") )
    #二级菜单
    elif destination == 'location':
        g = r.addGetDigits(numDigits=1, retries=3, timeout=10,
                   action='http://127.0.0.1:5000/phonemenu/?node=location')
        g.addPlay( get_ggtts_url("请选择水果") )
        g.addPlay( get_ggtts_url("西瓜,请按 1") )
        g.addPlay( get_ggtts_url("苹果,请按 2") )
        do_end(r,again_dest=destination, last_dest="default")
    elif destination == 'east-bay':
        r.addPlay( get_ggtts_url("西瓜堪称“瓜中之王”,原产于非洲。引入新疆是在唐代,五代时期引入中土") )
        r.addPlay( get_ggtts_url("西瓜中含有大量的水分,是一种可以滋身补体的食物和饮料") )
        do_end(r,again_dest=destination, last_dest="location")
    elif destination == 'san-jose':
        r.addPlay( get_ggtts_url("苹果,植物类水果,多次花果,具有丰富营养成分,有食疗、辅助治疗功能。") )
        do_end(r,again_dest=destination, last_dest="location")
    elif destination == 'duck':
        r.addPlay("http://yinyueshiting.baidu.com/data2/music/121524984/12152327672000128.mp3?xcode=73e5bdc48a52628b8bdc37595b2538486f8d94595cf48717")

    elif destination == 'receptionist':
        r.addPlay( get_ggtts_url("正在转接中,请稍等。"))
        g = r.addDial()
        g.addNumber("1002", gateways="user/,user/")
    elif destination == 'again':
        re = r.addRedirect("http://127.0.0.1:5000/phonemenu/?node=%s"%again_dest)
    elif destination == 'last':
        re = r.addRedirect("http://127.0.0.1:5000/phonemenu/?node=%s"%last_dest)
    else:
        # default menu
        g = r.addGetDigits(numDigits=1, timeout=10,
                           action='http://127.0.0.1:5000/phonemenu/?node=default')
        g.addPlay( get_ggtts_url("您好,欢迎来到捷优科技语音菜单测试") )
        g.addPlay( get_ggtts_url("了解服务时间, 请按 1") )
        g.addPlay( get_ggtts_url("二级菜单测试, 请按 2") )
        g.addPlay( get_ggtts_url("听首音乐, 请按 3") )
        g.addPlay( get_ggtts_url("转接人工服务, 请按 0") )
        
        do_end(r,again_dest=destination, last_dest=destination,with_again =False)


    print "RESTXML Response => %s" % r
    return jinja2_template('response_template.xml', response=r)
Esempio n. 11
0
def dialplan(fs_conf_path):
    u'''
    dialplan
    '''
    contexts = {}
    trunkroutes = base_models.TrunkRoutePattern.objects.all()
    for vm in trunkroutes:
        ct = vm.trunk.sip_interface.context.id
        if not contexts.has_key(ct): contexts[ct] = {}
        if not contexts[ct].has_key("trunkroutes"):
            contexts[ct]["trunkroutes"] = []
        contexts[ct]["trunkroutes"].append(vm)
    timeroutes = funcs_models.TimeRoutes.objects.all()
    for vm in timeroutes:
        ct = vm.number.context.id
        if not contexts.has_key(ct): contexts[ct] = {}
        if not contexts[ct].has_key("timeroutes"):
            contexts[ct]["timeroutes"] = []
        contexts[ct]["timeroutes"].append(vm)
    voicemails = funcs_models.VoiceMail.objects.all()
    for vm in voicemails:
        ct = vm.number.context.id
        if not contexts.has_key(ct): contexts[ct] = {}
        if not contexts[ct].has_key("voicemails"):
            contexts[ct]["voicemails"] = []
        contexts[ct]["voicemails"].append(vm)
    devices = funcs_models.Device.objects.all()
    for vm in devices:
        ct = vm.number.context.id
        if not contexts.has_key(ct): contexts[ct] = {}
        if not contexts[ct].has_key("devices"): contexts[ct]["devices"] = []
        contexts[ct]["devices"].append(vm)
    ringgroups = funcs_models.RingGroup.objects.all()
    for vm in ringgroups:
        ct = vm.number.context.id
        if not contexts.has_key(ct): contexts[ct] = {}
        if not contexts[ct].has_key("ringgroups"):
            contexts[ct]["ringgroups"] = []
        contexts[ct]["ringgroups"].append(vm)
    attendants = funcs_models.Autoattendant.objects.all()
    for vm in attendants:
        ct = vm.number.context.id
        if not contexts.has_key(ct): contexts[ct] = {}
        if not contexts[ct].has_key("attendants"):
            contexts[ct]["attendants"] = []
        contexts[ct]["attendants"].append(vm)
    conferences = funcs_models.Conference.objects.all()
    for vm in conferences:
        ct = vm.number.context.id
        if not contexts.has_key(ct): contexts[ct] = {}
        if not contexts[ct].has_key("conferences"):
            contexts[ct]["conferences"] = []
        contexts[ct]["conferences"].append(vm)
    all_context = base_models.Context.objects.all()
    for vm in all_context:
        ct = vm.id  #vm.number.context.id
        if contexts.has_key(ct):
            contexts[ct]['endtype'] = vm.end_type
            contexts[ct]['tts_string'] = vm.tts_string
            contexts[ct]['media_file'] = vm.media_file

    for context_id in contexts.keys():
        context = contexts[context_id]
        context["id"] = context_id
        m_data = jinja2_template('dialplan.xml',
                                 template_lookup=[tpl_path],
                                 context=context)
        m_file = os.path.join(fs_conf_path, 'dialplan',
                              'oe_context_%s.xml' % context_id)
        f = open(m_file, 'w+')
        f.write(m_data)
        f.close()