• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python model.has_anonymous_link函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_node_contributors_abbrev

def get_node_contributors_abbrev(auth, node, **kwargs):
    anonymous = has_anonymous_link(node, auth)
    formatter = "surname"
    max_count = kwargs.get("max_count", 3)
    if "user_ids" in kwargs:
        users = [User.load(user_id) for user_id in kwargs["user_ids"] if user_id in node.visible_contributor_ids]
    else:
        users = node.visible_contributors

    if anonymous or not node.can_view(auth):
        raise HTTPError(http.FORBIDDEN)

    contributors = []

    n_contributors = len(users)
    others_count = ""

    for index, user in enumerate(users[:max_count]):

        if index == max_count - 1 and len(users) > max_count:
            separator = " &"
            others_count = str(n_contributors - 3)
        elif index == len(users) - 1:
            separator = ""
        elif index == len(users) - 2:
            separator = " &"
        else:
            separator = ","
        contributor = user.get_summary(formatter)
        contributor["user_id"] = user._primary_key
        contributor["separator"] = separator

        contributors.append(contributor)

    return {"contributors": contributors, "others_count": others_count}
开发者ID:cslzchen,项目名称:osf.io,代码行数:35,代码来源:contributor.py


示例2: _get_summary

def _get_summary(node, auth, rescale_ratio, primary=True, link_id=None, show_path=False):
    # TODO(sloria): Refactor this or remove (lots of duplication with _view_project)
    summary = {
        'id': link_id if link_id else node._id,
        'primary': primary,
        'is_registration': node.is_registration,
        'is_fork': node.is_fork,
        'is_pending_registration': node.is_pending_registration,
        'is_retracted': node.is_retracted,
        'is_pending_retraction': node.is_pending_retraction,
        'embargo_end_date': node.embargo_end_date.strftime("%A, %b. %d, %Y") if node.embargo_end_date else False,
        'is_pending_embargo': node.is_pending_embargo,
        'archiving': node.archiving,
    }

    if node.can_view(auth):
        summary.update({
            'can_view': True,
            'can_edit': node.can_edit(auth),
            'primary_id': node._id,
            'url': node.url,
            'primary': primary,
            'api_url': node.api_url,
            'title': node.title,
            'category': node.category,
            'node_type': node.project_or_component,
            'is_fork': node.is_fork,
            'is_registration': node.is_registration,
            'anonymous': has_anonymous_link(node, auth),
            'registered_date': node.registered_date.strftime('%Y-%m-%d %H:%M UTC')
            if node.is_registration
            else None,
            'forked_date': node.forked_date.strftime('%Y-%m-%d %H:%M UTC')
            if node.is_fork
            else None,
            'nlogs': None,
            'ua_count': None,
            'ua': None,
            'non_ua': None,
            'addons_enabled': node.get_addon_names(),
            'is_public': node.is_public,
            'parent_title': node.parent_node.title if node.parent_node else None,
            'parent_is_public': node.parent_node.is_public if node.parent_node else False,
            'show_path': show_path
        })
        if rescale_ratio:
            ua_count, ua, non_ua = _get_user_activity(node, auth, rescale_ratio)
            summary.update({
                'nlogs': len(node.logs),
                'ua_count': ua_count,
                'ua': ua,
                'non_ua': non_ua,
            })
    else:
        summary['can_view'] = False

    # TODO: Make output format consistent with _view_project
    return {
        'summary': summary,
    }
开发者ID:rmoorman,项目名称:osf.io,代码行数:60,代码来源:node.py


示例3: get_contributors

def get_contributors(auth, node, **kwargs):

    # Can set limit to only receive a specified number of contributors in a call to this route
    if request.args.get('limit'):
        try:
            limit = int(request.args['limit'])
        except ValueError:
            raise HTTPError(http.BAD_REQUEST, data=dict(
                message_long='Invalid value for "limit": {}'.format(request.args['limit'])
            ))
    else:
        limit = None

    anonymous = has_anonymous_link(node, auth)

    if anonymous or not node.can_view(auth):
        raise HTTPError(http.FORBIDDEN)

    # Limit is either an int or None:
    # if int, contribs list is sliced to specified length
    # if None, contribs list is not sliced
    contribs = profile_utils.serialize_contributors(
        node.visible_contributors[0:limit],
        node=node,
    )

    # Will either return just contributor list or contributor list + 'more' element
    if limit:
        return {
            'contributors': contribs,
            'more': max(0, len(node.visible_contributors) - limit)
        }
    else:
        return {'contributors': contribs}
