def CreatePatientLink(tenant_name, tenant_id): now = datetime.utcnow() timestamp_now = time.mktime(now.timetuple()) + now.microsecond * 1e-6 timestamp_str = str(timestamp_now).rsplit('.', 1)[1] space_name = tenant_name.replace(" ", "_") + "_" + timestamp_str coSpace_id = CMS.createSpace(space_name, tenant_id) link, callId, ownerJid = CMS.getCoSpaceDetails(coSpace_id) CMS.createAccessMethod(coSpace_id, callId, space_name) return link
def patient(): session['logo'] = Config.LOGO tenant_list = CMS.getTenants() form = VWR_Admin() form.tenants.choices = tenant_list if request.method == 'POST': tenant_id = request.form['tenants'] tenant_name = dict(form.tenants.choices).get(form.tenants.data) now = datetime.utcnow() timestamp_now = time.mktime(now.timetuple()) + now.microsecond * 1e-6 timestamp_str = str(timestamp_now).rsplit('.', 1)[1] space_name = tenant_name.replace(" ", "_") + "_" + timestamp_str coSpace_id = CMS.createSpace(space_name, tenant_id) link, callId, ownerJid = CMS.getCoSpaceDetails(coSpace_id) CMS.createAccessMethod(coSpace_id, callId, space_name) return redirect(link) elif request.method == 'GET': return render_template('index.html', form=form)
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))