def test_plugins_warns(self): with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') plugins.plugins() assert len(w) == 1 assert issubclass(w[-1].category, DeprecationWarning) assert "slated for removal" in str(w[-1].message)
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
def yield_property(property_name): app = application.OpalApplication app_and_plugins = itertools.chain(plugins.plugins(), [app]) for plugin in app_and_plugins: excluded_tracking_prefixes = getattr(plugin, property_name, []) for i in excluded_tracking_prefixes: yield i
def restricted_teams(klass, user): """ Given a USER, return the restricted teams this user can access. """ restricted_teams = [] for plugin in plugins.plugins(): if plugin.restricted_teams: restricted_teams += plugin().restricted_teams(user) return restricted_teams
def get_roles(self): """ Return a roles dictionary for this user """ roles = {} for plugin in plugins.plugins(): roles.update(plugin().roles(self.user)) roles['default'] = [r.name for r in self.roles.all()] return roles
def flows(klass): """ Default implementation of flows() Pulls flows defined in the application's flows module, plus any flows defined by plugins. """ from opal.core import plugins flows = {} for plugin in plugins.plugins(): flows.update(plugin().flows()) if klass.flow_module is None: return flows flow = stringport(klass.flow_module) flows.update(flow.flows) return flows
router.register('patientlist', PatientListViewSet) router.register('patientrecordaccess', PatientRecordAccessViewSet) router.register('options', OptionsViewSet) router.register('referencedata', ReferenceDataViewSet) router.register('metadata', MetadataViewSet) for subrecord in subrecords(): sub_name = camelcase_to_underscore(subrecord.__name__) class SubViewSet(SubrecordViewSet): base_name = sub_name model = subrecord router.register(sub_name, SubViewSet) for plugin in plugins.plugins(): for api in plugin.apis: router.register(*api) class APIAdmitEpisodeView(View): """ Admit an episode from upstream! """ def post(self, *args, **kwargs): data = _get_request_data(self.request) resp = {'ok': 'Got your admission just fine - thanks!'} return _build_json_response(resp) class APIReferPatientView(View):
def _get_plugin_schemas(): scheme = {} for plugin in plugins.plugins(): scheme.update(plugin().list_schemas()) return scheme
def deps(): for plugin in plugins.plugins(): for i in plugin.angular_module_deps: yield i
def items(): for plugin in plugins.plugins(): for i in plugin.menuitems: yield i
def templates(): for plugin in plugins.plugins(): for tpl in plugin.head_extra: yield tpl
def styles(): for plugin in plugins.plugins(): for sheet in plugin.stylesheets: yield sheet
def scripts(): for plugin in plugins.plugins(): if namespace in plugin.javascripts: for javascript in plugin.javascripts[namespace]: yield javascript
url(r"api/v0.1/", include(api.router.urls)), ) # Generated subrecord template views for subrecord_model in subrecords(): sub_url = camelcase_to_underscore(subrecord_model.__name__) urlpatterns += patterns( "", url(r"^templates/modals/%s.html/?$" % sub_url, views.ModalTemplateView.as_view(), {"model": subrecord_model}), url( r"^templates/modals/%s.html/(?P<tag>[a-z_\-]+)/?$" % sub_url, views.ModalTemplateView.as_view(), {"model": subrecord_model}, ), url( r"^templates/modals/%s.html/(?P<tag>[a-z_\-]+)/(?P<subtag>[a-z_\-]+)/?$" % sub_url, views.ModalTemplateView.as_view(), {"model": subrecord_model}, ), ) urlpatterns += staticfiles_urlpatterns() from opal.core import plugins for plugin in plugins.plugins(): urlpatterns += plugin.urls urlpatterns += patterns("", url(r"templates/(?P<template_name>[a-z_/]+.html)", views.RawTemplateView.as_view()))