def perfwks(): d = {} if request.method == 'GET': # Determine if asking for specific fwk or not uri = request.args.get('uri', None) d['error'] = request.args.get('error', None) if uri: if current_user.is_authenticated(): d['registered'] = str(hash(uri)) in User(current_user.id).profile['perfwks'].keys() d['uri'] = uri d['fwk'] = models.getPerformanceFramework(uri) return render_template('perfwk-details.html', **d) d['frameworks_form'] = FrameworksForm() else: # Validate submitted fwk uri/parse/add to system ff = FrameworksForm(request.form) if ff.validate_on_submit(): #add to system competency.parseComp(ff.framework_uri.data) d['frameworks_form'] = FrameworksForm() else: d['frameworks_form'] = ff d['pfwks'] = models.findPerformanceFrameworks() return render_template('performancefwks.html', **d)
def perfwks(): d = {} if request.method == 'GET': # Determine if asking for specific fwk or not uri = request.args.get('uri', None) d['error'] = request.args.get('error', None) if uri: if current_user.is_authenticated(): d['registered'] = str(hash(uri)) in User( current_user.id).profile['perfwks'].keys() d['uri'] = uri d['fwk'] = models.getPerformanceFramework(uri) return render_template('perfwk-details.html', **d) d['frameworks_form'] = FrameworksForm() else: # Validate submitted fwk uri/parse/add to system ff = FrameworksForm(request.form) if ff.validate_on_submit(): #add to system competency.parseComp(ff.framework_uri.data) d['frameworks_form'] = FrameworksForm() else: d['frameworks_form'] = ff d['pfwks'] = models.findPerformanceFrameworks() return render_template('performancefwks.html', **d)
def lr_search(): # Get all comps/fwks/perfwks and parse id so it can be displayed comps = models.findCompetencies(sort='title') compfwks = models.findCompetencyFrameworks() perfwks = models.findPerformanceFrameworks() for c in comps: c['_id'] = str(c['_id']) for cf in compfwks: cf['_id'] = str(cf['_id']) for p in perfwks: p['_id'] = str(p['_id']) jcomps = json.dumps(comps) jcfwks = json.dumps(compfwks) jpfwks = json.dumps(perfwks) return render_template('lrsearch.html', search_form=SearchForm(), comps=jcomps, compfwks=jcfwks, perfwks=jpfwks)
def tetris_badge(perfwk_id, component_id, perf_id): # Probably a better way of doing this - serve png if '.png' in perf_id: filename = ':'.join([perfwk_id, component_id, perf_id]) try: badge = models.fsGetLastVersion(filename) except Exception, e: abort(404) badge_file = models.fsGetByID(badge._file['_id']) response = make_response(badge_file.read()) response.mimetype = badge_file.content_type return response # Serve metadata if not png else: b_fwk = models.findPerformanceFrameworks({'uuidurl': perfwk_id}) if not b_fwk: abort(404) b_class = models.getBadgeClass(perfwk_id, perf_id) if not b_class: abort(404) return b_class @app.route('/view_assertions', methods=['POST']) def view_assertions(): uri = request.form.get('uri', None) name = current_user.id p = performance.evaluate(uri, name)
def tetris_badge(perfwk_id, component_id, perf_id): # Probably a better way of doing this - serve png if '.png' in perf_id: filename = ':'.join([perfwk_id, component_id, perf_id]) try: badge = models.fsGetLastVersion(filename) except Exception, e: abort(404) badge_file = models.fsGetByID(badge._file['_id']) response = make_response(badge_file.read()) response.mimetype = badge_file.content_type return response # Serve metadata if not png else: b_fwk = models.findPerformanceFrameworks({'uuidurl': perfwk_id}) if not b_fwk: abort(404) b_class = models.getBadgeClass(perfwk_id, perf_id) if not b_class: abort(404) return b_class @app.route('/view_assertions', methods=['POST']) def view_assertions(): uri = request.form.get('uri', None) name = current_user.id