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

Python permissions.can_create_teams函数代码示例

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

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



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

示例1: dashboard

def dashboard(request, template='dashboard.html'):
    team_list = Team.objects.get_for_user(request.user, with_projects=True)
    if not team_list:
        if can_create_teams(request.user):
            return HttpResponseRedirect(reverse('sentry-new-team'))

        return render_to_response('sentry/generic_error.html', {
            'title': _('No Membership'),
            'message': _('You are not a member of any teams in Sentry and you do not have access to create a new team.'),
        }, request)

    return render_to_response('sentry/select_team.html', {
        'team_list': team_list.values(),
        'can_create_teams': can_create_teams(request.user),
    }, request)
开发者ID:Mbosco,项目名称:sentry,代码行数:15,代码来源:generic.py


示例2: new_project

def new_project(request):
    from django.contrib.auth.models import User

    if not can_create_projects(request.user):
        return HttpResponseRedirect(reverse('sentry'))

    allow_create_teams = can_create_teams(request.user)
    team_list = Team.objects.get_for_user(request.user)

    if request.user.has_perm('sentry.can_add_project') and User.objects.all()[0:2] == 2:
        project_form_cls = NewProjectAdminForm
        project_initial = {
            'owner': request.user.username,
        }
    else:
        project_form_cls = NewProjectForm
        project_initial = {}

    if len(team_list) > 0:
        select_team_form = SelectTeamForm(team_list, request.POST or None, prefix='st')
    elif not allow_create_teams:
        return render_to_response('sentry/projects/cannot_create_teams.html', {}, request)
    else:
        select_team_form = None

    if allow_create_teams:
        new_team_form = NewTeamForm(request.POST or None, prefix='nt')
    else:
        new_team_form = None

    project_form = project_form_cls(request.POST or None, initial=project_initial, prefix='prj')

    is_new_team = new_team_form and new_team_form.is_valid()
    if is_new_team or not select_team_form:
        team_form = new_team_form
    else:
        team_form = select_team_form

    if project_form.is_valid() and team_form.is_valid():
        project = project_form.save(commit=False)
        if not project.owner:
            project.owner = request.user

        if is_new_team:
            team = new_team_form.save(commit=False)
            team.owner = project.owner
            team.save()
        else:
            team = select_team_form.cleaned_data['team']

        project.team = team
        project.save()

        return HttpResponseRedirect(reverse('sentry-get-started', args=[project.slug]))

    return render_to_response('sentry/projects/new.html', {
        'project_form': project_form,
        'select_team_form': select_team_form,
        'new_team_form': new_team_form,
    }, request)
开发者ID:cheekybastard,项目名称:sentry,代码行数:60,代码来源:projects.py


示例3: get_default_context

def get_default_context(request, existing_context=None, team=None):
    from sentry.plugins import plugins

    context = {
        'HAS_SEARCH': settings.USE_SEARCH,
        'MESSAGES_PER_PAGE': settings.MESSAGES_PER_PAGE,
        'URL_PREFIX': settings.URL_PREFIX,
        'PLUGINS': plugins,
    }

    if request:
        context.update({
            'request': request,
            'can_create_teams': can_create_teams(request.user),
        })
        if team:
            context.update({
                'can_admin_team': Team.objects.get_for_user(request.user, MEMBER_OWNER),
                'can_create_projects': can_create_projects(request.user, team=team),
            })
        else:
            context['can_create_projects'] = can_create_projects(request.user)

        if not existing_context or 'PROJECT_LIST' not in existing_context:
            project_list = Project.objects.get_for_user(request.user, team=team)
            context['PROJECT_LIST'] = sorted(project_list, key=lambda x: x.name)
        if not existing_context or 'TEAM_LIST' not in existing_context:
            context['TEAM_LIST'] = sorted(Team.objects.get_for_user(request.user).values(), key=lambda x: x.name)

    return context
开发者ID:lxyu,项目名称:sentry,代码行数:30,代码来源:helpers.py


示例4: post

    def post(self, request, organization_slug):
        organization = Organization.objects.get_from_cache(
            slug=organization_slug,
        )

        if not can_create_teams(request.user, organization):
            return Response(status=403)

        serializer = TeamSerializer(data=request.DATA)

        if serializer.is_valid():
            result = serializer.object

            team = Team.objects.create(
                name=result['name'],
                slug=result.get('slug'),
                owner=result.get('owner') or organization.owner,
                organization=organization,
            )

            AuditLogEntry.objects.create(
                organization=organization,
                actor=request.user,
                ip_address=request.META['REMOTE_ADDR'],
                target_object=team.id,
                event=AuditLogEntryEvent.TEAM_ADD,
                data=team.get_audit_log_data(),
            )

            return Response(serialize(team, request.user), status=201)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:BlueMoebius,项目名称:sentry,代码行数:31,代码来源:organization_teams.py


