本文整理汇总了Python中website.models.Node.find_by_institutions方法的典型用法代码示例。如果您正苦于以下问题:Python Node.find_by_institutions方法的具体用法?Python Node.find_by_institutions怎么用?Python Node.find_by_institutions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类website.models.Node
的用法示例。
在下文中一共展示了Node.find_by_institutions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_object
# 需要导入模块: from website.models import Node [as 别名]
# 或者: from website.models.Node import find_by_institutions [as 别名]
def get_object(self):
inst = self.get_institution()
auth = get_user_auth(self.request)
nodes = [node for node in Node.find_by_institutions(inst, Q('is_registration', 'eq', False) & Q('is_deleted', 'ne', True)) if node.is_public or node.can_view(auth)]
ret = {
'data': nodes,
'self': inst
}
self.check_object_permissions(self.request, ret)
return ret
示例2: create
# 需要导入模块: from website.models import Node [as 别名]
# 或者: from website.models.Node import find_by_institutions [as 别名]
def create(self, validated_data):
inst = self.context['view'].get_object()['self']
user = self.context['request'].user
node_dicts = validated_data['data']
changes_flag = False
for node_dict in node_dicts:
node = Node.load(node_dict['_id'])
if not node:
raise exceptions.NotFound(detail='Node with id "{}" was not found'.format(node_dict['_id']))
if not node.has_permission(user, osf_permissions.WRITE):
raise exceptions.PermissionDenied(detail='Write permission on node {} required'.format(node_dict['_id']))
if inst not in node.affiliated_institutions:
node.add_affiliated_institution(inst, user, save=True)
changes_flag = True
if not changes_flag:
raise RelationshipPostMakesNoChanges
return {
'data': list(Node.find_by_institutions(inst, Q('is_registration', 'eq', False) & Q('is_deleted', 'ne', True))),
'self': inst
}
示例3: main
# 需要导入模块: from website.models import Node [as 别名]
# 或者: from website.models.Node import find_by_institutions [as 别名]
#.........这里部分代码省略.........
'banner_name': 'busara-banner.png',
'logo_name': 'busara-shield.png',
'auth_url': None,
'domains': [],
'email_domains': ['busaracenter.org'],
},
{
'_id': 'cos',
'name': 'Center For Open Science [Test]',
'description': 'COS is a non-profit technology company providing free and open services to increase inclusivity and transparency of research. Find out more at <a href="https://cos.io">cos.io</a>.',
'banner_name': 'cos-banner.png',
'logo_name': 'cos-shield.png',
'auth_url': None,
'domains': ['test-osf.cos.io'],
'email_domains': ['cos.io'],
},
{
'_id': 'esip',
'name': 'Federation of Earth Science Information Partners (ESIP) [Test]',
'description': '<a href="http://www.esipfed.org/">ESIP\'s</a> mission is to support the networking and data dissemination needs of our members and the global Earth science data community by linking the functional sectors of observation, research, application, education and use of Earth science.',
'banner_name': 'esip-banner.png',
'logo_name': 'esip-shield.png',
'auth_url': None,
'domains': [],
'email_domains': ['esipfed.org'],
},
{
'_id': 'nd',
'name': 'University of Notre Dame [Test]',
'description': 'In <a href="https://research.nd.edu/news/64035-notre-dame-center-for-open-science-partner-to-advance-open-science-initiatives/">partnership</a> with the <a href="https://crc.nd.edu">Center for Research Computing</a>, <a href="http://esc.nd.edu">Engineering & Science Computing</a>, and the <a href="https://library.nd.edu">Hesburgh Libraries</a>',
'banner_name': 'nd-banner.png',
'logo_name': 'nd-shield.png',
'auth_url': SHIBBOLETH_SP.format(encode_uri_component('https://login-test.cc.nd.edu/idp/shibboleth')),
'domains': ['test-osf-nd.cos.io'],
'email_domains': [],
},
{
'_id': 'nyu',
'name': 'New York University [Test]',
'description': 'New York University [Test]',
'banner_name': 'nyu-banner.png',
'logo_name': 'nyu-shield.png',
'auth_url': SHIBBOLETH_SP.format(encode_uri_component('https://shibbolethqa.es.its.nyu.edu/idp/shibboleth')),
'domains': ['test-osf-nyu.cos.io'],
'email_domains': [],
},
{
'_id': 'ucr',
'name': 'University of California Riverside [Test]',
'description': 'Policy prohibits storing PII or HIPAA data on this site, please see C&C\'s <a href="http://cnc.ucr.edu/security/researchers.html">security site</a> for more information.',
'banner_name': 'ucr-banner.png',
'logo_name': 'ucr-shield.png',
'auth_url': SHIBBOLETH_SP.format(encode_uri_component('urn:mace:incommon:ucr.edu')),
'domains': ['test-osf-ucr.cos.io'],
'email_domains': [],
},
{
'_id': 'ugent',
'name': 'Universiteit Gent [Test]',
'description': 'Universiteit Gent [Test]',
'banner_name': 'ugent-banner.png',
'logo_name': 'ugent-shield.png',
'auth_url': SHIBBOLETH_SP.format(encode_uri_component('https://identity.ugent.be/simplesaml/saml2/idp/metadata.php')),
'domains': ['test-osf-ugent.cos.io'],
'email_domains': [],
},
{
'_id': 'usc',
'name': 'University of Southern California [Test]',
'description': 'Projects must abide by <a href="http://policy.usc.edu/info-security/">USC\'s Information Security Policy</a>. Data stored for human subject research repositories must abide by <a href="http://policy.usc.edu/biorepositories/">USC\'s Biorepository Policy</a>. The OSF may not be used for storage of Personal Health Information that is subject to <a href="http://policy.usc.edu/hipaa/">HIPPA regulations</a>.',
'banner_name': 'usc-banner.png',
'logo_name': 'usc-shield.png',
'auth_url': SHIBBOLETH_SP.format(encode_uri_component('urn:mace:incommon:usc.edu')),
'domains': ['test-osf-usc.cos.io'],
'email_domains': [],
},
{
'_id': 'uva',
'name': 'University of Virginia [Test]',
'description': 'Projects must abide by the University <a href="http://www.virginia.edu/informationpolicy/security.html">Security and Data Protection Policies</a>',
'banner_name': 'uva-banner.png',
'logo_name': 'uva-shield.png',
'auth_url': SHIBBOLETH_SP.format(encode_uri_component('https://shibidp-test.its.virginia.edu/idp/shibboleth')),
'domains': ['test-osf-virginia.cos.io'],
'email_domains': [],
},
]
init_app(routes=False)
with TokuTransaction():
for inst_data in INSTITUTIONS:
new_inst, inst_created = update_or_create(inst_data)
# update the nodes elastic docs, to have current names of institutions. This will
# only work properly if this file is the only thing changing institution attributes
if not inst_created:
nodes = Node.find_by_institutions(new_inst, query=Q('is_deleted', 'ne', True))
for node in nodes:
update_node(node, async=False)
for extra_inst in Institution.find(Q('_id', 'nin', [x['_id'] for x in INSTITUTIONS])):
logger.warn('Extra Institution : {} - {}'.format(extra_inst._id, extra_inst.name))
示例4: main
# 需要导入模块: from website.models import Node [as 别名]
# 或者: from website.models.Node import find_by_institutions [as 别名]
#.........这里部分代码省略.........
'name': 'Oklahoma State University [Test]',
'description': '<a href="http://www.library.okstate.edu/research-support/research-data-services/">OSU Library Research Data Services</a>',
'banner_name': 'okstate-banner.png',
'logo_name': 'okstate-shield.png',
'auth_url': None, # https://stwcas.okstate.edu/cas/login?service=...
'logout_url': None,
'domains': ['test-osf-library-okstate.cos.io'],
'email_domains': [],
},
{
'_id': 'ucsd',
'name': 'University of California San Diego [Test]',
'description': 'This service is supported on campus by the UC San Diego Library for our research community. Do not use this service to store or transfer personally identifiable information, personal health information, or any other controlled unclassified information. For assistance please contact the Library\'s Research Data Curation Program at <a href="mailto:[email protected]">[email protected]</a>.',
'banner_name': 'ucsd-banner.png',
'logo_name': 'ucsd-shield.png',
'auth_url': SHIBBOLETH_SP_LOGIN.format(encode_uri_component('urn:mace:incommon:ucsd.edu')),
'logout_url': SHIBBOLETH_SP_LOGOUT.format(encode_uri_component('https://test.osf.io/goodbye')),
'domains': ['test-osf-ucsd.cos.io'],
'email_domains': [],
},
{
'_id': 'ucr',
'name': 'University of California Riverside [Test]',
'description': 'Policy prohibits storing PII or HIPAA data on this site, please see C&C\'s <a href="http://cnc.ucr.edu/security/researchers.html">security site</a> for more information.',
'banner_name': 'ucr-banner.png',
'logo_name': 'ucr-shield.png',
'auth_url': SHIBBOLETH_SP_LOGIN.format(encode_uri_component('urn:mace:incommon:ucr.edu')),
'logout_url': SHIBBOLETH_SP_LOGOUT.format(encode_uri_component('https://test.osf.io/goodbye')),
'domains': ['test-osf-ucr.cos.io'],
'email_domains': [],
},
{
'_id': 'ugent',
'name': 'Universiteit Gent [Test]',
'description': 'Universiteit Gent [Test]',
'banner_name': 'ugent-banner.png',
'logo_name': 'ugent-shield.png',
'auth_url': SHIBBOLETH_SP_LOGIN.format(encode_uri_component('https://identity.ugent.be/simplesaml/saml2/idp/metadata.php')),
'logout_url': SHIBBOLETH_SP_LOGOUT.format(encode_uri_component('https://test.osf.io/goodbye')),
'domains': ['test-osf-ugent.cos.io'],
'email_domains': [],
},
{
'_id': 'usc',
'name': 'University of Southern California [Test]',
'description': 'Projects must abide by <a href="http://policy.usc.edu/info-security/">USC\'s Information Security Policy</a>. Data stored for human subject research repositories must abide by <a href="http://policy.usc.edu/biorepositories/">USC\'s Biorepository Policy</a>. The OSF may not be used for storage of Personal Health Information that is subject to <a href="http://policy.usc.edu/hipaa/">HIPPA regulations</a>.',
'banner_name': 'usc-banner.png',
'logo_name': 'usc-shield.png',
'auth_url': SHIBBOLETH_SP_LOGIN.format(encode_uri_component('urn:mace:incommon:usc.edu')),
'logout_url': SHIBBOLETH_SP_LOGOUT.format(encode_uri_component('https://test.osf.io/goodbye')),
'domains': ['test-osf-usc.cos.io'],
'email_domains': [],
},
{
'_id': 'uva',
'name': 'University of Virginia [Test]',
'description': 'In partnership with the <a href="http://www.virginia.edu/vpr/">Vice President for Research</a>, <a href="http://dsi.virginia.edu">Data Science Institute</a>, <a href="https://www.hsl.virginia.edu">Health Sciences Library</a>, and <a href="http://data.library.virginia.edu">University Library</a>. Learn more about <a href="http://cadre.virginia.edu">UVA resources for computational and data-driven research</a>. Projects must abide by the <a href="http://www.virginia.edu/informationpolicy/security.html">University Security and Data Protection Policies</a>.',
'banner_name': 'uva-banner.png',
'logo_name': 'uva-shield.png',
'auth_url': SHIBBOLETH_SP_LOGIN.format(encode_uri_component('https://shibidp-test.its.virginia.edu/idp/shibboleth')),
'logout_url': SHIBBOLETH_SP_LOGOUT.format(encode_uri_component('https://test.osf.io/goodbye')),
'domains': ['test-osf-virginia.cos.io'],
'email_domains': [],
},
{
'_id': 'vcu',
'name': 'Virginia Commonwealth University [Test]',
'description': 'This service is supported by the VCU Libraries and the VCU Office of Research and Innovation for our research community. Do not use this service to store or transfer personally identifiable information (PII), personal health information (PHI), or any other controlled unclassified information (CUI). VCU\'s policy entitled "<a href="http://www.policy.vcu.edu/sites/default/files/Research%20Data%20Ownership,%20Retention,%20Access%20and%20Securty.pdf">Research Data Ownership, Retention, Access and Security</a>" applies. For assistance please contact the <a href="https://www.library.vcu.edu/services/data/">VCU Libraries Research Data Management Program</a>.',
'banner_name': 'vcu-banner.png',
'logo_name': 'vcu-shield.png',
'auth_url': SHIBBOLETH_SP_LOGIN.format(encode_uri_component('https://shibboleth.vcu.edu/idp/shibboleth')),
'logout_url': SHIBBOLETH_SP_LOGOUT.format(encode_uri_component('https://test.osf.io/goodbye')),
'domains': ['test-osf-research-vcu.cos.io'],
'email_domains': [],
},
{
'_id': 'vt',
'name': 'Virginia Tech [Test]',
'description': None,
'banner_name': 'vt-banner.png',
'logo_name': 'vt-shield.png',
'auth_url': SHIBBOLETH_SP_LOGIN.format(encode_uri_component('https://shib-pprd.middleware.vt.edu')),
'logout_url': SHIBBOLETH_SP_LOGOUT.format(encode_uri_component('https://test.osf.io/goodbye')),
'domains': ['osf.vt.edu'],
'email_domains': [],
},
]
init_app(routes=False)
with TokuTransaction():
for inst_data in INSTITUTIONS:
new_inst, inst_created = update_or_create(inst_data)
# update the nodes elastic docs, to have current names of institutions. This will
# only work properly if this file is the only thing changing institution attributes
if not inst_created:
nodes = Node.find_by_institutions(new_inst, query=Q('is_deleted', 'ne', True))
for node in nodes:
update_node(node, async=False)
for extra_inst in Institution.find(Q('_id', 'nin', [x['_id'] for x in INSTITUTIONS])):
logger.warn('Extra Institution : {} - {}'.format(extra_inst._id, extra_inst.name))
示例5: get_events
# 需要导入模块: from website.models import Node [as 别名]
# 或者: from website.models.Node import find_by_institutions [as 别名]
def get_events(self, date):
super(InstitutionSummary, self).get_events(date)
institutions = self.get_institutions()
counts = []
# Convert to a datetime at midnight for queries and the timestamp
timestamp_datetime = datetime(date.year, date.month, date.day).replace(tzinfo=pytz.UTC)
query_datetime = timestamp_datetime + timedelta(1)
for institution in institutions:
user_query = Q('_affiliated_institutions', 'eq', institution.node)
node_query = (
Q('is_deleted', 'ne', True) &
Q('is_folder', 'ne', True) &
Q('date_created', 'lt', query_datetime)
)
registration_query = node_query & Q('is_registration', 'eq', True)
non_registration_query = node_query & Q('is_registration', 'eq', False)
project_query = non_registration_query & Q('parent_node', 'eq', None)
registered_project_query = registration_query & Q('parent_node', 'eq', None)
public_query = Q('is_public', 'eq', True)
private_query = Q('is_public', 'eq', False)
node_public_query = non_registration_query & public_query
node_private_query = non_registration_query & private_query
project_public_query = project_query & public_query
project_private_query = project_query & private_query
registered_node_public_query = registration_query & public_query
registered_node_private_query = registration_query & private_query
registered_project_public_query = registered_project_query & public_query
registered_project_private_query = registered_project_query & private_query
count = {
'institution':{
'id': institution._id,
'name': institution.name,
},
'users': {
'total': User.find(user_query).count(),
},
'nodes': {
'total':Node.find_by_institutions(institution, node_query).count(),
'public': Node.find_by_institutions(institution, node_public_query).count(),
'private': Node.find_by_institutions(institution, node_private_query).count(),
},
'projects': {
'total': Node.find_by_institutions(institution, project_query).count(),
'public': Node.find_by_institutions(institution, project_public_query).count(),
'private': Node.find_by_institutions(institution, project_private_query).count(),
},
'registered_nodes': {
'total': Node.find_by_institutions(institution, registration_query).count(),
'public': Node.find_by_institutions(institution, registered_node_public_query).count(),
'embargoed': Node.find_by_institutions(institution, registered_node_private_query).count(),
},
'registered_projects': {
'total': Node.find_by_institutions(institution, registered_project_query).count(),
'public': Node.find_by_institutions(institution, registered_project_public_query).count(),
'embargoed': Node.find_by_institutions(institution, registered_project_private_query).count(),
},
'keen': {
'timestamp': timestamp_datetime.isoformat()
}
}
logger.info(
'{} Nodes counted. Nodes: {}, Projects: {}, Registered Nodes: {}, Registered Projects: {}'.format(
count['institution']['name'],
count['nodes']['total'],
count['projects']['total'],
count['registered_nodes']['total'],
count['registered_projects']['total']
)
)
counts.append(count)
return counts