开发者ID:caspinelli,项目名称:osf.io,代码行数:34,代码来源:contributor.py


示例4: _get_logs

def _get_logs(node, count, auth, link=None, page=0):
    """

    :param Node node:
    :param int count:
    :param auth:
    :return list: List of serialized logs,
            boolean: if there are more logs

    """
    logs = []
    total = 0
    for log in reversed(node.logs):
        # A number of errors due to database inconsistency can arise here. The
        # log can be None; its `node__logged` back-ref can be empty, and the
        # 0th logged node can be None. Need to make sure that log is not None
        if log:
            log_node = log.resolve_node(node)
            if log.can_view(node, auth):
                total += 1
                anonymous = has_anonymous_link(log_node, auth)
                logs.append(serialize_log(log, anonymous))
        else:
            logger.warn('Log on node {} is None'.format(node._id))

    paginated_logs, pages = paginate(logs, total, page, count)

    return list(paginated_logs), total, pages
开发者ID:KerryKDiehl,项目名称:osf.io,代码行数:28,代码来源:log.py


示例5: node_register_template_page

def node_register_template_page(auth, node, metaschema_id, **kwargs):
    if node.is_registration and bool(node.registered_schema):
        try:
            meta_schema = RegistrationSchema.objects.get(_id=metaschema_id)
        except RegistrationSchema.DoesNotExist:
            # backwards compatability for old urls, lookup by name
            meta_schema = RegistrationSchema.objects.filter(name=_id_to_name(metaschema_id)).order_by('-schema_version').first()
            if not meta_schema:
                raise HTTPError(http.NOT_FOUND, data={
                    'message_short': 'Invalid schema name',
                    'message_long': 'No registration schema with that name could be found.'
                })
        if not node.registered_schema.filter(id=meta_schema.id).exists():
            raise HTTPError(http.BAD_REQUEST, data={
                'message_short': 'Invalid schema',
                'message_long': 'This registration has no registration supplment with that name.'
            })

        ret = _view_project(node, auth, primary=True)
        my_meta = serialize_meta_schema(meta_schema)
        if has_anonymous_link(node, auth):
            for indx, schema_page in enumerate(my_meta['schema']['pages']):
                for idx, schema_question in enumerate(schema_page['questions']):
                    if schema_question['title'] in settings.ANONYMIZED_TITLES:
                        del my_meta['schema']['pages'][indx]['questions'][idx]
        ret['node']['registered_schema'] = serialize_meta_schema(meta_schema)
        return ret
    else:
        status.push_status_message(
            'You have been redirected to the project\'s registrations page. From here you can initiate a new Draft Registration to complete the registration process',
            trust=False,
            id='redirected_to_registrations',
        )
        return redirect(node.web_url_for('node_registrations', view=kwargs.get('template'), _guid=True))
开发者ID:aaxelb,项目名称:osf.io,代码行数:34,代码来源:register.py


示例6: _get_logs

def _get_logs(node, count, auth, link=None, offset=0):
    """

    :param Node node:
    :param int count:
    :param auth:
    :return list: List of serialized logs,
            boolean: if there are more logs

    """
    logs = []
    has_more_logs = False
    for log in (x for idx, x in enumerate(reversed(node.logs)) if idx >= offset):
        # A number of errors due to database inconsistency can arise here. The
        # log can be None; its `node__logged` back-ref can be empty, and the
        # 0th logged node can be None. Catch and log these errors and ignore
        # the offending logs.
        log_node = log.resolve_node(node)
        if log.can_view(node, auth):
            anonymous = has_anonymous_link(log_node, auth)
            if len(logs) < count:
                logs.append(serialize_log(log, anonymous))
            else:
                has_more_logs = True
                break
    return logs, has_more_logs
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:26,代码来源:log.py


示例7: osf_storage_get_revisions

def osf_storage_get_revisions(payload, node_addon, **kwargs):
    node = node_addon.owner
    page = payload.get('page') or 0
    path = payload.get('path')
    is_anon = has_anonymous_link(node, Auth(private_key=payload.get('view_only')))

    if not path:
        raise HTTPError(httplib.BAD_REQUEST)

    try:
        page = int(page)
    except (TypeError, ValueError):
        raise HTTPError(httplib.BAD_REQUEST)

    record = model.OsfStorageFileRecord.find_by_path(path, node_addon)

    if record is None:
        raise HTTPError(httplib.NOT_FOUND)

    indices, versions, more = record.get_versions(
        page,
        size=osf_storage_settings.REVISIONS_PAGE_SIZE,
    )

    return {
        'revisions': [
            utils.serialize_revision(node, record, versions[idx], indices[idx], anon=is_anon)
            for idx in range(len(versions))
        ],
        'more': more,
    }
