本文整理汇总了Python中sentry.permissions.can_create_projects函数的典型用法代码示例。如果您正苦于以下问题:Python can_create_projects函数的具体用法?Python can_create_projects怎么用?Python can_create_projects使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了can_create_projects函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例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):
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
示例4: 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
示例5: 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
示例6: create_new_team_project
def create_new_team_project(request, team):
from sentry.web.forms.projects import NewProjectAdminForm, NewProjectForm
if not can_create_projects(request.user, team):
return HttpResponseRedirect(reverse("sentry"))
if request.user.has_perm("sentry.can_add_project"):
form_cls = NewProjectAdminForm
initial = {"owner": request.user.username}
else:
form_cls = NewProjectForm
initial = {}
form = form_cls(request.POST or None, initial=initial)
if form.is_valid():
project = form.save(commit=False)
project.team = team
if not project.owner:
project.owner = request.user
project.save()
if project.platform not in (None, "other"):
return HttpResponseRedirect(reverse("sentry-docs-client", args=[project.slug, project.platform]))
return HttpResponseRedirect(reverse("sentry-get-started", args=[project.slug]))
context = csrf(request)
context.update({"form": form, "team": team, "page": "projects"})
return render_to_response("sentry/teams/projects/new.html", context, request)
开发者ID:pratz,项目名称:sentry,代码行数:29,代码来源:teams.py
示例7: 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
示例8: manage_team
def manage_team(request, team):
result = plugins.first('has_perm', request.user, 'edit_team', team)
if result is False and not request.user.has_perm('sentry.can_change_team'):
return HttpResponseRedirect(reverse('sentry'))
form = EditTeamForm(request.POST or None, instance=team)
if form.is_valid():
team = form.save()
return HttpResponseRedirect(request.path + '?success=1')
member_list = [(pm, pm.user) for pm in team.member_set.select_related('user').order_by('user__username')]
pending_member_list = [(pm, pm.email) for pm in team.pending_member_set.all().order_by('email')]
project_list = list(team.project_set.all())
context = csrf(request)
context.update({
'can_add_project': can_create_projects(request.user, team),
'can_add_member': can_add_team_member(request.user, team),
'can_remove_team': can_remove_team(request.user, team),
'page': 'details',
'form': form,
'team': team,
'member_list': member_list,
'pending_member_list': pending_member_list,
'project_list': project_list,
})
return render_to_response('sentry/teams/manage.html', context, request)
开发者ID:doismellburning,项目名称:sentry,代码行数:31,代码来源:teams.py
示例9: create_new_team_project
def create_new_team_project(request, team):
from sentry.web.forms import NewProjectAdminForm, NewProjectForm
if not can_create_projects(request.user, team):
return HttpResponseRedirect(reverse('sentry'))
if request.user.has_perm('sentry.can_add_project'):
form_cls = NewProjectAdminForm
initial = {
'owner': request.user.username,
}
else:
form_cls = NewProjectForm
initial = {}
form = form_cls(request.POST or None, initial=initial)
if form.is_valid():
project = form.save(commit=False)
project.team = team
if not project.owner:
project.owner = request.user
project.save()
return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.pk]))
context = csrf(request)
context.update({
'form': form,
'team': team,
})
return render_to_response('sentry/teams/projects/new.html', context, request)
开发者ID:bgyss,项目名称:sentry,代码行数:31,代码来源:teams.py
示例10: create_new_team_project
def create_new_team_project(request, team):
from sentry.web.forms.projects import NewProjectAdminForm, NewProjectForm
if not can_create_projects(request.user, team):
return HttpResponseRedirect(reverse('sentry'))
if request.user.has_perm('sentry.can_add_project'):
form_cls = NewProjectAdminForm
initial = {
'owner': request.user.username,
}
else:
form_cls = NewProjectForm
initial = {}
form = form_cls(request.POST or None, initial=initial)
if form.is_valid():
project = form.save(commit=False)
project.team = team
if not project.owner:
project.owner = request.user
project.save()
if project.platform not in (None, 'other'):
return HttpResponseRedirect(reverse('sentry-docs-client', args=[project.team.slug, project.slug, project.platform]))
return HttpResponseRedirect(reverse('sentry-get-started', args=[project.team.slug, project.slug]))
context = csrf(request)
context.update({
'form': form,
'page': 'projects',
'SUBSECTION': 'new_project',
})
return render_with_team_context(team, 'sentry/teams/projects/new.html', context, request)
开发者ID:DouweM,项目名称:sentry,代码行数:35,代码来源:teams.py
示例11: dashboard
def dashboard(request, team):
project_list = list(Project.objects.filter(team=team))
if not project_list and can_create_projects(request.user, team=team):
return HttpResponseRedirect(reverse("sentry-new-project", args=[team.slug]))
for project in project_list:
project.team = team
return render_to_response("sentry/dashboard.html", {"team": team, "project_list": project_list}, request)
开发者ID:Getsidecar,项目名称:sentry,代码行数:10,代码来源:groups.py
示例12: 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
示例13: dashboard
def dashboard(request, template='dashboard.html'):
project_list = get_project_list(request.user, key='slug')
has_projects = len(project_list) > 1 or (len(project_list) == 1 and project_list.values()[0].pk != settings.PROJECT)
if not has_projects:
if not request.user.is_authenticated():
request.session['_next'] = request.get_full_path()
return HttpResponseRedirect(get_login_url())
elif can_create_projects(request.user):
return HttpResponseRedirect(reverse('sentry-new-project'))
return render_to_response('sentry/%s' % template, {}, request)
开发者ID:fbentz,项目名称:sentry,代码行数:12,代码来源:generic.py
示例14: dashboard
def dashboard(request):
project_list = get_project_list(request.user, key="slug")
has_projects = len(project_list) > 1 or (len(project_list) == 1 and project_list.values()[0].pk != settings.PROJECT)
if not has_projects:
if not request.user.is_authenticated():
request.session["_next"] = request.build_absolute_uri()
return HttpResponseRedirect(get_login_url())
elif can_create_projects(request.user):
return HttpResponseRedirect(reverse("sentry-new-project"))
return render_to_response("sentry/dashboard.html", {}, request)
开发者ID:botondus,项目名称:sentry,代码行数:12,代码来源:generic.py
示例15: dashboard
def dashboard(request, team):
project_list = list(Project.objects.filter(team=team))
if not project_list and can_create_projects(request.user, team=team):
return HttpResponseRedirect(reverse('sentry-new-project', args=[team.slug]))
for project in project_list:
project.team = team
return render_to_response('sentry/dashboard.html', {
'team': team,
'project_list': project_list,
'SECTION': 'events',
}, request)
开发者ID:askfor,项目名称:sentry,代码行数:14,代码来源:groups.py
示例16: dashboard
def dashboard(request, organization, team):
project_list = list(Project.objects.filter(team=team))
if not project_list and can_create_projects(request.user, team=team):
url = reverse('sentry-create-project', args=[team.organization.slug])
return HttpResponseRedirect(url + '?team=' + team.slug)
for project in project_list:
project.team = team
return render_to_response('sentry/dashboard.html', {
'organization': team.organization,
'team': team,
'project_list': project_list,
}, request)
开发者ID:galdwulf,项目名称:sentry,代码行数:15,代码来源:groups.py
示例17: manage_team_projects
def manage_team_projects(request, team):
result = plugins.first('has_perm', request.user, 'edit_team', team)
if result is False and not request.user.has_perm('sentry.can_change_team'):
return HttpResponseRedirect(reverse('sentry'))
project_list = list(team.project_set.all())
context = csrf(request)
context.update({
'can_add_project': can_create_projects(request.user, team),
'page': 'projects',
'team': team,
'project_list': project_list,
})
return render_to_response('sentry/teams/projects/index.html', context, request)
开发者ID:dariobottazzi,项目名称:sentry,代码行数:16,代码来源:teams.py
示例18: post
def post(self, request, team_id):
team = Team.objects.get_from_cache(id=team_id)
assert_perm(team, request.user, request.auth, access=MEMBER_ADMIN)
if not can_create_projects(request.user, team=team_id):
return Response(status=403)
serializer = ProjectSerializer(data=request.DATA)
if serializer.is_valid():
project = serializer.object
project.team = team
project.owner = team.owner
project.save()
return Response(serialize(project, request.user), status=201)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:CrazyLionHeart,项目名称:sentry,代码行数:17,代码来源:team_project_index.py
示例19: manage_team
def manage_team(request, team):
result = plugins.first('has_perm', request.user, 'edit_team', team)
if result is False and not request.user.has_perm('sentry.can_change_team'):
return HttpResponseRedirect(reverse('sentry'))
if request.user.has_perm('sentry.can_add_team'):
form_cls = EditTeamAdminForm
else:
form_cls = EditTeamForm
form = form_cls(request.POST or None, initial={
'owner': team.owner,
}, instance=team)
# XXX: form.is_valid() changes the foreignkey
original_owner = team.owner
if form.is_valid():
team = form.save()
if team.owner != original_owner:
# Update access for new membership if it's changed
# (e.g. member used to be USER, but is now OWNER)
team.member_set.filter(user=team.owner).update(type=MEMBER_OWNER)
return HttpResponseRedirect(request.path + '?success=1')
member_list = [(pm, pm.user) for pm in team.member_set.select_related('user').order_by('user__username')]
pending_member_list = [(pm, pm.email) for pm in team.pending_member_set.all().order_by('email')]
project_list = list(team.project_set.all())
context = csrf(request)
context.update({
'can_add_project': can_create_projects(request.user, team),
'can_add_member': can_add_team_member(request.user, team),
'can_remove_team': can_remove_team(request.user, team),
'page': 'details',
'form': form,
'team': team,
'member_list': member_list,
'pending_member_list': pending_member_list,
'project_list': project_list,
})
return render_to_response('sentry/teams/manage.html', context, request)
开发者ID:allanlei,项目名称:sentry,代码行数:45,代码来源:teams.py
示例20: manage_team_projects
def manage_team_projects(request, team):
result = plugins.first("has_perm", request.user, "edit_team", team)
if result is False and not request.user.has_perm("sentry.can_change_team"):
return HttpResponseRedirect(reverse("sentry"))
project_list = list(team.project_set.all())
context = csrf(request)
context.update(
{
"can_add_project": can_create_projects(request.user, team),
"page": "projects",
"team": team,
"project_list": project_list,
}
)
return render_to_response("sentry/teams/projects/index.html", context, request)
开发者ID:pratz,项目名称:sentry,代码行数:18,代码来源:teams.py
注:本文中的sentry.permissions.can_create_projects函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论