def view_task(request, uid, return_context=False): task = Task.get(uid)[0] # Replace newlines with <br>, etc. task["definition"] = clean_html(task["definition"]) contrasts = Task.get_contrasts(task["id"]) # Make a lookup dictionary based on concept id concept_lookup = dict() for contrast in contrasts: contrast_concepts = Contrast.get_concepts(contrast["contrast_id"]) for concept in contrast_concepts: concept_lookup = update_lookup(concept_lookup, concept["concept_id"], contrast) # Retrieve conditions, make associations with contrasts conditions = Task.get_conditions(uid) context = { "task": task, "concepts": concept_lookup, "contrasts": contrasts, "conditions": conditions, "domain": DOMAIN } if return_context == True: return context return render(request, 'atlas/view_task.html', context)
def test_contrast_get_concepts(self): contrast = Contrast() concepts = contrast.get_concepts(self.cont.properties['id']) self.assertEqual(len(concepts), 1) self.assertEqual(concepts[0]['concept_id'], self.con.properties['id'])