开发者ID:crystallss,项目名称:osf.io,代码行数:31,代码来源:views.py


示例8: dataverse_get_file_info

def dataverse_get_file_info(node_addon, auth, **kwargs):
    """API view that gets info for a file."""
    node = node_addon.owner
    file_id = kwargs.get('path')

    fail_if_unauthorized(node_addon, auth, file_id)
    fail_if_private(file_id)

    anonymous = has_anonymous_link(node, auth)

    download_url = node.web_url_for('dataverse_download_file', path=file_id)
    dataverse_url = 'http://{0}/dvn/dv/'.format(HOST) + node_addon.dataverse_alias
    study_url = 'http://dx.doi.org/' + node_addon.study_hdl
    delete_url = node.api_url_for('dataverse_delete_file', path=file_id)

    data = {
        'node': {
            'id': node._id,
            'title': node.title
        },
        'filename': scrape_dataverse(file_id, name_only=True)[0],
        'dataverse': privacy_info_handle(node_addon.dataverse, anonymous),
        'study': privacy_info_handle(node_addon.study, anonymous),
        'urls': {
            'dataverse': privacy_info_handle(dataverse_url, anonymous),
            'study': privacy_info_handle(study_url, anonymous),
            'download': privacy_info_handle(download_url, anonymous),
            'delete': privacy_info_handle(delete_url, anonymous),
            'files': node.web_url_for('collect_file_trees'),
        }
    }

    return {'data': data}, httplib.OK
开发者ID:lbanner,项目名称:osf.io,代码行数:33,代码来源:crud.py


示例9: comment_discussion

def comment_discussion(auth, node, **kwargs):

    users = collect_discussion(node)
    anonymous = has_anonymous_link(node, auth)
    # Sort users by comment frequency
    # TODO: Allow sorting by recency, combination of frequency and recency
    sorted_users = sorted(
        users.keys(),
        key=lambda item: len(users[item]),
        reverse=True,
    )

    return {
        'discussion': [
            {
                'id': privacy_info_handle(user._id, anonymous),
                'url': privacy_info_handle(user.url, anonymous),
                'fullname': privacy_info_handle(user.fullname, anonymous, name=True),
                'isContributor': node.is_contributor(user),
                'gravatarUrl': privacy_info_handle(
                    gravatar(
                        user, use_ssl=True, size=settings.GRAVATAR_SIZE_DISCUSSION,
                    ),
                    anonymous
                ),

            }
            for user in sorted_users
        ]
    }
开发者ID:sbt9uc,项目名称:osf.io,代码行数:30,代码来源:comment.py


示例10: serialize_node_summary

def serialize_node_summary(node, auth, primary=True, show_path=False):
    summary = {
        'id': node._id,
        'primary': primary,
        'is_registration': node.is_registration,
        'is_fork': node.is_fork,
        'is_pending_registration': node.is_pending_registration,
        'is_retracted': node.is_retracted,
        'is_pending_retraction': node.is_pending_retraction,
        'embargo_end_date': node.embargo_end_date.strftime('%A, %b. %d, %Y') if node.embargo_end_date else False,
        'is_pending_embargo': node.is_pending_embargo,
        'is_embargoed': node.is_embargoed,
        'archiving': node.archiving,
    }
    contributor_data = serialize_contributors_for_summary(node)

    parent_node = node.parent_node
    user = auth.user
    if node.can_view(auth):
        summary.update({
            'can_view': True,
            'can_edit': node.can_edit(auth),
            'primary_id': node._id,
            'url': node.url,
            'primary': primary,
            'api_url': node.api_url,
            'title': node.title,
            'category': node.category,
            'isPreprint': bool(node.preprint_file_id),
            'childExists': bool(node.nodes_active),
            'is_admin': node.has_permission(user, permissions.ADMIN),
            'is_contributor': node.is_contributor(user),
            'logged_in': auth.logged_in,
            'node_type': node.project_or_component,
            'is_fork': node.is_fork,
            'is_registration': node.is_registration,
            'anonymous': has_anonymous_link(node, auth),
            'registered_date': node.registered_date.strftime('%Y-%m-%d %H:%M UTC')
            if node.is_registration
            else None,
            'forked_date': node.forked_date.strftime('%Y-%m-%d %H:%M UTC')
            if node.is_fork
            else None,
            'ua_count': None,
            'ua': None,
            'non_ua': None,
            'is_public': node.is_public,
            'parent_title': parent_node.title if parent_node else None,
            'parent_is_public': parent_node.is_public if parent_node else False,
            'show_path': show_path,
            # Read nlogs annotation if possible
            'nlogs': node.nlogs if hasattr(node, 'nlogs') else node.logs.count(),
            'contributors': contributor_data['contributors'],
            'others_count': contributor_data['others_count'],
        })
    else:
        summary['can_view'] = False

    return summary