示例5: get_default_context

def get_default_context(request, existing_context=None, team=None):
    from sentry.plugins import plugins

    context = {
        "HAS_SEARCH": settings.USE_SEARCH,
        "MESSAGES_PER_PAGE": settings.MESSAGES_PER_PAGE,
        "INTERNAL_PROJECT": get_internal_project(),
        "PROJECT_ID": str(settings.PROJECT),
        "URL_PREFIX": settings.URL_PREFIX,
        "PLUGINS": plugins,
        "USE_JS_CLIENT": settings.USE_JS_CLIENT,
    }

    if request:
        context.update(
            {
                "request": request,
                "can_create_projects": can_create_projects(request.user),
                "can_create_teams": can_create_teams(request.user),
            }
        )
        if team:
            context.update({"can_admin_team": Team.objects.get_for_user(request.user, MEMBER_OWNER)})

        if not existing_context or "PROJECT_LIST" not in existing_context:
            project_list = Project.objects.get_for_user(request.user, team=team)
            context["PROJECT_LIST"] = sorted(project_list, key=lambda x: x.name)
        if not existing_context or "TEAM_LIST" not in existing_context:
            context["TEAM_LIST"] = sorted(Team.objects.get_for_user(request.user).values(), key=lambda x: x.name)

    return context
开发者ID:jtwaleson,项目名称:sentry,代码行数:31,代码来源:helpers.py


示例6: dashboard

def dashboard(request, template='dashboard.html'):
    team_list = Team.objects.get_for_user(request.user)
    if not team_list:
        if can_create_teams(request.user):
            return HttpResponseRedirect(reverse('sentry-new-team'))

        return render_to_response('sentry/generic_error.html', {
            'title': _('No Membership'),
            'message': _('You are not a member of any teams in Sentry and you do not have access to create a new team.'),
        }, request)

    # This cookie gets automatically set by render_to_response
    if len(team_list) == 1:
        team = team_list.values()[0]
        return HttpResponseRedirect(reverse('sentry', args=[team.slug]))

    # these kinds of queries make people sad :(
    results = []
    for team in sorted(team_list.itervalues(), key=lambda x: x.name):
        project_list = list(team.project_set.filter(
            status=STATUS_VISIBLE,
        ).order_by('name')[:20])
        results.append((team, project_list))

    return render_to_response('sentry/select_team.html', {
        'team_list': results,
    }, request)
开发者ID:Aaron1011,项目名称:sentry,代码行数:27,代码来源:generic.py


示例7: get_default_context

def get_default_context(request, existing_context=None):
    from sentry.plugins import plugins

    context = {
        'HAS_SEARCH': settings.USE_SEARCH,
        'MESSAGES_PER_PAGE': settings.MESSAGES_PER_PAGE,
        'PROJECT_ID': str(settings.PROJECT),
        'VIEWS': list(View.objects.all()),
        'URL_PREFIX': settings.URL_PREFIX,
        'PLUGINS': plugins,
        'USE_JS_CLIENT': settings.USE_JS_CLIENT,
    }

    if request:
        context.update({
            'request': request,
            'can_create_projects': can_create_projects(request.user),
            'can_create_teams': can_create_teams(request.user),
        })
        if not existing_context or 'PROJECT_LIST' not in existing_context:
            context['PROJECT_LIST'] = get_project_list(request.user).values()
        if not existing_context or 'TEAM_LIST' not in existing_context:
            context['TEAM_LIST'] = get_team_list(request.user).values()

    return context
开发者ID:tbarbugli,项目名称:sentry,代码行数:25,代码来源:helpers.py


示例8: get_default_context

def get_default_context(request, existing_context=None):
    from sentry.plugins import plugins

    context = {
        'COMPRESS_ENABLED': dj_settings.COMPRESS_ENABLED,
        'COMPRESS_LESS': dj_settings.COMPRESS_ENABLED and dj_settings.LESS_BIN,
        'HAS_SEARCH': settings.USE_SEARCH,
        'MESSAGES_PER_PAGE': settings.MESSAGES_PER_PAGE,
        'INTERNAL_PROJECT': get_internal_project(),
        'PROJECT_ID': str(settings.PROJECT),
        'VIEWS': list(View.objects.all()),
        'URL_PREFIX': settings.URL_PREFIX,
        'PLUGINS': plugins,
        'USE_JS_CLIENT': settings.USE_JS_CLIENT,
    }

    if request:
        context.update({
            'request': request,
            'can_create_projects': can_create_projects(request.user),
            'can_create_teams': can_create_teams(request.user),
        })
        if not existing_context or 'PROJECT_LIST' not in existing_context:
            context['PROJECT_LIST'] = get_project_list(request.user).values()
        if not existing_context or 'TEAM_LIST' not in existing_context:
            context['TEAM_LIST'] = Team.objects.get_for_user(request.user).values()

    return context
