Exemplo n.º 1
0
def set(request):
    """
    Register Endpoint
    return
        sip - Endpoint onbject
        r - status ( 0 or 1 or 2 )
        domain - Domain Name
        xml_context - Not Found
    """
    p = request.POST
    key_value = name = 'result'
    xml_context = '<result status="not found" />'
    #TODO add caching
    try:
        key_value = p.get('user')
        if p.get('action') == 'sip_auth':
            e = Endpoint.objects.get(uid__exact = p.get('user'), enable=True, sip_profile__name__exact=p.get('sip_profile'))
            if is_app('fsb.tariff'):
                #from fsb.tariff.models import TariffPlan
                tariff = True
            else:
                tariff = False
            return request.Context({'name':name, 'key_value':key_value, 'sip':e, 'tariff':tariff, 'domain':p.get('domain')}).render_response('directory/sip_reg.xml')
        elif p.get('action') == 'message-count':
            e = Endpoint.objects.get(uid = p.get('user'), enable=True)
            if is_app('fsb.tariff'):
                #from fsb.tariff.models import TariffPlan
                tariff = True
            else:
                tariff = False
            return request.Context({'name':name, 'key_value':key_value, 'sip':e, 'tariff':tariff, 'domain':p.get('domain')}).render_response('directory/sip_reg.xml')
        else:
            return request.Context({'name':name, 'key_value':key_value, 'xml_context':xml_context}).render_response('server/fs.xml')
    except Endpoint.DoesNotExist:
        return request.Context({'name':name, 'key_value':key_value, 'xml_context':xml_context}).render_response('server/fs.xml')
Exemplo n.º 2
0
 def testAppcheck(self):
     tr = 0
     if is_app('fsa.core'):
         tr = 1
     self.assertEqual(tr, 1)
     tr = 0
     if is_app('fsadmin.nax'):
         tr = 1
     self.assertEqual(tr, 0)
Exemplo n.º 3
0
def get(request):
    try:
        l.debug("post: %s" % request.POST)
        if request.POST['section'] == "configuration":
            try:
                # TODO добавить загрузку конфигурации lcr.conf
                from fsa.server import views as sv
                if (request.POST.get('key_value') == "event_socket.conf"):
                    l.debug("key_ value %s hostname: %s" % (request.POST.get('key_value'), request.POST.get('hostname')))
                    return sv.get_event_socket(request)
                elif (request.POST['key_value'] == "acl.conf"):
                    from fsa.acl import views as av
                    l.debug("key_ value %s hostname: %s" % (request.POST.get('key_value'), request.POST.get('hostname')))
                    return av.get(request)
                elif (request.POST['key_value'] == "limit.conf"):
                    l.debug("key_ value %s hostname: %s" % (request.POST.get('key_value'), request.POST.get('hostname')))
                    return sv.get_limit(request)
                elif (request.POST['key_value'] == "post_load_modules.conf"):
                    l.debug("key_ value %s hostname: %s" % (request.POST.get('key_value'), request.POST.get('hostname')))
                    return sv.post_modules(request)
                elif (request.POST['key_value'] == "odbc_query.conf"):
                    l.debug("key_ value %s hostname: %s" % (request.POST.get('key_value'), request.POST.get('hostname')))
                    return sv.odbc_query(request)
                elif (request.POST['key_value'] == "post_load_switch.conf"):
                    l.debug("key_ value %s hostname: %s" % (request.POST.get('key_value'), request.POST.get('hostname')))
                    return sv.post_switch(request) 
                elif (request.POST['key_value'] == "sofia.conf"):
                    l.debug("key_ value %s hostname: %s" % (request.POST.get('key_value'), request.POST.get('hostname')))
                    return sv.get_sofia(request)
                elif (request.POST['key_value'] == "nibblebill.conf"):
                    l.debug("key_ value %s hostname: %s" % (request.POST.get('key_value'), request.POST.get('hostname')))
                    from fsb.billing import views as bill
                    return bill.get_conf(request)
                elif (request.POST['key_value'] == "xml_cdr.conf"):
                    from fsa.cdr import views as cv
                    l.debug("key_ value xml_cdr.conf hostname: %s" % request.POST.get('hostname'))
                    return cv.get_xml_conf(request)
                elif is_app('fsa.lcr') and request.POST.get('key_value') == "lcr.conf":
                    l.debug("hostname: %s (lcr.conf)" % request.POST.get('hostname'))
                    from fsa.lcr import views as lv
                    return lv.get_conf(request)
                else:
                    return sv.get(request)
            except Exception, e:
                l.error("Error import module: %s" % e)
    except Exception, e:
        l.error("Error generating confg %s" % e)
        return HttpResponseNotFound('<h1>Error generating config</h1>')