开发者ID:adlius,项目名称:osf.io,代码行数:59,代码来源:views.py


示例11: osfstorage_get_revisions

def osfstorage_get_revisions(file_node, node_addon, payload, **kwargs):
    is_anon = has_anonymous_link(node_addon.owner, Auth(private_key=request.args.get('view_only')))

    # Return revisions in descending order
    return {
        'revisions': [
            utils.serialize_revision(node_addon.owner, file_node, version, index=len(file_node.versions) - idx - 1, anon=is_anon)
            for idx, version in enumerate(reversed(file_node.versions))
        ]
    }
开发者ID:545zhou,项目名称:osf.io,代码行数:10,代码来源:views.py


示例12: file_info

def file_info(auth, fid, **kwargs):
    versions = []
    node = kwargs['node'] or kwargs['project']
    file_name = fid
    file_name_clean = urlsafe_filename(file_name)
    files_page_url = node.web_url_for('collect_file_trees')
    latest_download_url = None
    api_url = None
    anonymous = has_anonymous_link(node, auth)

    try:
        files_versions = node.files_versions[file_name_clean]
    except KeyError:
        raise HTTPError(http.NOT_FOUND)
    latest_version_number = get_latest_version_number(file_name_clean, node) + 1

    for idx, version in enumerate(list(reversed(files_versions))):
        node_file = NodeFile.load(version)
        number = len(files_versions) - idx
        unique, total = get_basic_counters('download:{}:{}:{}'.format(
            node._primary_key,
            file_name_clean,
            number,
        ))
        download_url = node_file.download_url(node)
        api_url = node_file.api_url(node)
        versions.append({
            'file_name': file_name,
            'download_url': download_url,
            'version_number': number,
            'display_number': number if idx > 0 else 'current',
            'modified_date': node_file.date_uploaded.strftime('%Y/%m/%d %I:%M %p'),
            'downloads': total if total else 0,
            'committer_name': privacy_info_handle(
                node_file.uploader.fullname, anonymous, name=True
            ),
            'committer_url': privacy_info_handle(node_file.uploader.url, anonymous),
        })
        if number == latest_version_number:
            latest_download_url = download_url
    return {
        'node_title': node.title,
        'file_name': file_name,
        'versions': versions,
        'registered': node.is_registration,
        'urls': {
            'api': api_url,
            'files': files_page_url,
            'latest': {
                'download': latest_download_url,
            },
        }
    }
开发者ID:lbanner,项目名称:osf.io,代码行数:53,代码来源:views.py


示例13: _get_summary