开发者ID:acdha,项目名称:sentry,代码行数:28,代码来源:helpers.py


示例9: get_default_context

def get_default_context(request, existing_context=None):
    from sentry.plugins import plugins

    context = {
        "HAS_SEARCH": settings.USE_SEARCH,
        "MESSAGES_PER_PAGE": settings.MESSAGES_PER_PAGE,
        "PROJECT_ID": str(settings.PROJECT),
        "VIEWS": list(View.objects.all()),
        "URL_PREFIX": settings.URL_PREFIX,
        "PLUGINS": plugins,
        "USE_JS_CLIENT": settings.USE_JS_CLIENT,
    }

    if request:
        context.update(
            {
                "request": request,
                "can_create_projects": can_create_projects(request.user),
                "can_create_teams": can_create_teams(request.user),
            }
        )
        if not existing_context or "PROJECT_LIST" not in existing_context:
            context["PROJECT_LIST"] = get_project_list(request.user).values()
        if not existing_context or "TEAM_LIST" not in existing_context:
            context["TEAM_LIST"] = Team.objects.get_for_user(request.user).values()

    return context
开发者ID:nickburns2006,项目名称:sentry,代码行数:27,代码来源:helpers.py


示例10: create_new_team

def create_new_team(request):
    if not can_create_teams(request.user):
        return missing_perm(request, Permissions.ADD_TEAM)

    if request.user.has_perm('sentry.can_add_team'):
        form_cls = NewTeamAdminForm
        initial = {
            'owner': request.user.username,
        }
    else:
        form_cls = NewTeamForm
        initial = {}

    form = form_cls(request.POST or None, initial=initial)
    if form.is_valid():
        team = form.save(commit=False)
        if not team.owner_id:
            team.owner = request.user
        team.save()
        return HttpResponseRedirect(reverse('sentry-new-project', args=[team.slug]))

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

    return render_to_response('sentry/teams/new.html', context, request)
开发者ID:SmashingDevelopment,项目名称:sentry,代码行数:27,代码来源:teams.py


示例11: new_project

def new_project(request):
    from django.contrib.auth.models import User

    if not can_create_projects(request.user):
        return HttpResponseRedirect(reverse("sentry"))

    allow_create_teams = can_create_teams(request.user)
    team_list = Team.objects.get_for_user(request.user)

    if request.user.has_perm("sentry.can_add_project") and User.objects.all()[0:2] == 2:
        project_form_cls = NewProjectAdminForm
        project_initial = {"owner": request.user.username}
    else:
        project_form_cls = NewProjectForm
        project_initial = {}

    if len(team_list) > 0:
        select_team_form = SelectTeamForm(team_list, request.POST or None, prefix="st")
    elif not allow_create_teams:
        return render_to_response("sentry/projects/cannot_create_teams.html", {}, request)
    else:
        select_team_form = None

    if allow_create_teams:
        new_team_form = NewTeamForm(request.POST or None, prefix="nt")
    else:
        new_team_form = None

    project_form = project_form_cls(request.POST or None, initial=project_initial, prefix="prj")

    is_new_team = new_team_form and new_team_form.is_valid()
    if is_new_team or not select_team_form:
        team_form = new_team_form
    else:
        team_form = select_team_form

    if project_form.is_valid() and team_form.is_valid():
        project = project_form.save(commit=False)
        if not project.owner:
            project.owner = request.user
        if is_new_team:
            team = new_team_form.save(commit=False)
            team.owner = project.owner
            team.save()
        else:
            team = select_team_form.cleaned_data["team"]
        project.team = team
        project.save()
        return HttpResponseRedirect(reverse("sentry-project-client-help", args=[project.slug]))

    return render_to_response(
        "sentry/projects/new.html",
        {"project_form": project_form, "select_team_form": select_team_form, "new_team_form": new_team_form},
        request,
    )
开发者ID:nkabir,项目名称:sentry,代码行数:55,代码来源:projects.py


