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

Python helpers.get_project_list函数代码示例

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

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



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

示例1: test_does_not_include_private_projects

    def test_does_not_include_private_projects(self, get_for_user):
        get_for_user.return_value = {self.project2.team.id: self.project2.team}
        project_list = get_project_list(self.user)
        get_for_user.assert_called_once_with(self.user, None)
        assert project_list == {
            self.project2.id: self.project2,
        }

        get_for_user.reset_mock()
        project_list = get_project_list(self.user, MEMBER_USER)
        get_for_user.assert_called_once_with(self.user, MEMBER_USER)
        assert project_list == {
            self.project2.id: self.project2,
        }
开发者ID:lukegb,项目名称:sentry,代码行数:14,代码来源:tests.py


示例2: 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_list = [project]
    else:
        project_list = get_project_list(request.user).values()

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

    base_qs = Group.objects.filter(
        project__in=project_list,
        status=0,
    ).select_related('project').order_by('-score')

    if has_trending():
        group_list = list(Group.objects.get_accelerated(base_qs, minutes=(
            (cutoff.days * 1440) + (cutoff.seconds * 60)
        ))[:limit])
    else:
        group_list = list(base_qs.filter(
            last_seen__gte=cutoff_dt
        )[:limit])

    data = transform_groups(request, group_list, template='sentry/partial/_group_small.html')

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

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


示例3: _wrapped

        def _wrapped(request, project_id=None, *args, **kwargs):
            # XXX: if project_id isn't set, should we only allow superuser?
            if project_id.isdigit():
                lookup_kwargs = {'id': int(project_id)}
            else:
                lookup_kwargs = {'slug': project_id}

            if request.user.is_superuser:
                if project_id:
                    try:
                        project = Project.objects.get_from_cache(**lookup_kwargs)
                    except Project.DoesNotExist:
                        return HttpResponseRedirect(reverse('sentry'))
                else:
                    project = None
                return func(request, project, *args, **kwargs)

            if project_id:
                key, value = lookup_kwargs.items()[0]
                project_list = get_project_list(request.user, group_or_func, key=key)
                try:
                    project = project_list[value]
                except (KeyError, ValueError):
                    return HttpResponseRedirect(reverse('sentry'))
            else:
                project = None

            return func(request, project, *args, **kwargs)
开发者ID:lardissone,项目名称:sentry,代码行数:28,代码来源:decorators.py


示例4: remove_project

def remove_project(request, project):
    if not can_remove_project(request.user, project):
        return HttpResponseRedirect(reverse('sentry'))

    project_list = filter(lambda x: x != project, get_project_list(request.user).itervalues())

    form = RemoveProjectForm(request.user, project_list, request.POST or None)

    if form.is_valid():
        removal_type = form.cleaned_data['removal_type']
        if removal_type == '1':
            project.delete()
        elif removal_type == '2':
            new_project = form.cleaned_data['project']
            project.merge_to(new_project)
        elif removal_type == '3':
            project.update(status=1)
        else:
            raise ValueError(removal_type)

        return HttpResponseRedirect(reverse('sentry-project-list'))

    context = csrf(request)
    context.update({
        'form': form,
        'project': project,
    })

    return render_to_response('sentry/projects/remove.html', context, request)
开发者ID:Fashiolista,项目名称:sentry,代码行数:29,代码来源:projects.py


示例5: dashboard

def dashboard(request):
    project_list = get_project_list(request.user, key='slug')
    if len(project_list) == 1:
        return HttpResponseRedirect(reverse('sentry', kwargs={'project_id': project_list.keys()[0]}))
    if len(project_list) == 0 and not request.user.is_authenticated():
        return HttpResponseRedirect(get_login_url())
    return render_to_response('sentry/dashboard.html', request=request)
开发者ID:Technigami,项目名称:sentry,代码行数:7,代码来源:generic.py


示例6: dashboard

def dashboard(request):
    project_list = get_project_list(request.user, key='slug')
    if len(project_list) == 0 and not request.user.is_authenticated():
        return HttpResponseRedirect(get_login_url())

    if project_list:
        cutoff = datetime.datetime.now() - datetime.timedelta(days=1)
        base_qs = Group.objects.filter(
            project__in=project_list.values(),
            status=0,
        ).select_related('project').order_by('-score')

        # TODO: change this to calculate the most frequent events in the time period,
        # not just events seen within the time period that have at one time been frequent
        top_event_list = list(base_qs.filter(
            last_seen__gte=cutoff
        )[:10])

        new_event_list = list(base_qs.filter(
            active_at__gte=cutoff,
        )[:10])
    else:
        top_event_list = None
        new_event_list = None

    return render_to_response('sentry/dashboard.html', {
        'top_event_list': top_event_list,
        'new_event_list': new_event_list,
    }, request)
开发者ID:SimpleTax,项目名称:sentry,代码行数:29,代码来源:generic.py


示例7: 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


示例8: 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


示例9: test_does_include_private_projects_without_access

 def test_does_include_private_projects_without_access(self, get_for_user):
     get_for_user.return_value = {self.project2.team.id: self.project2.team}
     project_list = get_project_list(self.user)
     get_for_user.assert_called_once_with(self.user, None)
     self.assertEquals(len(project_list), 2)
     self.assertIn(self.project.id, project_list)
     self.assertIn(self.project2.id, project_list)
开发者ID:DazWorrall,项目名称:sentry,代码行数:7,代码来源:tests.py