def _get_summary(node, auth, rescale_ratio, primary=True, link_id=None, show_path=False):
    # TODO(sloria): Refactor this or remove (lots of duplication with _view_project)
    summary = {
        "id": link_id if link_id else node._id,
        "primary": primary,
        "is_registration": node.is_registration,
        "is_fork": node.is_fork,
        "is_pending_registration": node.is_pending_registration,
        "is_retracted": node.is_retracted,
        "is_pending_retraction": node.is_pending_retraction,
        "embargo_end_date": node.embargo_end_date.strftime("%A, %b. %d, %Y") if node.embargo_end_date else False,
        "is_pending_embargo": node.is_pending_embargo,
        "archiving": node.archiving,
    }

    if node.can_view(auth):
        summary.update(
            {
                "can_view": True,
                "can_edit": node.can_edit(auth),
                "primary_id": node._id,
                "url": node.url,
                "primary": primary,
                "api_url": node.api_url,
                "title": node.title,
                "category": node.category,
                "node_type": node.project_or_component,
                "is_fork": node.is_fork,
                "is_registration": node.is_registration,
                "anonymous": has_anonymous_link(node, auth),
                "registered_date": node.registered_date.strftime("%Y-%m-%d %H:%M UTC")
                if node.is_registration
                else None,
                "forked_date": node.forked_date.strftime("%Y-%m-%d %H:%M UTC") if node.is_fork else None,
                "nlogs": None,
                "ua_count": None,
                "ua": None,
                "non_ua": None,
                "addons_enabled": node.get_addon_names(),
                "is_public": node.is_public,
                "parent_title": node.parent_node.title if node.parent_node else None,
                "parent_is_public": node.parent_node.is_public if node.parent_node else False,
                "show_path": show_path,
            }
        )
        if rescale_ratio:
            ua_count, ua, non_ua = _get_user_activity(node, auth, rescale_ratio)
            summary.update({"nlogs": len(node.logs), "ua_count": ua_count, "ua": ua, "non_ua": non_ua})
    else:
        summary["can_view"] = False

    # TODO: Make output format consistent with _view_project
    return {"summary": summary}
开发者ID:Alpani,项目名称:osf.io,代码行数:53,代码来源:node.py


示例14: list_comments

def list_comments(auth, node, **kwargs):
    anonymous = has_anonymous_link(node, auth)
    guid = request.args.get('target')
    target = resolve_target(node, guid)
    serialized_comments = serialize_comments(target, auth, anonymous)
    n_unread = 0

    if node.is_contributor(auth.user):
        if auth.user.comments_viewed_timestamp is None:
            auth.user.comments_viewed_timestamp = {}
            auth.user.save()
        n_unread = n_unread_comments(target, auth.user)
    return {
        'comments': serialized_comments,
        'nUnread': n_unread
    }
开发者ID:sbt9uc,项目名称:osf.io,代码行数:16,代码来源:comment.py


示例15: osf_storage_get_revisions

def osf_storage_get_revisions(payload, node_addon, **kwargs):
    node = node_addon.owner
    path = payload.get('path')
    is_anon = has_anonymous_link(node, Auth(private_key=payload.get('view_only')))

    if not path:
        raise HTTPError(httplib.BAD_REQUEST)

    record = model.OsfStorageFileNode.get(path.strip('/'), node_addon)

    # Return revisions in descending order
    return {
        'revisions': [
            utils.serialize_revision(node, record, version, index=len(record.versions) - idx - 1, anon=is_anon)
            for idx, version in enumerate(reversed(record.versions))
        ]
    }
开发者ID:erinmayhood,项目名称:osf.io,代码行数:17,代码来源:views.py


示例16: get_node_contributors_abbrev

def get_node_contributors_abbrev(auth, **kwargs):
    node = kwargs['node'] or kwargs['project']

    anonymous = has_anonymous_link(node, auth)

    max_count = kwargs.get('max_count', 3)
    if 'user_ids' in kwargs:
        users = [
            User.load(user_id) for user_id in kwargs['user_ids']
            if user_id in node.visible_contributor_ids
        ]
    else:
        users = node.visible_contributors

    if anonymous or not node.can_view(auth):
        raise HTTPError(http.FORBIDDEN)

    contributors = []

    n_contributors = len(users)
    others_count = ''

    for index, user in enumerate(users[:max_count]):

        if index == max_count - 1 and len(users) > max_count:
            separator = '&nbsp;&'
            others_count = str(n_contributors - 3)
        elif index == len(users) - 1:
            separator = ''
        elif index == len(users) - 2:
            separator = '&nbsp&'
        else:
            separator = ','

        contributors.append({
            'user_id': user._primary_key,
            'separator': separator,
        })

    return {
        'contributors': contributors,
        'others_count': others_count,
    }
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:43,代码来源:contributor.py


示例17: _get_logs

def _get_logs(node, count, auth, link=None, page=0):
    """

    :param Node node:
    :param int count:
    :param auth:
    :return list: List of serialized logs,
            boolean: if there are more logs

    """
    logs_set = node.get_aggregate_logs_queryset(auth)
    total = len(logs_set)
    start = page * count
    stop = start + count
    logs = [
        serialize_log(log, auth=auth, anonymous=has_anonymous_link(node, auth))
        for log in logs_set[start:stop]
    ]
    pages = math.ceil(total / float(count))
    return logs, total, pages
开发者ID:erinmayhood,项目名称:osf.io,代码行数:20,代码来源:log.py