示例12: handle

    def handle(self, request, organization):
        if not can_create_teams(request.user, organization):
            return missing_perm(request, Permissions.ADD_TEAM)

        session_data = request.session.get(self.session_key, {})
        if request.method == 'GET':
            logging.debug('GET request; resetting create team form wizard')
            current_step = 0
            try:
                del request.session[self.session_key]
            except KeyError:
                pass
        else:
            current_step = int(request.POST.get('step', 0))

        last_step = len(self.steps) - 1

        if current_step > last_step:
            logging.debug('Invalid step passed; resetting create team form wizard')
            return self.render_validation_error(request, organization)

        op = request.POST.get('op')
        if op != 'continue':
            data = None
        else:
            data = request.POST or None

        form = self.get_step_form(current_step, data)
        if op == 'continue' and form.is_valid():
            session_data['step%d' % current_step] = form.cleaned_data
            request.session[self.session_key] = session_data
            if current_step == last_step:
                # no more steps, render done view
                return self.render_done(request, organization, form)
            else:
                # proceed to the next step
                return self.render_next_step(request, organization, current_step + 1)

        elif op == 'back' and current_step > 0:
            return self.render_next_step(request, organization, current_step - 1)

        elif op == 'skip' and current_step > 0:
            session_data['step%d' % current_step] = {}
            request.session[self.session_key] = session_data
            if current_step == last_step:
                # no more steps, render done view
                return self.render_done(request, organization, form)
            else:
                # proceed to the next step
                return self.render_next_step(request, organization, current_step + 1)

        return self.render(request, organization, current_step, form)
开发者ID:BlueMoebius,项目名称:sentry,代码行数:52,代码来源:create_team.py


示例13: dashboard

def dashboard(request, template="dashboard.html"):
    team_list = Team.objects.get_for_user(request.user, with_projects=True)
    if not team_list:
        if can_create_teams(request.user):
            return HttpResponseRedirect(reverse("sentry-new-team"))

        return render_to_response(
            "sentry/generic_error.html",
            {
                "title": _("No Membership"),
                "message": _(
                    "You are not a member of any teams in Sentry and you do not have access to create a new team."
                ),
            },
            request,
        )

    return render_to_response("sentry/select_team.html", {"team_list": team_list.values()}, request)
开发者ID:Getsidecar,项目名称:sentry,代码行数:18,代码来源:generic.py


示例14: post

    def post(self, request):
        if not can_create_teams(request.user):
            return Response(status=403)

        if request.user.is_superuser:
            serializer = TeamAdminSerializer(data=request.DATA)
        else:
            serializer = TeamSerializer(data=request.DATA)

        if serializer.is_valid():
            result = serializer.object
            team = Team.objects.create(
                name=result['name'],
                slug=result.get('slug'),
                owner=result.get('owner') or request.user,
            )
            return Response(serialize(team, request.user), status=201)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:catufunwa,项目名称:sentry,代码行数:18,代码来源:team_index.py


示例15: dashboard

def dashboard(request, template='dashboard.html'):
    team_list = Team.objects.get_for_user(request.user)
    if not team_list:
        if can_create_teams(request.user):
            return HttpResponseRedirect(reverse('sentry-new-team'))

        return render_to_response('sentry/generic_error.html', {
            'title': _('No Membership'),
            'message': _('You are not a member of any teams in Sentry and you do not have access to create a new team.'),
        }, request)

    # This cookie gets automatically set by render_to_response
    last_team = request.session.get('team')
    if last_team in team_list:
        team = team_list[last_team]
    else:
        team = team_list.values()[0]

    # Redirect to first team
    # TODO: maybe store this in a cookie and redirect to last seen team?
    return HttpResponseRedirect(reverse('sentry', args=[team.slug]))
开发者ID:DouweM,项目名称:sentry,代码行数:21,代码来源:generic.py


示例16: post

    def post(self, request, organization):
        """
        Create a new team

        Create a new team bound to an organization.

            {method} {path}
            {{
                "name": "My team"
            }}

        """
        if not can_create_teams(request.user, organization):
            return Response(status=403)

        serializer = TeamSerializer(data=request.DATA)

        if serializer.is_valid():
            result = serializer.object

            team = Team.objects.create(
                name=result["name"],
                slug=result.get("slug"),
                owner=result.get("owner") or organization.owner,
                organization=organization,
            )

            AuditLogEntry.objects.create(
                organization=organization,
                actor=request.user,
                ip_address=request.META["REMOTE_ADDR"],
                target_object=team.id,
                event=AuditLogEntryEvent.TEAM_ADD,
                data=team.get_audit_log_data(),
            )

            return Response(serialize(team, request.user), status=201)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:Juraldinio,项目名称:sentry,代码行数:38,代码来源:organization_teams.py


