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


Python helpers.get_project_list函数代码示例

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


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


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