Example #1
0
def home():
    session['logo'] = Config.LOGO
    tenant_list = CMS.getTenants()
    if current_user.username == "admin":
        form = Admin()
        template = "admin.html"
        settings = Extensions.get_admin_settings()
        space_list = []
        for tenant in tenant_list:
            tenant_name = tenant[1]
            space_filter = tenant_name.replace(" ", "_")
            print(space_filter)
            space_list = CMS.getSpaces(space_filter, space_list)
        form.spaces.choices = space_list
        try:
            guestCLP = settings['guest_CLP']
        except:
            guestCLP = ""
        try:
            hostCLP = settings['host_CLP']
        except:
            hostCLP = ""
    else:
        form = VWR_Admin()
        template = "index.html"
    form.tenants.choices = tenant_list
    if request.method == 'POST':
        if "tenants" in request.form:
            tenant_id = request.form['tenants']
        if "create_tenant" in request.form:
            print("create_tenant")
            CMS.createTenant(request.form['tenant'], settings['guest_CLP'])
        elif "delete_tenant" in request.form:
            print("delete_tenant")
            CMS.deleteTenant(tenant_id)
        elif "create_guest_CLP" in request.form:
            print("create_guest_CLP")
            Guest_CLP_ID = CMS.createGuest_CLP("guest")
            Extensions.update_admin_settings(Guest_CLP_ID, "")
        elif "create_host_CLP" in request.form:
            print("create_host_CLP")
            Host_CLP_ID = CMS.createHost_CLP("host")
            Extensions.update_admin_settings("", Host_CLP_ID)
        elif "delete_spaces" in request.form:
            print("delete_spaces")
            spaceIdList = request.form.getlist('spaces')
            CMS.deleteSpaces(spaceIdList)
        if current_user.username == "admin":
            return redirect(url_for('home'))
        else:
            return redirect(url_for('vwr', tenant_id=tenant_id))
    elif request.method == 'GET':
        if current_user.username == "admin":
            return render_template(template,
                                   form=form,
                                   guestCLP=guestCLP,
                                   hostCLP=hostCLP)
        else:
            return render_template(template, form=form)
Example #2
0
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)
        link = CreatePatientLink(tenant_name, tenant_id)
        return redirect(link)
    elif request.method == 'GET':
        return render_template('index.html', form=form)
Example #3
0
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)