Example #1
0
def create_link():
    if request.method == 'POST':
        tenant_id = request.form['tenant_id']
        print('tenant id: ' + tenant_id)
        tenant_name = CMS.getTenant(tenant_id)
        link = CreatePatientLink(tenant_name, tenant_id)
        data = {"link": link}
        response = app.response_class(response=json.dumps(data),
                                      status=200,
                                      mimetype='application/json')
        return response
Example #2
0
def vwr():
    tenant_id = request.args.get('tenant_id', None)
    tenant_name = CMS.getTenant(tenant_id)
    Callback = Extensions.get_settings(current_user.username)
    form = EnterEndpoint()
    form.endpoint.data = Callback
    form.tenant_id.data = tenant_id
    call_id_list = CMS.getCalls(tenant_id)
    calls = len(call_id_list)
    active_call_list = []
    waiting_call_list = []
    active_list = []
    waiting_list = []
    active_dur_list = []
    waiting_dur_list = []
    active_space_list = []
    waiting_space_list = []
    #following only needed for active calls
    uri_list = []
    passcode_list = []
    link_list = []
    owner_list = []
    if calls > 0:
        for call_id in call_id_list:
            participant_name, participant_id, activator_name = CMS.getParticipants(
                call_id)
            duration_mins, coSpace_id = CMS.getCallDetails(call_id)
            link, callId, ownerJid = CMS.getCoSpaceDetails(coSpace_id)
            access_method_id = CMS.getAccessMethod(coSpace_id)
            uri, passcode, link = CMS.getAccessMethodDetails(
                coSpace_id, access_method_id)
            main_link, drop_link = link.split("/invited")
            if len(ownerJid) > 0:
                active_list.append(participant_name)
                active_dur_list.append(duration_mins)
                active_space_list.append(coSpace_id)
                active_call_list.append(call_id)
                owner_list.append(ownerJid)
                uri_list.append(uri)
                passcode_list.append(passcode)
                link_list.append(main_link)
            else:
                waiting_list.append(participant_name)
                waiting_dur_list.append(duration_mins)
                waiting_space_list.append(coSpace_id)
                waiting_call_list.append(call_id)
    active_calls = len(active_call_list)
    waiting_calls = len(waiting_call_list)
    if request.method == 'POST':
        if form.validate() == False:
            flash('All fields are required.')
        else:
            print("callid: " + request.form['callid'])
            if request.form['callid'] is not None:
                participant_name, participant_id, activator_name = CMS.getParticipants(
                    request.form['callid'])
                print("activator: " + activator_name)
                if activator_name == "":
                    CMS.addParticipantToCall(request.form['callid'],
                                             request.form['endpoint'])
    return render_template('vwr.html',
                           form=form,
                           tenant=tenant_name,
                           active_calls=active_calls,
                           waiting_calls=waiting_calls,
                           waiting=zip(waiting_list, waiting_call_list,
                                       waiting_dur_list, waiting_space_list),
                           active=zip(active_list, active_call_list,
                                      active_dur_list, active_space_list,
                                      uri_list, passcode_list, link_list,
                                      owner_list))