当前位置: 首页>>代码示例>>Python>>正文


Python DraftRegistration.find方法代码示例

本文整理汇总了Python中website.project.model.DraftRegistration.find方法的典型用法代码示例。如果您正苦于以下问题:Python DraftRegistration.find方法的具体用法?Python DraftRegistration.find怎么用?Python DraftRegistration.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在website.project.model.DraftRegistration的用法示例。


在下文中一共展示了DraftRegistration.find方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_queryset

# 需要导入模块: from website.project.model import DraftRegistration [as 别名]
# 或者: from website.project.model.DraftRegistration import find [as 别名]
 def get_queryset(self):
     query = (
         Q('registration_schema', 'eq', get_prereg_schema()) &
         Q('approval', 'ne', None)
     )
     ordering = self.get_ordering()
     if 'initiator' in ordering:
         return DraftRegistration.find(query).sort(ordering)
     if ordering == SORT_BY['title']:
         return DraftRegistration.find(query).sort(
             'registration_metadata.q1.value')
     if ordering == SORT_BY['n_title']:
         return DraftRegistration.find(query).sort(
             '-registration_metadata.q1.value')
     return sort_drafts(DraftRegistration.find(query), ordering)
开发者ID:caspinelli,项目名称:osf.io,代码行数:17,代码来源:views.py

示例2: get_draft_obj

# 需要导入模块: from website.project.model import DraftRegistration [as 别名]
# 或者: from website.project.model.DraftRegistration import find [as 别名]
def get_draft_obj(draft_pk):
	auth = Auth(adminUser)
	
	draft = DraftRegistration.find(
        Q('_id', 'eq', draft_pk)
    )

	return draft[0], auth
开发者ID:Ghalko,项目名称:COS-Admin-Interface,代码行数:10,代码来源:database.py

示例3: get_draft

# 需要导入模块: from website.project.model import DraftRegistration [as 别名]
# 或者: from website.project.model.DraftRegistration import find [as 别名]
def get_draft(draft_pk):
	auth = Auth(adminUser)
	
	draft = DraftRegistration.find(
        Q('_id', 'eq', draft_pk)
    )

	return utils.serialize_draft_registration(draft[0], auth), http.OK
开发者ID:samchrisinger,项目名称:COS-Admin-Interface,代码行数:10,代码来源:database.py

示例4: get_all_drafts

# 需要导入模块: from website.project.model import DraftRegistration [as 别名]
# 或者: from website.project.model.DraftRegistration import find [as 别名]
def get_all_drafts():
	# TODO[lauren]: add query parameters to only retrieve submitted drafts, they will have an approval associated with them
	all_drafts = DraftRegistration.find()

	auth = Auth(adminUser)

	serialized_drafts = {
		'drafts': [utils.serialize_draft_registration(d, auth) for d in all_drafts]
	}
	return serialized_drafts
开发者ID:Ghalko,项目名称:COS-Admin-Interface,代码行数:12,代码来源:database.py

示例5: get_queryset

# 需要导入模块: from website.project.model import DraftRegistration [as 别名]
# 或者: from website.project.model.DraftRegistration import find [as 别名]
 def get_queryset(self):
     prereg_schema = MetaSchema.find_one(
         Q('name', 'eq', 'Prereg Challenge') &
         Q('schema_version', 'eq', 2)
     )
     query = (
         Q('registration_schema', 'eq', prereg_schema) &
         Q('approval', 'ne', None)
     )
     return DraftRegistration.find(query).sort(self.ordering)
开发者ID:545zhou,项目名称:osf.io,代码行数:12,代码来源:views.py

示例6: main

# 需要导入模块: from website.project.model import DraftRegistration [as 别名]
# 或者: from website.project.model.DraftRegistration import find [as 别名]
def main(dry_run=True):
    if dry_run:
        logger.warn('DRY RUN mode')
    pending_approval_drafts = DraftRegistration.find()
    need_approval_drafts = [draft for draft in pending_approval_drafts
                            if draft.approval and draft.requires_approval and draft.approval.state == Sanction.UNAPPROVED]

    for draft in need_approval_drafts:
        sanction = draft.approval
        try:
            if not dry_run:
                sanction.state = Sanction.APPROVED
                sanction._on_complete(None)
                sanction.save()
            logger.warn('Approved {0}'.format(draft._id))
        except Exception as e:
            logger.error(e)
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:19,代码来源:approve_draft_registrations.py

示例7: get_prereg_drafts

