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

Python javascript.to_json函数代码示例

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

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



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

示例1: get_new_groups

def get_new_groups(request, project=None):
    minutes = int(request.REQUEST.get('minutes', 15))
    limit = min(100, int(request.REQUEST.get('limit', 10)))

    if project:
        project_dict = {project.id: project}
    else:
        project_dict = get_project_list(request.user)

    cutoff = datetime.timedelta(minutes=minutes)
    cutoff_dt = timezone.now() - cutoff

    group_list = list(Group.objects.filter(
        project__in=project_dict.keys(),
        status=0,
        active_at__gte=cutoff_dt,
    ).order_by('-score')[:limit])

    for group in group_list:
        group._project_cache = project_dict.get(group.project_id)

    data = to_json(group_list, request)

    response = HttpResponse(data)
    response['Content-Type'] = 'application/json'

    return response
开发者ID:davidszotten,项目名称:sentry,代码行数:27,代码来源:api.py


示例2: get_resolved_groups

def get_resolved_groups(request, team=None, project=None):
    minutes = int(request.REQUEST.get('minutes', 15))
    limit = min(100, int(request.REQUEST.get('limit', 10)))

    if not team and project:
        project_list = [project]
    else:
        project_list = Project.objects.get_for_user(request.user, team=team)

    project_dict = dict((p.id, p) for p in project_list)

    cutoff = datetime.timedelta(minutes=minutes)
    cutoff_dt = timezone.now() - cutoff

    group_list = list(Group.objects.filter(
        project__in=project_list,
        status=STATUS_RESOLVED,
        resolved_at__gte=cutoff_dt,
    ).order_by('-score')[:limit])

    for group in group_list:
        group._project_cache = project_dict.get(group.project_id)

    data = to_json(group_list, request)

    response = HttpResponse(json.dumps(data))
    response['Content-Type'] = 'application/json'

    return response
开发者ID:DNIWE-Systems,项目名称:sentry,代码行数:29,代码来源:api.py


示例3: resolve

def resolve(request, team, project):
    gid = request.REQUEST.get('gid')
    if not gid:
        return HttpResponseForbidden()

    try:
        group = Group.objects.get(pk=gid)
    except Group.DoesNotExist:
        return HttpResponseForbidden()

    now = timezone.now()

    happened = Group.objects.filter(
        pk=group.pk,
    ).exclude(status=STATUS_RESOLVED).update(
        status=STATUS_RESOLVED,
        resolved_at=now,
    )
    group.status = STATUS_RESOLVED
    group.resolved_at = now

    if happened:
        Activity.objects.create(
            project=project,
            group=group,
            type=Activity.SET_RESOLVED,
            user=request.user,
        )

    return to_json(group, request)
开发者ID:DNIWE-Systems,项目名称:sentry,代码行数:30,代码来源:api.py


示例4: get_resolved_groups

def get_resolved_groups(request, team=None, project=None):
    minutes = int(request.REQUEST.get('minutes', 15))
    limit = min(100, int(request.REQUEST.get('limit', 10)))

    if team:
        project_list = list(Project.objects.filter(team=team))
    elif project:
        project_list = [project]
    else:
        project_list = get_project_list(request.user).values()

    cutoff = datetime.timedelta(minutes=minutes)
    cutoff_dt = timezone.now() - cutoff

    group_list = Group.objects.filter(
        project__in=project_list,
        status=STATUS_RESOLVED,
        resolved_at__gte=cutoff_dt,
    ).select_related('project').order_by('-score')[:limit]

    data = to_json(group_list, request)

    response = HttpResponse(json.dumps(data))
    response['Content-Type'] = 'application/json'

    return response
开发者ID:TracyWebTech,项目名称:sentry,代码行数:26,代码来源:api.py


示例5: poll

def poll(request, project):
    offset = 0
    limit = settings.MESSAGES_PER_PAGE

    view_id = request.GET.get('view_id')
    if view_id:
        try:
            view = View.objects.get_from_cache(pk=view_id)
        except View.DoesNotExist:
            return HttpResponseBadRequest()
    else:
        view = None

    response = _get_group_list(
        request=request,
        project=project,
        view=view,
    )

    event_list = response['event_list']
    event_list = list(event_list[offset:limit])

    data = to_json(event_list, request)

    response = HttpResponse(data)
    response['Content-Type'] = 'application/json'
    return response
开发者ID:davidszotten,项目名称:sentry,代码行数:27,代码来源:api.py


示例6: get_group_trends

