def competencies(): # Look for comp args, if none display all comps d = {} uri = request.args.get('uri', None) mb = request.args.get('mb', False) if uri: if current_user.is_authenticated(): user = User(current_user.id) comps = user.getAllComps() d['registered'] = str(hash(uri)) in comps.keys() d['uri'] = uri comp = models.getCompetency(uri, objectid=True) d['cid'] = comp.pop('_id') d['comp'] = comp # If medbiq comp display xml if so since it's the original and not lossy internal one if mb: if not comp.get('edited', False) and competency.isMB(comp): try: thexml = requests.get(competency.addXMLSuffix( comp['uri'])).text except: thexml = mbc.toXML(comp) else: thexml = mbc.toXML(comp) return Response(thexml, mimetype='application/xml') else: compuri = d['uri'] if 'adlnet' in d['uri']: compuri = compuri[:7] + 'www.' + compuri[7:] url = "https://node01.public.learningregistry.net/slice?any_tags=%s" % compuri resp = requests.get(url) ids = [] if resp.status_code == 200: lrresults = json.loads(resp.content) ids = [s['doc_ID'] for s in lrresults['documents']] for d_id in ids: models.updateCompetencyLR( d['cid'], current_app.config['LR_NODE'] + d_id + '&by_doc_ID=T') updated_comp = models.getCompetency(uri, objectid=True) d['comp'] = updated_comp return render_template('comp-details.html', **d) d['comps'] = models.findCompetencies() return render_template('competencies.html', **d)
def competencies(): # Look for comp args, if none display all comps d = {} uri = request.args.get('uri', None) mb = request.args.get('mb', False) if uri: if current_user.is_authenticated(): user = User(current_user.id) comps = user.getAllComps() d['registered'] = str(hash(uri)) in comps.keys() d['uri'] = uri comp = models.getCompetency(uri, objectid=True) d['cid'] = comp.pop('_id') d['comp'] = comp # If medbiq comp display xml if so since it's the original and not lossy internal one if mb: if not comp.get('edited', False) and competency.isMB(comp): try: thexml = requests.get(competency.addXMLSuffix(comp['uri'])).text except: thexml = mbc.toXML(comp) else: thexml = mbc.toXML(comp) return Response(thexml, mimetype='application/xml') else: compuri = d['uri'] if 'adlnet' in d['uri']: compuri = compuri[:7] + 'www.' + compuri[7:] url = "https://node01.public.learningregistry.net/slice?any_tags=%s" % compuri resp = requests.get(url) ids = [] if resp.status_code == 200: lrresults = json.loads(resp.content) ids = [s['doc_ID'] for s in lrresults['documents']] for d_id in ids: models.updateCompetencyLR(d['cid'], current_app.config['LR_NODE'] + d_id + '&by_doc_ID=T') updated_comp = models.getCompetency(uri, objectid=True) d['comp'] = updated_comp return render_template('comp-details.html', **d) d['comps'] = models.findCompetencies() return render_template('competencies.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 competencies(): d = {} d['comps'] = models.findCompetencies() return render_template('competencies.html', **d)