本文整理汇总了Python中bika.lims.interfaces.IClient.providedBy方法的典型用法代码示例。如果您正苦于以下问题:Python IClient.providedBy方法的具体用法?Python IClient.providedBy怎么用?Python IClient.providedBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bika.lims.interfaces.IClient
的用法示例。
在下文中一共展示了IClient.providedBy方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Vocabulary_SampleType
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def Vocabulary_SampleType(self):
vocabulary = CatalogVocabulary(self)
vocabulary.catalog = 'bika_setup_catalog'
folders = [self.bika_setup.bika_sampletypes]
if IClient.providedBy(self.aq_parent):
folders.append(self.aq_parent)
return vocabulary(allow_blank=True, portal_type='SampleType')
示例2: update
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def update(self):
"""Called before the listings renders
"""
super(PatientsView, self).update()
# Render the Add button. We need to do this here because patients live
# inside site.patients folder
self.context_actions = {}
patients = api.get_portal().patients
if security.check_permission(AddPatient, patients):
self.context_actions = {
_("Add"): {
"url": "createObject?type_name=Patient",
"icon": "++resource++bika.lims.images/add.png"}
}
# If the current user is a client contact, display those patients that
# belong to same client or that do not belong to any client
client = api.get_current_client()
if client:
query = dict(client_uid=[api.get_uid(client), "-1"])
# We add UID "-1" to also include Patients w/o Client assigned
self.contentFilter.update(query)
for rv in self.review_states:
rv["contentFilter"].update(query)
# If the current context is a Client, remove the title column
if IClient.providedBy(self.context):
self.remove_column('getPrimaryReferrerTitle')
示例3: folderitems
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def folderitems(self, **kwargs):
items = super(ARImportsView, self).folderitems()
for x in range(len(items)):
if 'obj' not in items[x]:
continue
obj = items[x]['obj']
items[x]['Title'] = obj.title_or_id()
if items[x]['review_state'] == 'invalid':
items[x]['replace']['Title'] = "<a href='%s/edit'>%s</a>" % (
obj.absolute_url(), items[x]['Title'])
else:
items[x]['replace']['Title'] = "<a href='%s/view'>%s</a>" % (
obj.absolute_url(), items[x]['Title'])
items[x]['Creator'] = obj.Creator()
items[x]['Filename'] = obj.getFilename()
parent = obj.aq_parent
items[x]['Client'] = parent if IClient.providedBy(parent) else ''
items[x]['replace']['Client'] = "<a href='%s'>%s</a>" % (
parent.absolute_url(), parent.Title())
items[x]['DateCreated'] = ulocalized_time(
obj.created(), long_format=True, time_only=False, context=obj)
date = getTransitionDate(obj, 'validate')
items[x]['DateValidated'] = date if date else ''
date = getTransitionDate(obj, 'import')
items[x]['DateImported'] = date if date else ''
return items
示例4: get_client_uid
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def get_client_uid(self):
instance = self.context.aq_parent
while not IPloneSiteRoot.providedBy(instance):
if IClient.providedBy(instance):
return instance.UID()
if IBatch.providedBy(instance):
client = instance.getClient()
if client:
return client.UID()
示例5: getClient
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def getClient(self):
""" Retrieves the Client for which the current Batch is attached to
Tries to retrieve the Client from the Schema property, but if not
found, searches for linked ARs and retrieve the Client from the
first one. If the Batch has no client, returns None.
"""
client = self.Schema().getField('Client').get(self)
if client:
return client
client = self.aq_parent
if IClient.providedBy(client):
return client
示例6: __call__
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def __call__(self):
plone.protect.CheckAuthenticator(self.request)
curr_user = api.get_current_user()
contact = api.get_user_contact(curr_user, contact_types=['Contact'])
parent = contact and contact.getParent() or None
if parent and not IClient.providedBy(parent):
parent = None
ret = {'ClientTitle': parent and parent.Title() or '',
'ClientID': parent and parent.getClientID() or '',
'ClientSysID': parent and parent.id or '',
'ClientUID': parent and parent.UID() or '',}
return json.dumps(ret)
示例7: __call__
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def __call__(self, context, mode, field, default):
state = default if default else 'hidden'
fieldName = field.getName()
if fieldName != 'Client':
return state
parent = self.context.aq_parent
if IBatch.providedBy(parent):
if parent.getClient():
return 'hidden'
if IClient.providedBy(parent):
return 'hidden'
return state
示例8: get_client
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def get_client(self, schema, fieldnames):
"""All Client Contact fields must be restricted to show only relevant
Contacts. During creation the batch can be in some weird states
and is located inside some odd contexs (TempFolder, PortalFactory),
so some wiggling required. We also can't use schema field accessors
directly, as it causes recursion.
"""
client = None
# If heirarchy does not exist we're in early creation; skip body.
if hasattr(self, 'context') and hasattr(self.context, 'aq_parent'):
parent = self.context.aq_parent
while not IPloneSiteRoot.providedBy(parent):
if IClient.providedBy(parent):
client = parent
break
parent = parent.aq_parent
return client
示例9: get_current_client
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def get_current_client(self, default=None):
"""Returns the client the current user belongs to
"""
user = api.get_current_user()
roles = user.getRoles()
if 'Client' not in roles:
return default
contact = api.get_user_contact(user)
if not contact or ILabContact.providedBy(contact):
return default
client = api.get_parent(contact)
if not client or not IClient.providedBy(client):
return default
return client
示例10: __call__
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def __call__(self):
mtool = getToolByName(self.context, 'portal_membership')
can_add_doctors = mtool.checkPermission(AddDoctor, self.context)
if can_add_doctors:
add_doctors_url = '{}/doctors/createObject?type_name=Doctor' \
.format(self.portal_url)
self.context_actions[_('Add')] = {
'url': add_doctors_url,
'icon': '++resource++bika.lims.images/add.png'
}
if mtool.checkPermission(ManageDoctors, self.context):
self.review_states[0]['transitions'].append({'id':'deactivate'})
self.review_states.append(
{'id':'inactive',
'title': _('Dormant'),
'contentFilter': {'is_active': False},
'transitions': [{'id':'activate'}, ],
'columns': self.columns.keys()})
self.review_states.append(
{'id':'all',
'title': _('All'),
'contentFilter':{},
'transitions':[{'id':'empty'}],
'columns': self.columns.keys()})
stat = self.request.get("%s_review_state"%self.form_id, 'default')
self.show_select_column = stat != 'all'
# If the current context is a Client, filter Doctors by Client UID
if IClient.providedBy(self.context):
client_uid = api.get_uid(self.context)
self.contentFilter['getPrimaryReferrerUID'] = client_uid
# If the current user is a client contact, do not display the doctors
# assigned to other clients
elif self.get_user_client_uid():
client_uid = self.get_user_client_uid()
self.contentFilter['getPrimaryReferrerUID'] = [client_uid, None]
return super(DoctorsView, self).__call__()
示例11: __init__
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def __init__(self, context, request):
super(ARImportsView, self).__init__(context, request)
request.set('disable_plone.rightcolumn', 1)
alsoProvides(request, IContentListing)
self.catalog = "portal_catalog"
self.contentFilter = {
'portal_type': 'ARImport',
'cancellation_state': 'active',
'sort_on': 'sortable_title',
}
self.context_actions = {}
if IClient.providedBy(self.context):
self.context_actions = {
_('AR Import'): {
'url': 'arimport_add',
'icon': '++resource++bika.lims.images/add.png'}}
self.show_sort_column = False
self.show_select_row = False
self.show_select_column = False
self.pagesize = 50
self.form_id = "arimports"
self.icon = \
self.portal_url + "/++resource++bika.lims.images/arimport_big.png"
self.title = self.context.translate(_("Analysis Request Imports"))
self.description = ""
self.columns = {
'Title': {'title': _('Title')},
'Client': {'title': _('Client')},
'Filename': {'title': _('Filename')},
'Creator': {'title': _('Date Created')},
'DateCreated': {'title': _('Date Created')},
'DateValidated': {'title': _('Date Validated')},
'DateImported': {'title': _('Date Imported')},
'state_title': {'title': _('State')},
}
self.review_states = [
{'id': 'default',
'title': _('Pending'),
'contentFilter': {'review_state': ['invalid', 'valid']},
'columns': ['Title',
'Creator',
'Filename',
'Client',
'DateCreated',
'DateValidated',
'DateImported',
'state_title']},
{'id': 'imported',
'title': _('Imported'),
'contentFilter': {'review_state': 'imported'},
'columns': ['Title',
'Creator',
'Filename',
'Client',
'DateCreated',
'DateValidated',
'DateImported',
'state_title']},
{'id': 'cancelled',
'title': _('Cancelled'),
'contentFilter': {
'review_state': ['initial', 'invalid', 'valid', 'imported'],
'cancellation_state': 'cancelled'
},
'columns': ['Title',
'Creator',
'Filename',
'Client',
'DateCreated',
'DateValidated',
'DateImported',
'state_title']},
]
示例12: __init__
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def __init__(self, context, request):
super(BaseARImportsView, self).__init__(context, request)
request.set('disable_plone.rightcolumn', 1)
self.catalog = "portal_catalog"
self.contentFilter = {
'portal_type': 'ARImport',
'sort_on':'sortable_title',
}
self.context_actions = {}
if IClient.providedBy(self.context):
self.context_actions = \
{_('AR Import'):
{'url': 'arimport_add',
'icon': '++resource++bika.lims.images/add.png'}}
self.show_sort_column = False
self.show_select_row = False
self.show_select_column = False
self.pagesize = 50
self.form_id = "arimports"
self.icon = \
self.portal_url + "/++resource++bika.lims.images/arimport_big.png"
self.title = self.context.translate(_("Analysis Request Imports"))
self.description = ""
self.columns = {
'title': {'title': _('Import')},
'getClientTitle': {'title': _('Client')},
'getDateImported': {'title': _('Date Imported')},
'getStatus': {'title': _('Validity')},
'getDateApplied': {'title': _('Date Submitted')},
'state_title': {'title': _('State')},
}
self.review_states = [
{'id':'default',
'title': _('All'),
'contentFilter':{},
'columns': ['title',
'getClientTitle',
'getDateImported',
'getStatus',
'getDateApplied',
'state_title']},
{'id':'imported',
'title': _('Imported'),
'contentFilter':{'review_state':'imported'},
'columns': ['title',
'getClientTitle',
'getDateImported',
'getStatus']},
{'id':'submitted',
'title': _('Applied'),
'contentFilter':{'review_state':'submitted'},
'columns': ['title',
'getClientTitle',
'getDateImported',
'getStatus',
'getDateApplied']},
]
示例13: filter_client_lookups
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def filter_client_lookups(self, schema, client):
if IClient.providedBy(client):
ids = [c.getId() for c in client.objectValues('Contact')]
for fn in ["Contact", "CCContact", "InvoiceContact"]:
if fn in schema:
schema[fn].widget.base_query['id'] = ids
示例14: is_client_context
# 需要导入模块: from bika.lims.interfaces import IClient [as 别名]
# 或者: from bika.lims.interfaces.IClient import providedBy [as 别名]
def is_client_context(self):
"""Returns whether the batch listing is displayed in IClient context
or if the current user is a client contact
"""
return api.get_current_client() or IClient.providedBy(self.context)