def get_group_trends(request, project=None):
    minutes = int(request.REQUEST.get('minutes', 15))
    limit = min(100, int(request.REQUEST.get('limit', 10)))

    if project:
        project_dict = {project.pk: project}
    else:
        project_dict = get_project_list(request.user)

    base_qs = Group.objects.filter(
        project__in=project_dict.keys(),
        status=0,
    )

    if has_trending():
        group_list = list(Group.objects.get_accelerated(base_qs, minutes=(
            minutes
        ))[:limit])
    else:
        cutoff = datetime.timedelta(minutes=minutes)
        cutoff_dt = timezone.now() - cutoff

        group_list = list(base_qs.filter(
            last_seen__gte=cutoff_dt
        ).order_by('-score')[:limit])

    for group in group_list:
        group._project_cache = project_dict.get(group.project_id)

    data = to_json(group_list, request)

    response = HttpResponse(data)
    response['Content-Type'] = 'application/json'

    return response
开发者ID:davidszotten,项目名称:sentry,代码行数:35,代码来源:api.py


示例7: get_group_trends

def get_group_trends(request, team=None, project=None):
    minutes = int(request.REQUEST.get('minutes', 15))
    limit = min(100, int(request.REQUEST.get('limit', 10)))

    if not team and project:
        project_list = [project]
    else:
        project_list = Project.objects.get_for_user(request.user, team=team)

    project_dict = dict((p.id, p) for p in project_list)

    base_qs = Group.objects.filter(
        project__in=project_list,
        status=0,
    )

    cutoff = datetime.timedelta(minutes=minutes)
    cutoff_dt = timezone.now() - cutoff

    group_list = list(base_qs.filter(
        status=STATUS_UNRESOLVED,
        last_seen__gte=cutoff_dt
    ).extra(select={'sort_value': 'score'}).order_by('-score')[:limit])

    for group in group_list:
        group._project_cache = project_dict.get(group.project_id)

    data = to_json(group_list, request)

    response = HttpResponse(data)
    response['Content-Type'] = 'application/json'

    return response
开发者ID:DNIWE-Systems,项目名称:sentry,代码行数:33,代码来源:api.py


示例8: get_new_groups

def get_new_groups(request, team=None, project=None):
    minutes = int(request.REQUEST.get("minutes", 15))
    limit = min(100, int(request.REQUEST.get("limit", 10)))

    if not team and project:
        project_list = [project]
    else:
        project_list = Project.objects.get_for_user(request.user, team=team)

    project_dict = dict((p.id, p) for p in project_list)

    cutoff = datetime.timedelta(minutes=minutes)
    cutoff_dt = timezone.now() - cutoff

    group_list = list(
        Group.objects.filter(project__in=project_dict.keys(), status=STATUS_UNRESOLVED, active_at__gte=cutoff_dt)
        .extra(select={"sort_value": "score"})
        .order_by("-score", "-first_seen")[:limit]
    )

    for group in group_list:
        group._project_cache = project_dict.get(group.project_id)

    data = to_json(group_list, request)

    response = HttpResponse(data)
    response["Content-Type"] = "application/json"

    return response
开发者ID:rnoldo,项目名称:sentry,代码行数:29,代码来源:api.py


示例9: get_new_groups

def get_new_groups(request, team=None, project=None):
    minutes = int(request.REQUEST.get('minutes', 15))
    limit = min(100, int(request.REQUEST.get('limit', 10)))

    if team:
        project_dict = dict((p.id, p) for p in Project.objects.filter(team=team))
    elif project:
        project_dict = {project.id: project}
    else:
        project_dict = get_project_list(request.user)

    cutoff = datetime.timedelta(minutes=minutes)
    cutoff_dt = timezone.now() - cutoff

    group_list = list(Group.objects.filter(
        project__in=project_dict.keys(),
        status=STATUS_UNRESOLVED,
        active_at__gte=cutoff_dt,
    ).extra(select={'sort_value': 'score'}).order_by('-score', '-first_seen')[:limit])

    for group in group_list:
        group._project_cache = project_dict.get(group.project_id)

    data = to_json(group_list, request)

    response = HttpResponse(data)
    response['Content-Type'] = 'application/json'

    return response
开发者ID:TracyWebTech,项目名称:sentry,代码行数:29,代码来源:api.py


示例10: unmute_group

def unmute_group(request, project, group_id):
    try:
        group = Group.objects.get(pk=group_id)
    except Group.DoesNotExist:
        return HttpResponseForbidden()

    group.update(status=STATUS_UNRESOLVED)

    return to_json(group, request)
开发者ID:allanlei,项目名称:sentry,代码行数:9,代码来源:api.py


示例11: make_group_private

def make_group_private(request, project, group_id):
    try:
        group = Group.objects.get(pk=group_id)
    except Group.DoesNotExist:
        return HttpResponseForbidden()

    group.update(is_public=False)

    return to_json(group, request)
开发者ID:allanlei,项目名称:sentry,代码行数:9,代码来源:api.py


示例12: poll

def poll(request, team, project):
    offset = 0
    limit = settings.MESSAGES_PER_PAGE

    response = _get_group_list(request=request, project=project)

    event_list = response["event_list"]
    event_list = list(event_list[offset:limit])

    return to_json(event_list, request)
开发者ID:rnoldo,项目名称:sentry,代码行数:10,代码来源:api.py


示例13: unresolve_group

def unresolve_group(request, team, project, group_id):
    try:
        group = Group.objects.get(pk=group_id)
    except Group.DoesNotExist:
        return HttpResponseForbidden()

    happened = group.update(status=STATUS_UNRESOLVED)
    if happened:
        Activity.objects.create(project=project, group=group, type=Activity.SET_UNRESOLVED, user=request.user)

    return to_json(group, request)
开发者ID:rnoldo,项目名称:sentry,代码行数:11,代码来源:api.py


示例14: make_group_private

def make_group_private(request, team, project, group_id):
    try:
        group = Group.objects.get(pk=group_id)
    except Group.DoesNotExist:
        return HttpResponseForbidden()

    happened = group.update(is_public=False)

    if happened:
        Activity.objects.create(project=project, group=group, type=Activity.SET_PRIVATE, user=request.user)

    return to_json(group, request)
开发者ID:rnoldo,项目名称:sentry,代码行数:12,代码来源:api.py


示例15: poll

def poll(request, team, project):
    offset = 0
    limit = EVENTS_PER_PAGE

    response = _get_group_list(
        request=request,
        project=project,
    )

    event_list = response['event_list']
    event_list = list(event_list[offset:limit])

    return to_json(event_list, request)
开发者ID:DNIWE-Systems,项目名称:sentry,代码行数:13,代码来源:api.py


示例16: poll

def poll(request, organization, project):
    offset = 0
    limit = EVENTS_PER_PAGE

    group_result = _get_group_list(
        request=request,
        project=project,
    )

    event_list = group_result['event_list']
    event_list = list(event_list[offset:limit])

    data = to_json(event_list, request)

    links = [
        ('previous', str(group_result['prev_cursor'])),
        ('next', str(group_result['next_cursor'])),
    ]

    querystring = u'&'.join(
        u'{0}={1}'.format(urlquote(k), urlquote(v))
        for k, v in request.GET.iteritems()
        if k != 'cursor'
    )
    base_url = request.build_absolute_uri(request.path)
    if querystring:
        base_url = '{0}?{1}'.format(base_url, querystring)
    else:
        base_url = base_url + '?'

    link_values = []
    for name, cursor in links:
        link_values.append(LINK_HEADER.format(
            uri=base_url,
            cursor=cursor,
            name=name,
            has_results='true' if bool(cursor) else 'false',
        ))

    headers = {}
    if link_values:
        headers['Link'] = ', '.join(link_values)

    response = HttpResponse(data)
    response['Content-Type'] = 'application/json'
    if link_values:
        response['Link'] = ', '.join(link_values)
    return response
开发者ID:rebeckag,项目名称:sentry,代码行数:48,代码来源:api.py


示例17: poll

def poll(request, project):
    offset = 0
    limit = settings.MESSAGES_PER_PAGE

    response = _get_group_list(
        request=request,
        project=project,
    )

    event_list = response['event_list']
    event_list = list(event_list[offset:limit])

    data = to_json(event_list, request)

    response = HttpResponse(data)
    response['Content-Type'] = 'application/json'
    return response
开发者ID:alphachoi,项目名称:sentry,代码行数:17,代码来源:api.py


示例18: make_group_public

def make_group_public(request, organization, project, group_id):
    try:
        group = Group.objects.get(pk=group_id)
    except Group.DoesNotExist:
        return HttpResponseForbidden()

    happened = group.update(is_public=True)

    if happened:
        Activity.objects.create(
            project=project,
            group=group,
            type=Activity.SET_PUBLIC,
            user=request.user,
        )

    return to_json(group, request)
开发者ID:rebeckag,项目名称:sentry,代码行数:17,代码来源:api.py


示例19: bookmark

def bookmark(request, team, project):
    gid = request.REQUEST.get("gid")
    if not gid:
        return HttpResponseForbidden()

    if not request.user.is_authenticated():
        return HttpResponseForbidden()

    try:
        group = Group.objects.get(pk=gid)
    except Group.DoesNotExist:
        return HttpResponseForbidden()

    gb, created = GroupBookmark.objects.get_or_create(project=group.project, user=request.user, group=group)
    if not created:
        gb.delete()

    return to_json(group, request)
开发者ID:rnoldo,项目名称:sentry,代码行数:18,代码来源:api.py


示例20: mute_group

def mute_group(request, team, project, group_id):
    try:
        group = Group.objects.get(pk=group_id)
    except Group.DoesNotExist:
        return HttpResponseForbidden()

    happened = group.update(
        status=STATUS_MUTED,
        resolved_at=timezone.now(),
    )
    if happened:
        Activity.objects.create(
            project=project,
            group=group,
            type=Activity.SET_MUTED,
            user=request.user,
        )

    return to_json(group, request)
开发者ID:DNIWE-Systems,项目名称:sentry,代码行数:19,代码来源:api.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python json.dumps函数代码示例发布时间:2022-05-27
下一篇:
Python imports.import_string函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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