def aggregationtypes_edit(aggregationtype_id=None): aggregationtype = get_aggregation_type(aggregationtype_id) if request.method == 'POST': if aggregationtype: flash('Successfully added your aggregation type.', 'success') else: aggregationtype = {} flash('Could not add your aggregation type.', 'error') tests = dqtests.tests() return render_template("aggregation_types_edit.html", aggregationtype=aggregationtype, tests=tests, admin=usermanagement.check_perms('admin'), loggedinuser=current_user)
def get_summary_org_test(results): from iatidq import dqorganisations, dqtests orgtests = set(map(lambda x: (x['organisation_id'], x['test_id']), results)) ot = [] for orgtest in orgtests: orgtest_results = filter(lambda x: ( x['organisation_id'] == orgtest[0] and x['test_id'] == orgtest[1] ), results) success = filter(lambda x: x['response'] == 1, orgtest_results) fail = filter(lambda x: x['response'] != 1, orgtest_results) totalsuccess = sum(map(lambda x: x['count'], success)) totalfail = sum(map(lambda x: x['count'], fail)) pct = float(totalsuccess) / (totalsuccess + totalfail) * 100 passfail = pct >= 50.0 if passfail: passfail_class='success' passfail_text='PASS' else: passfail_class='important' passfail_text='FAIL' ot.append({ 'organisation_id': orgtest[0], 'organisation': dqorganisations.organisation_by_id(orgtest[0]), 'test_id': orgtest[1], 'test': dqtests.tests(orgtest[1]), 'success': round(pct, 2), 'total': totalsuccess+totalfail, 'results': orgtest_results, 'pass': passfail, 'passfail_text': passfail_text, 'passfail_class': passfail_class, }) return ot
def get_test_info(test_id): return dqtests.tests(test_id)