示例10: dashboard

def dashboard(request):
    project_list = get_project_list(request.user, key='slug')
    if len(project_list) == 0 and not request.user.is_authenticated():
        return HttpResponseRedirect(get_login_url())

    if project_list:
        cutoff = datetime.datetime.now() - datetime.timedelta(days=1)
        base_qs = Group.objects.filter(
            project__in=project_list.values(),
            status=0,
        ).select_related('project').order_by('-score')

        top_event_list = list(base_qs.filter(
            last_seen__gte=cutoff
        )[:10])

        new_event_list = list(base_qs.filter(
            first_seen__gte=cutoff,
        )[:10])
    else:
        top_event_list = None
        new_event_list = None

    return render_to_response('sentry/dashboard.html', {
        'top_event_list': top_event_list,
        'new_event_list': new_event_list,
    }, request)
开发者ID:mrooney,项目名称:sentry,代码行数:27,代码来源:generic.py


示例11: remove_project

def remove_project(request, project):
    if not can_remove_project(request.user, project):
        return HttpResponseRedirect(reverse("sentry"))

    project_list = filter(lambda x: x != project, get_project_list(request.user).itervalues())

    form = RemoveProjectForm(request.user, project_list, request.POST or None)

    if form.is_valid():
        removal_type = form.cleaned_data["removal_type"]
        if removal_type == "1":
            project.delete()
        elif removal_type == "2":
            new_project = form.cleaned_data["project"]
            project.merge_to(new_project)
        elif removal_type == "3":
            project.update(status=1)
        else:
            raise ValueError(removal_type)

        return HttpResponseRedirect(reverse("sentry-project-list"))

    context = csrf(request)
    context.update({"form": form, "project": project})

    return render_to_response("sentry/projects/remove.html", context, request)
开发者ID:nkabir,项目名称:sentry,代码行数:26,代码来源:projects.py


示例12: 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).order_by("-score")

    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)[:limit])

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

    data = transform_groups(request, group_list, template="sentry/partial/_group_small.html")

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

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


示例13: get_stats

def get_stats(request, project=None):
    minutes = int(request.REQUEST.get('minutes', 15))

    if project:
        project_list = [project]
    else:
        project_list = get_project_list(request.user).values()

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

    num_events = ProjectCountByMinute.objects.filter(
        project__in=project_list,
        date__gte=cutoff_dt,
    ).aggregate(t=Sum('times_seen'))['t'] or 0

    # XXX: This is too slow if large amounts of groups are resolved
    num_resolved = Group.objects.filter(
        project__in=project_list,
        status=1,
        resolved_at__gte=cutoff_dt,
    ).aggregate(t=Sum('times_seen'))['t'] or 0

    data = {
        'events': num_events,
        'resolved': num_resolved,
    }

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

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


示例14: 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


示例15: 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


示例16: resolve

def resolve(request, project):
    gid = request.REQUEST.get('gid')
    if not gid:
        return HttpResponseForbidden()
    try:
        group = Group.objects.get(pk=gid)
    except Group.DoesNotExist:
        return HttpResponseForbidden()

    if group.project and group.project.pk not in get_project_list(request.user):
        return HttpResponseForbidden()

    Group.objects.filter(pk=group.pk).update(status=1)
    group.status = 1

    data = [
        (m.pk, {
            'html': render_to_string('sentry/partial/_group.html', {
                'group': m,
                'request': request,
            }).strip(),
            'count': m.times_seen,
        }) for m in [group]]

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


示例17: chart

def chart(request, team=None, project=None):
    gid = request.REQUEST.get('gid')
    days = int(request.REQUEST.get('days', '90'))
    if gid:
        try:
            group = Group.objects.get(pk=gid)
        except Group.DoesNotExist:
            return HttpResponseForbidden()

        data = Group.objects.get_chart_data(group, max_days=days)
    elif project:
        data = Project.objects.get_chart_data(project, max_days=days)
    elif team:
        cache_key = 'api.chart:team=%s,days=%s' % (team.id, days)

        data = cache.get(cache_key)
        if data is None:
            project_list = list(Project.objects.filter(team=team))
            data = Project.objects.get_chart_data_for_group(project_list, max_days=days)
            cache.set(cache_key, data, 300)
    else:
        cache_key = 'api.chart:user=%s,days=%s' % (request.user.id, days)

        data = cache.get(cache_key)
        if data is None:
            project_list = get_project_list(request.user).values()
            data = Project.objects.get_chart_data_for_group(project_list, max_days=days)
            cache.set(cache_key, data, 300)

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


示例18: bookmark

def bookmark(request, 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()

    if group.project and group.project.pk not in get_project_list(request.user):
        return HttpResponseForbidden()

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

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


示例19: dashboard

def dashboard(request):
    project_list = get_project_list(request.user, key='slug')
    if len(project_list) == 0 and not request.user.is_authenticated():
        return HttpResponseRedirect(get_login_url())

    return render_to_response('sentry/dashboard.html', {
    }, request)
开发者ID:NewAgeDev,项目名称:sentry,代码行数:7,代码来源:generic.py


示例20: clear

def clear(request, project):
    projects = get_project_list(request.user)

    event_list = Group.objects.filter(Q(project__in=projects.keys()) | Q(project__isnull=True))

    event_list.update(status=1)

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python helpers.group_is_public函数代码示例发布时间:2022-05-27
下一篇:
Python helpers.get_login_url函数代码示例发布时间: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