# 需要导入模块: from website.project.model import DraftRegistration [as 别名]
# 或者: from website.project.model.DraftRegistration import find [as 别名]
def get_prereg_drafts(user=None, filters=tuple()):
    prereg_schema = MetaSchema.find_one(
        Q('name', 'eq', 'Prereg Challenge') &
        Q('schema_version', 'eq', 2)
    )
    query = (
        Q('registration_schema', 'eq', prereg_schema) &
        Q('approval', 'ne', None)
    )
    if user:
        pass
        # TODO: filter by assignee; this requires multiple levels of Prereg admins-
        # one level that can see all drafts, and another than can see only the ones they're assigned.
        # As a followup to this, we need to make sure this applies to approval/rejection/commenting endpoints
        # query = query & Q('_metaschema_flags.assignee', 'eq', user._id)
    return sorted(
        DraftRegistration.find(query),
        key=operator.attrgetter('approval.initiation_date')
    )
开发者ID:DanielSBrown,项目名称:osf.io,代码行数:21,代码来源:views.py

示例8: main

# 需要导入模块: from website.project.model import DraftRegistration [as 别名]
# 或者: from website.project.model.DraftRegistration import find [as 别名]
def main(dry_run=True):
    if dry_run:
        logger.warn('DRY RUN mode')
    pending_approval_drafts = DraftRegistration.find()
    need_approval_drafts = [draft for draft in pending_approval_drafts
                            if draft.requires_approval and draft.approval and draft.approval.state == Sanction.UNAPPROVED]

    for draft in need_approval_drafts:
        add_comments(draft)
        sanction = draft.approval
        try:
            if not dry_run:
                sanction.forcibly_reject()
                #manually do the on_reject functionality to prevent send_mail problems
                sanction.meta = {}
                sanction.save()
                draft.approval = None
                draft.save()
            logger.warn('Rejected {0}'.format(draft._id))
        except Exception as e:
            logger.error(e)
开发者ID:adlius,项目名称:osf.io,代码行数:23,代码来源:reject_draft_registrations.py

示例9: check_access

# 需要导入模块: from website.project.model import DraftRegistration [as 别名]
# 或者: from website.project.model.DraftRegistration import find [as 别名]
def check_access(node, auth, action, cas_resp):
    """Verify that user can perform requested action on resource. Raise appropriate
    error code if action cannot proceed.
    """
    permission = permission_map.get(action, None)
    if permission is None:
        raise HTTPError(httplib.BAD_REQUEST)

    if cas_resp:
        if permission == 'read':
            if node.is_public:
                return True
            required_scope = oauth_scopes.CoreScopes.NODE_FILE_READ
        else:
            required_scope = oauth_scopes.CoreScopes.NODE_FILE_WRITE
        if not cas_resp.authenticated \
           or required_scope not in oauth_scopes.normalize_scopes(cas_resp.attributes['accessTokenScope']):
            raise HTTPError(httplib.FORBIDDEN)

    if permission == 'read' and node.can_view(auth):
        return True
    if permission == 'write' and node.can_edit(auth):
        return True

    # Users attempting to register projects with components might not have
    # `write` permissions for all components. This will result in a 403 for
    # all `copyto` actions as well as `copyfrom` actions if the component
    # in question is not public. To get around this, we have to recursively
    # check the node's parent node to determine if they have `write`
    # permissions up the stack.
    # TODO(hrybacki): is there a way to tell if this is for a registration?
    # All nodes being registered that receive the `copyto` action will have
    # `node.is_registration` == True. However, we have no way of telling if
    # `copyfrom` actions are originating from a node being registered.
    # TODO This is raise UNAUTHORIZED for registrations that have not been archived yet
    if action == 'copyfrom' or (action == 'copyto' and node.is_registration):
        parent = node.parent_node
        while parent:
            if parent.can_edit(auth):
                return True
            parent = parent.parent_node

    # Users with the PREREG_ADMIN_TAG should be allowed to download files
    # from prereg challenge draft registrations.
    try:
        prereg_schema = MetaSchema.find_one(
            Q('name', 'eq', 'Prereg Challenge') &
            Q('schema_version', 'eq', 2)
        )
        allowed_nodes = [node] + node.parents
        prereg_draft_registration = DraftRegistration.find(
            Q('branched_from', 'in', [n._id for n in allowed_nodes]) &
            Q('registration_schema', 'eq', prereg_schema)
        )
        if action == 'download' and \
                    auth.user is not None and \
                    prereg_draft_registration.count() > 0 and \
                    settings.PREREG_ADMIN_TAG in auth.user.system_tags:
            return True
    except NoResultsFound:
        pass

    raise HTTPError(httplib.FORBIDDEN if auth.user else httplib.UNAUTHORIZED)
开发者ID:kms6bn,项目名称:osf.io,代码行数:65,代码来源:views.py


注:本文中的website.project.model.DraftRegistration.find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。