Exemplo n.º 1
0
 def test_disorderapilist(self):
     disorder = Disorder()
     response = self.client.get(reverse('disorder_api_list'))
     count = disorder.count()
     content = json.loads(response.content.decode('utf-8'))
     self.assertEqual(len(content), count)
     self.assertEqual(response.status_code, 200)
Exemplo n.º 2
0
 def test_view_disorder(self):
     disorder = Disorder()
     dis = disorder.create("test_view_disorder", {"prop": "prop"})
     uid = dis.properties['id']
     response = self.client.get(reverse('disorder', kwargs={'uid': uid}))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.context['disorder']['id'], uid)
     dis.delete()
Exemplo n.º 3
0
def update_disorder(request, uid):
    if request.method == "POST":
        definition = request.POST.get('disorder_definition', '')
        name = request.POST.get('disorder_name', '')
        updates = add_update("name", name)
        updates = add_update("definition", definition, updates)
        Disorder.update(uid, updates=updates)
    return view_disorder(request, uid)
Exemplo n.º 4
0
 def __init__(self, name=None, *args, **kwargs):
     super(DisorderDisorderForm, self).__init__(*args, **kwargs)
     name = (name if name is not None else '')
     disorders = Disorder()
     type_choices = [
         ('parent', '{} is a kind of <selected disorder>'.format(name)),
         ('child', '<selected disorder> is a kind of {}'.format(name))
     ]
     dis_choices = [(x['id'], x['name']) for x in disorders.all()]
     self.fields['type'] = forms.ChoiceField(choices=type_choices)
     self.fields['disorders'] = forms.ChoiceField(choices=dis_choices)
     self.helper = FormHelper()
     self.helper.form_tag = False
     self.helper.add_input(Submit('submit', 'Submit'))
     self.helper.add_input(Reset('disorder-disorder-cancel', 'Cancel'))
Exemplo n.º 5
0
 def test_disorderapidetail_by_name(self):
     disorder = Disorder()
     response = self.client.get(reverse('disorder_api_list'),
                                {'name': self.disorder.properties['name']})
     content = json.loads(response.content.decode('utf-8'))
     self.assertEqual(content['id'], self.disorder.properties['id'])
     self.assertEqual(response.status_code, 200)
Exemplo n.º 6
0
 def test_update_disorder(self):
     self.assertTrue(
         self.client.login(username=self.user.username,
                           password=self.password))
     disorder = Disorder()
     dis = disorder.create('test_update_disorder', {'prop': 'prop'})
     response = self.client.post(
         reverse('update_disorder', kwargs={'uid': dis.properties['id']}), {
             'disorder_name': 'disorder_name',
             'disorder_definition': 'disorder_definition'
         })
     self.assertEqual(response.status_code, 200)
     self.assertEqual('disorder_name', response.context['disorder']['name'])
     self.assertEqual('disorder_definition',
                      response.context['disorder']['definition'])
     dis.delete()
Exemplo n.º 7
0
    def __init__(self, task_id, *args, **kwargs):
        super(TaskDisorderForm, self).__init__(*args, **kwargs)
        disorders = Disorder()
        behaviors = query.Behavior()
        traits = query.Trait()
        tasks = Task()
        contrasts = tasks.get_relation(task_id, "HASCONTRAST")

        cont_choices = [(x['id'], x['name']) for x in contrasts]
        self.fields['contrasts'] = forms.ChoiceField(choices=cont_choices)

        pheno_choices = []
        pheno_choices.extend([(x['id'], ''.join([x['name'], " (Disorder)"]))
                              for x in disorders.all()])
        pheno_choices.extend([(x['id'], ''.join([x['name'], " (Behavior)"]))
                              for x in behaviors.all()])
        pheno_choices.extend([(x['id'], ''.join([x['name'], " (Trait)"]))
                              for x in traits.all()])
        self.fields['disorders'] = forms.ChoiceField(choices=pheno_choices)

        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.add_input(Submit('submit', 'Submit'))
        self.helper.add_input(Reset('task-disorder-cancel', 'Cancel'))