示例18: get_node_contributors_abbrev

def get_node_contributors_abbrev(auth, node, **kwargs):
    anonymous = has_anonymous_link(node, auth)
    formatter = 'surname'
    max_count = kwargs.get('max_count', 3)
    if 'user_ids' in kwargs:
        users = [
            User.load(user_id) for user_id in kwargs['user_ids']
            if user_id in node.visible_contributor_ids
        ]
    else:
        users = node.visible_contributors

    if anonymous or not node.can_view(auth):
        raise HTTPError(http.FORBIDDEN)

    contributors = []

    n_contributors = len(users)
    others_count = ''

    for index, user in enumerate(users[:max_count]):

        if index == max_count - 1 and len(users) > max_count:
            separator = ' &'
            others_count = str(n_contributors - 3)
        elif index == len(users) - 1:
            separator = ''
        elif index == len(users) - 2:
            separator = ' &'
        else:
            separator = ','
        contributor = user.get_summary(formatter)
        contributor['user_id'] = user._primary_key
        contributor['separator'] = separator

        contributors.append(contributor)

    return {
        'contributors': contributors,
        'others_count': others_count,
    }
开发者ID:caspinelli,项目名称:osf.io,代码行数:41,代码来源:contributor.py


示例19: osfstorage_get_revisions

def osfstorage_get_revisions(file_node, node_addon, payload, **kwargs):
    from osf.models import PageCounter, FileVersion  # TODO Fix me onces django works
    is_anon = has_anonymous_link(node_addon.owner, Auth(private_key=request.args.get('view_only')))

    counter_prefix = 'download:{}:{}:'.format(file_node.node._id, file_node._id)

    version_count = file_node.versions.count()
    # Don't worry. The only % at the end of the LIKE clause, the index is still used
    counts = dict(PageCounter.objects.filter(_id__startswith=counter_prefix).values_list('_id', 'total'))
    qs = FileVersion.includable_objects.filter(basefilenode__id=file_node.id).include('creator__guids').order_by('-created')

    for i, version in enumerate(qs):
        version._download_count = counts.get('{}{}'.format(counter_prefix, version_count - i - 1), 0)

    # Return revisions in descending order
    return {
        'revisions': [
            utils.serialize_revision(node_addon.owner, file_node, version, index=version_count - idx - 1, anon=is_anon)
            for idx, version in enumerate(qs)
        ]
    }
开发者ID:geeksnglitter,项目名称:osf.io,代码行数:21,代码来源:views.py


示例20: node_register_template_page

def node_register_template_page(auth, node, metaschema_id, **kwargs):
    if node.is_registration and bool(node.registered_schema):
        try:
            meta_schema = MetaSchema.find_one(
                Q('_id', 'eq', metaschema_id)
            )
        except NoResultsFound:
            # backwards compatability for old urls, lookup by name
            try:
                meta_schema = MetaSchema.find(
                    Q('name', 'eq', _id_to_name(metaschema_id))
                ).sort('-schema_version')[0]
            except IndexError:
                raise HTTPError(http.NOT_FOUND, data={
                    'message_short': 'Invalid schema name',
                    'message_long': 'No registration schema with that name could be found.'
                })
        if meta_schema not in node.registered_schema:
            raise HTTPError(http.BAD_REQUEST, data={
                'message_short': 'Invalid schema',
                'message_long': 'This registration has no registration supplment with that name.'
            })

        ret = _view_project(node, auth, primary=True)
        my_meta = serialize_meta_schema(meta_schema)
        if has_anonymous_link(node, auth):
            for indx, schema_page in enumerate(my_meta['schema']['pages']):
                for idx, schema_question in enumerate(schema_page['questions']):
                    if schema_question['title'] in settings.ANONYMIZED_TITLES:
                        del my_meta['schema']['pages'][indx]['questions'][idx]
        ret['node']['registered_schema'] = serialize_meta_schema(meta_schema)
        return ret
    else:
        status.push_status_message(
            'You have been redirected to the project\'s registrations page. From here you can initiate a new Draft Registration to complete the registration process',
            trust=False
        )
        return redirect(node.web_url_for('node_registrations', view=kwargs.get('template')))
开发者ID:baylee-d,项目名称:osf.io,代码行数:38,代码来源:register.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python model.Comment类代码示例发布时间:2022-05-26
下一篇:
Python model.get_pointer_parent函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap