Esempio n. 1
0
 def actions():
     app = application.get_app()
     for action in app.actions:
         yield action
     for plugin in plugins.plugins():
         for action in plugin.actions:
             yield action
Esempio n. 2
0
 def actions():
     app = application.get_app()
     for action in app.actions:
         yield action
     for plugin in plugins.plugins():
         for action in plugin.actions:
             yield action
Esempio n. 3
0
 def write_to_many_files(self, data):
     app_dir = application.get_app().directory()
     for listname in data:
         filepath = os.path.abspath(
             os.path.join(app_dir, 'data', 'lookuplists',
                          '{0}.json'.format(listname)))
         contents = {listname: data[listname]}
         self.write_to_file(contents, filepath)
Esempio n. 4
0
 def styles():
     app = application.get_app()
     for style in app.get_styles():
         if style.endswith(".scss"):
             mime_type = "text/x-scss"
         else:
             mime_type = "text/css"
         yield style, mime_type
Esempio n. 5
0
    def yield_property(property_name):
        app = application.get_app()
        app_and_plugins = itertools.chain(plugins.OpalPlugin.list(), [app])

        for plugin in app_and_plugins:
            excluded_tracking_prefixes = getattr(plugin, property_name, [])
            for i in excluded_tracking_prefixes:
                yield i
Esempio n. 6
0
    def yield_property(property_name):
        app = application.get_app()
        app_and_plugins = itertools.chain(plugins.OpalPlugin.list(), [app])

        for plugin in app_and_plugins:
            excluded_tracking_prefixes = getattr(plugin, property_name, [])
            for i in excluded_tracking_prefixes:
                yield i
Esempio n. 7
0
 def from_component(self, component):
     # Start with the initial lookuplists.json
     filename = ffs.Path(LOOKUPLIST_LOCATION.format(component.directory()))
     self.load(self.from_path(filename))
     # then work throught the lookuplists we know about
     for lookuplist in lookuplists.LookupList.__subclasses__():
         path = ffs.Path("{0}/data/lookuplists/{1}.json".format(
             application.get_app().directory(), lookuplist.get_api_name()))
         self.load(self.from_path(path))
Esempio n. 8
0
 def test_from_component(self, path):
     c = loader.Command()
     c.from_component(application.get_app())
     calls = [c[0][0] for c in path.call_args_list]
     expected = [
         'data/lookuplists/lookuplists.json', 'data/lookuplists/drug.json',
         'data/lookuplists/condition.json'
     ]
     for e in expected:
         self.assertTrue(len([c for c in calls if c.endswith(e)]) == 1)
Esempio n. 9
0
 def write_to_many_files(self, data):
     app_dir = application.get_app().directory()
     for listname in data:
         filepath = os.path.abspath(
             os.path.join(
                 app_dir, 'data', 'lookuplists', '{0}.json'.format(listname)
             )
         )
         contents = {listname: data[listname]}
         self.write_to_file(contents, filepath)
Esempio n. 10
0
 def from_component(self, component):
     # Start with the initial lookuplists.json
     filename = ffs.Path(LOOKUPLIST_LOCATION.format(component.directory()))
     self.load(self.from_path(filename))
     # then work throught the lookuplists we know about
     for lookuplist in lookuplists.LookupList.__subclasses__():
         path = ffs.Path("{0}/data/lookuplists/{1}.json".format(
             application.get_app().directory(),
             lookuplist.get_api_name()
         ))
         self.load(self.from_path(path))
 def test_from_component(self, path):
     c = loader.Command()
     c.from_component(application.get_app())
     calls = [c[0][0] for c in path.call_args_list]
     expected = [
         os.path.join('data', 'lookuplists', 'lookuplists.json'),
         os.path.join('data', 'lookuplists', 'drug.json'),
         os.path.join('data', 'lookuplists', 'condition.json'),
     ]
     for e in expected:
         self.assertTrue(len([c for c in calls if c.endswith(e)]) == 1)
Esempio n. 12
0
def menu(context):
    """
    Render the menu for this application.
    """
    context = copy.copy(context)
    app = application.get_app()
    menu = app.get_menu(user=context['user'])

    context.dicts.append({
        'menu': menu,
    })
    return context
Esempio n. 13
0
    def __init__(self, user=None):
        self.user = user
        self.items = []

        from opal.core import application, plugins
        app = application.get_app()

        # If we don't += this here, we start appending to the
        # list attached to the active Application class.
        # Which is suboptimal.
        self.items = app.get_menu_items(self.user)

        for plugin in plugins.OpalPlugin.list():
            self.items.extend(plugin.get_menu_items(self.user))
Esempio n. 14
0
    def __init__(self, user=None):
        self.user = user
        self.items = []

        from opal.core import application, plugins
        app = application.get_app()

        # If we don't += this here, we start appending to the
        # list attached to the active Application class.
        # Which is suboptimal.
        self.items = app.get_menu_items(self.user)

        for plugin in plugins.OpalPlugin.list():
            self.items.extend(plugin.get_menu_items(self.user))