示例17: create_new_team

def create_new_team(request):
    if not can_create_teams(request.user):
        return HttpResponseRedirect(reverse("sentry"))

    if request.user.has_perm("sentry.can_add_team"):
        form_cls = NewTeamAdminForm
        initial = {"owner": request.user.username}
    else:
        form_cls = NewTeamForm
        initial = {}

    form = form_cls(request.POST or None, initial=initial)
    if form.is_valid():
        team = form.save(commit=False)
        if not team.owner_id:
            team.owner = request.user
        team.save()
        return HttpResponseRedirect(reverse("sentry-manage-team", args=[team.slug]))

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

    return render_to_response("sentry/teams/new.html", context, request)
开发者ID:pratz,项目名称:sentry,代码行数:23,代码来源:teams.py


示例18: post

    def post(self, request, organization):
        """
        Create a new team

        Create a new team bound to an organization.

            {method} {path}
            {{
                "name": "My team"
            }}

        """
        if not can_create_teams(request.user, organization):
            return Response(status=403)

        serializer = TeamSerializer(data=request.DATA)

        if serializer.is_valid():
            result = serializer.object

            team = Team.objects.create(
                name=result['name'],
                slug=result.get('slug'),
                organization=organization,
            )

            self.create_audit_entry(
                request=request,
                organization=organization,
                target_object=team.id,
                event=AuditLogEntryEvent.TEAM_ADD,
                data=team.get_audit_log_data(),
            )

            return Response(serialize(team, request.user), status=201)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:KinKir,项目名称:sentry,代码行数:36,代码来源:organization_teams.py


示例19: get_default_context

def get_default_context(request, existing_context=None, team=None):
    from sentry.plugins import plugins

    context = {
        'COMPRESS_ENABLED': dj_settings.COMPRESS_ENABLED,
        'COMPRESS_LESS': dj_settings.COMPRESS_ENABLED and dj_settings.LESS_BIN,
        'HAS_SEARCH': settings.USE_SEARCH,
        'MESSAGES_PER_PAGE': settings.MESSAGES_PER_PAGE,
        'INTERNAL_PROJECT': get_internal_project(),
        'PROJECT_ID': str(settings.PROJECT),
        'URL_PREFIX': settings.URL_PREFIX,
        'PLUGINS': plugins,
        'USE_JS_CLIENT': settings.USE_JS_CLIENT,
    }

    if request:
        context.update({
            'request': request,
            'can_create_projects': can_create_projects(request.user),
            'can_create_teams': can_create_teams(request.user),
        })
        if team:
            context.update({
                'can_admin_team': Team.objects.get_for_user(request.user, MEMBER_OWNER)
            })

        if not existing_context or 'PROJECT_LIST' not in existing_context:
            if team:
                project_list = Project.objects.filter(team=team)
            else:
                project_list = get_project_list(request.user).values()
            context['PROJECT_LIST'] = sorted(project_list, key=lambda x: x.name)
        if not existing_context or 'TEAM_LIST' not in existing_context:
            context['TEAM_LIST'] = sorted(Team.objects.get_for_user(request.user).values(), key=lambda x: x.name)

    return context
开发者ID:andrewsmedina,项目名称:sentry,代码行数:36,代码来源:helpers.py


示例20: import

"""
sentry.templatetags.sentry_permissions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010-2014 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
from __future__ import absolute_import

from django import template

from sentry.permissions import (
    can_create_organizations, can_create_teams, can_create_projects,
    can_remove_project, can_manage_project, can_manage_team, can_manage_org
)

register = template.Library()

# TODO: Django doesn't seem to introspect function args correctly for filters
# so we can't just register.filter(can_add_team_member)
register.filter('can_create_organizations')(lambda a: can_create_organizations(a))
register.filter('can_create_teams')(lambda a, b: can_create_teams(a, b))
register.filter('can_create_projects')(lambda a, b: can_create_projects(a, b))
register.filter('can_manage_team')(lambda a, b: can_manage_team(a, b))
register.filter('can_manage_project')(lambda a, b: can_manage_project(a, b))
register.filter('can_manage_org')(lambda a, b: can_manage_org(a, b))
register.filter('can_remove_project')(lambda a, b: can_remove_project(a, b))
开发者ID:BlueMoebius,项目名称:sentry,代码行数:27,代码来源:sentry_permissions.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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