Exemplo n.º 8
0
def all_disorders(request):
    '''all_disorders returns page with list of all disorders'''

    disorders = Disorder.all(order_by="name")
    for d in range(len(disorders)):
        disorder = disorders[d]
        if disorder["classification"] == None:
            disorder["classification"] = "None"
            disorders[d] = disorder

    context = {
        'appname': "The Cognitive Atlas",
        'active': "disorders",
        'nodes': disorders
    }

    return render(request, "atlas/all_disorders.html", context)
Exemplo n.º 9
0
def base(request):

    # We only need id and name for the home page
    fields = ["id","name"]

    concepts = Concept.all(limit=10,order_by="last_updated",fields=fields)
    tasks = Task.all(limit=10,order_by="last_updated",fields=fields)
    disorders = Disorder.all(limit=10,order_by="last_updated",fields=fields)
    theories = Theory.all(limit=7,order_by="last_updated",fields=fields)
    
    appname = "The Cognitive Atlas"
    context = {'appname': appname,
               'active':'homepage',
               'concepts':concepts,
               'tasks':tasks,
               'theories':theories,
               'disorders':disorders}

    return context
Exemplo n.º 10
0
 def setUp(self):
     disorder = Disorder()
     self.disorder = disorder.create("test_view_disorder", {
         "prop": "prop",
         "definition": "definition"
     })
Exemplo n.º 11
0
from cognitive.apps.atlas.query import Concept, Task, Disorder, Theory, Battery
from django.shortcuts import render, render_to_response
from django.template import RequestContext
from cognitive.settings import DOMAIN
from django.shortcuts import render
from django.template import loader

Concept = Concept()
Task = Task()
Disorder = Disorder()
Theory = Theory()
Battery = Battery()

def base(request):

    # We only need id and name for the home page
    fields = ["id","name"]

    concepts = Concept.all(limit=10,order_by="last_updated",fields=fields)
    tasks = Task.all(limit=10,order_by="last_updated",fields=fields)
    disorders = Disorder.all(limit=10,order_by="last_updated",fields=fields)
    theories = Theory.all(limit=7,order_by="last_updated",fields=fields)
    
    appname = "The Cognitive Atlas"
    context = {'appname': appname,
               'active':'homepage',
               'concepts':concepts,
               'tasks':tasks,
               'theories':theories,
               'disorders':disorders}
Exemplo n.º 12
0
def view_disorder(request, uid):
    disorder = Disorder.get(uid)[0]
    context = {"disorder": disorder}
    return render(request, 'atlas/view_disorder.html', context)
Exemplo n.º 13
0
from cognitive.apps.atlas.query import Concept, Task, Disorder, \
  Contrast, Battery, Theory, Condition, search
from cognitive.apps.atlas.utils import clean_html, update_lookup, add_update
from django.http import JsonResponse, HttpResponse
from cognitive.settings import DOMAIN
from django.shortcuts import render
from django.template import loader
import pickle
import json
import numpy

Concept = Concept()
Task = Task()
Disorder = Disorder()
Contrast = Contrast()
Battery = Battery()
Theory = Theory()
Condition = Condition()

# Needed on all pages
counts = {
    "disorders": Disorder.count(),
    "tasks": Task.count(),
    "contrasts": Contrast.count(),
    "concepts": Concept.count(),
    "batteries": Battery.count(),
    "theories": Theory.count()
}

# VIEWS FOR ALL NODES #############################################################
Exemplo n.º 14
0
from cognitive.apps.atlas.query import Concept, Task, Disorder, Theory, Battery

Concept = Concept()
Task = Task()
Disorder = Disorder()
Theory = Theory()
Battery = Battery()

# Needed on all pages
counts = {"disorders":Disorder.count(),
          "tasks":Task.count(),
          "concepts":Concept.count(),
          "theories":Theory.count(),
          "batteries":Battery.count()}

def counts_processor(request):
    return {'counts': counts}