Esempio n. 15
0
    def __init__(self, user=None):
        self.user = user
        self.items = []

        from opal.core import application, plugins
        app = application.get_app()

        # If we don't += this here, we start appending to the
        # list attached to the active Application class.
        # Which is suboptimal.
        app_items = app.get_menu_items(user=self.user)
        warnthem = """
Declaring Opal menu items as python dicts will no longer work in Opal 0.9.0.

Menu items should be instances of opal.core.menus.MenuItem

You should convert {0}

Please consult the Opal documentation on menus for more information.
"""
        for item in app_items:
            if isinstance(item, MenuItem):
                self.items.append(item)
            else:
                self.items.append(MenuItem(**item))
                warnings.warn(warnthem.format(item),
                              DeprecationWarning,
                              stacklevel=2)

        for plugin in plugins.OpalPlugin.list():
            for item in plugin.menuitems:
                if isinstance(item, MenuItem):
                    self.items.append(item)
                else:
                    self.items.append(MenuItem(**item))
                    warnings.warn(warnthem.format(item),
                                  DeprecationWarning,
                                  stacklevel=2)
Esempio n. 16
0
from rest_framework import routers, status, viewsets
from rest_framework.response import Response

from opal.models import (
    Episode, Synonym, Patient, PatientRecordAccess, PatientSubrecord
)
from opal.core import application, exceptions, metadata, plugins, schemas
from opal.core.lookuplists import LookupList
from opal.utils import stringport, camelcase_to_underscore
from opal.core.subrecords import subrecords
from opal.core.views import _get_request_data, _build_json_response
from opal.core.patient_lists import (
    PatientList, TaggedPatientListMetadata, FirstListMetadata
)

app = application.get_app()

# TODO This is stupid - we can fully deprecate this please?
try:
    options = stringport(settings.OPAL_OPTIONS_MODULE)
    micro_test_defaults = options.micro_test_defaults
except AttributeError:
    class options:
        model_names = []
    micro_test_defaults = []

class OPALRouter(routers.DefaultRouter):
    def get_default_base_name(self, viewset):
        name = getattr(viewset, 'base_name', None)
        if name is None:
            return routers.DefaultRouter.get_default_base_name(self, viewset)
Esempio n. 17
0
 def items():
     app = application.get_app()
     for i in app.menuitems:
         yield i
Esempio n. 18
0
from django.contrib.contenttypes.models import ContentType
from rest_framework import routers, status, viewsets
from rest_framework.permissions import IsAuthenticated

from opal.models import (
    Episode, Synonym, Patient, PatientRecordAccess,
    PatientSubrecord, UserProfile
)
from opal.core import application, exceptions, metadata, plugins, schemas
from opal.core.lookuplists import LookupList
from opal.core.subrecords import subrecords
from opal.core.views import json_response
from opal.core.patient_lists import PatientList


app = application.get_app()


class OPALRouter(routers.DefaultRouter):
    def get_default_base_name(self, viewset):
        name = getattr(viewset, 'base_name', None)
        if name is None:
            return routers.DefaultRouter.get_default_base_name(self, viewset)
        return name


router = OPALRouter()


def item_from_pk(fn):
    """
Esempio n. 19
0
 def scripts():
     app = application.get_app()
     for javascript in app.javascripts:
         yield javascript
Esempio n. 20
0
 def scripts():
     app = application.get_app()
     for javascript in app.javascripts:
         yield javascript
Esempio n. 21
0
 def test_created_with_the_default_episode(self):
     _, episode = self.new_patient_and_episode_please()
     self.assertEqual(application.get_app().default_episode_category,
                      episode.category_name)
Esempio n. 22
0
 def scripts():
     app = application.get_app()
     for javascript in app.core_javascripts[namespace]:
         yield javascript
Esempio n. 23
0
 def test_get_app(self, subclasses):
     mock_app = MagicMock('Mock App')
     subclasses.return_value = [mock_app]
     self.assertEqual(mock_app, application.get_app())
Esempio n. 24
0
 def items():
     app = application.get_app()
     for i in app.menuitems:
         yield i
Esempio n. 25
0
 def items():
     app = application.get_app()
     for i in app.get_menu_items(user=context['user']):
         yield i
Esempio n. 26
0
def opal_angular_deps():
    app = application.get_app()
    return dict(deps=app.get_all_angular_module_deps())
Esempio n. 27
0
 def scripts():
     app = application.get_app()
     for javascript in app.core_javascripts[namespace]:
         yield javascript
Esempio n. 28
0
 def test_get_app(self, subclasses):
     mock_app = MagicMock('Mock App')
     subclasses.return_value = [mock_app]
     self.assertEqual(mock_app, application.get_app())
Esempio n. 29
0
 def test_created_with_the_default_episode(self):
     _, episode = self.new_patient_and_episode_please()
     self.assertEqual(
         application.get_app().default_episode_category,
         episode.category_name
     )
Esempio n. 30
0
def get_default_episode_type():
    app = application.get_app()
    return app.default_episode_category
Esempio n. 31
0
 def styles():
     app = application.get_app()
     for style in app.get_styles():
         yield style