本文整理汇总了Python中sentry.plugins.helpers.set_option函数的典型用法代码示例。如果您正苦于以下问题:Python set_option函数的具体用法?Python set_option怎么用?Python set_option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_option函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_update_is_not_available
def test_update_is_not_available(self):
set_option('sentry:latest_version', '5.5.1')
with mock.patch('sentry.get_version') as get_version:
get_version.return_value = '5.5.0'
resp = self.client.get(self.path)
assert self.UPDATE_MESSAGE in resp.content
开发者ID:CaseCommonsDevOps,项目名称:sentry,代码行数:7,代码来源:tests.py
示例2: manage_project
def manage_project(request, project):
result = plugins.first('has_perm', request.user, 'edit_project', project)
if result is False and not request.user.has_perm('sentry.can_change_project'):
return HttpResponseRedirect(reverse('sentry'))
# XXX: We probably shouldnt allow changing the team unless they're the project owner
team_list = Team.objects.get_for_user(project.owner or request.user, MEMBER_OWNER)
if request.user.has_perm('sentry.can_change_project'):
form_cls = EditProjectAdminForm
else:
form_cls = EditProjectForm
form = form_cls(request, team_list, request.POST or None, instance=project, initial={
'origins': '\n'.join(get_option('sentry:origins', project) or []),
'owner': project.owner,
})
if form.is_valid():
project = form.save()
set_option('sentry:origins', form.cleaned_data.get('origins') or [], project)
return HttpResponseRedirect(request.path + '?success=1')
context = csrf(request)
context.update({
'can_remove_project': can_remove_project(request.user, project),
'page': 'details',
'form': form,
'project': project,
'TEAM_LIST': team_list.values(),
'SECTION': 'settings',
})
return render_to_response('sentry/projects/manage.html', context, request)
开发者ID:cheekybastard,项目名称:sentry,代码行数:34,代码来源:projects.py
示例3: test_set_sentry_version_old
def test_set_sentry_version_old(self, get_version):
set_option(self.KEY, self.NEW)
get_version.return_value = self.CURRENT
set_sentry_version(latest=self.OLD)
self.assertEqual(Option.objects.get_value(key=self.KEY), self.NEW)
开发者ID:CrazyLionHeart,项目名称:sentry,代码行数:8,代码来源:tests.py
示例4: test_set_sentry_version_old
def test_set_sentry_version_old(self):
set_option(self.KEY, self.NEW)
with mock.patch('sentry.get_version') as get_version:
get_version.return_value = self.CURRENT
set_sentry_version(latest=self.OLD)
self.assertEqual(Option.objects.get_value(key=self.KEY), self.NEW)
开发者ID:CaseCommonsDevOps,项目名称:sentry,代码行数:9,代码来源:tests.py
示例5: set_option
def set_option(self, key, value, project=None, user=None):
"""
Updates the value of an option in your plugins keyspace.
If ``project`` is passed, it will limit the scope to that project's keyspace.
>>> plugin.set_option('my_option', 'http://example.com')
"""
from sentry.plugins.helpers import set_option
return set_option(self._get_option_key(key), value, project, user)
开发者ID:alexandrul,项目名称:sentry,代码行数:10,代码来源:v1.py
示例6: manage_project
def manage_project(request, project):
result = plugins.first("has_perm", request.user, "edit_project", project)
if result is False and not request.user.has_perm("sentry.can_change_project"):
return HttpResponseRedirect(reverse("sentry"))
team_list = Team.objects.get_for_user(request.user, MEMBER_OWNER)
if request.user.has_perm("sentry.can_change_project"):
form_cls = EditProjectAdminForm
else:
form_cls = EditProjectForm
form = form_cls(
request,
team_list,
request.POST or None,
instance=project,
initial={"origins": "\n".join(get_option("sentry:origins", project) or []), "owner": project.owner},
)
if form.is_valid():
project = form.save()
set_option("sentry:origins", form.cleaned_data.get("origins") or [], project)
return HttpResponseRedirect(request.path + "?success=1")
if not project.team:
member_list = []
else:
member_list = [(tm, tm.user) for tm in project.team.member_set.select_related("user")]
context = csrf(request)
context.update(
{
"can_remove_project": can_remove_project(request.user, project),
"page": "details",
"form": form,
"project": project,
"member_list": member_list,
"TEAM_LIST": team_list.values(),
}
)
return render_to_response("sentry/projects/manage.html", context, request)
开发者ID:nkabir,项目名称:sentry,代码行数:43,代码来源:projects.py
示例7: manage_project
def manage_project(request, team, project):
result = plugins.first('has_perm', request.user, 'edit_project', project)
if result is False and not request.user.has_perm('sentry.can_change_project'):
return HttpResponseRedirect(reverse('sentry'))
# XXX: We probably shouldnt allow changing the team unless they're the project owner
team_list = Team.objects.get_for_user(project.owner or request.user, MEMBER_OWNER)
can_admin_project = request.user == project.owner or request.user.has_perm('sentry.can_change_project')
if can_admin_project:
form_cls = EditProjectAdminForm
else:
form_cls = EditProjectForm
form = form_cls(request, team_list, request.POST or None, instance=project, initial={
'origins': '\n'.join(get_option('sentry:origins', project) or []),
'owner': project.owner,
})
if form.is_valid():
project = form.save()
set_option('sentry:origins', form.cleaned_data.get('origins') or [], project)
messages.add_message(request, messages.SUCCESS,
_('Changes to your project were saved.'))
return HttpResponseRedirect(reverse('sentry-manage-project', args=[team.slug, project.slug]))
context = csrf(request)
context.update({
'team': team,
'can_remove_project': can_remove_project(request.user, project),
'page': 'details',
'form': form,
'project': project,
'SECTION': 'team',
'SUBSECTION': 'projects'
})
return render_to_response('sentry/projects/manage.html', context, request)
开发者ID:TracyWebTech,项目名称:sentry,代码行数:41,代码来源:projects.py
示例8: manage_project
def manage_project(request, project):
result = plugins.first('has_perm', request.user, 'edit_project', project)
if result is False and not request.user.has_perm('sentry.can_change_project'):
return HttpResponseRedirect(reverse('sentry'))
team_list = Team.objects.get_for_user(request.user, MEMBER_OWNER)
if request.user.has_perm('sentry.can_change_project'):
form_cls = EditProjectAdminForm
else:
form_cls = EditProjectForm
form = form_cls(request, team_list, request.POST or None, instance=project, initial={
'origins': '\n'.join(get_option('sentry:origins', project) or []),
'owner': project.owner,
})
if form.is_valid():
project = form.save()
set_option('sentry:origins', form.cleaned_data.get('origins') or [], project)
return HttpResponseRedirect(request.path + '?success=1')
if not project.team:
member_list = []
else:
member_list = [(tm, tm.user) for tm in project.team.member_set.select_related('user')]
context = csrf(request)
context.update({
'can_remove_project': can_remove_project(request.user, project),
'page': 'details',
'form': form,
'project': project,
'member_list': member_list,
'TEAM_LIST': team_list.values(),
})
return render_to_response('sentry/projects/manage.html', context, request)
开发者ID:Fashiolista,项目名称:sentry,代码行数:38,代码来源:projects.py
示例9: test_set_option_without_project
def test_set_option_without_project(self):
with mock.patch('sentry.models.Option.objects.set_value') as set_value:
set_option('key', 'value')
set_value.assert_called_once_with('key', 'value')
开发者ID:755,项目名称:sentry,代码行数:5,代码来源:tests.py
示例10: test_set_option_with_project
def test_set_option_with_project(self):
with mock.patch('sentry.models.ProjectOption.objects.set_value') as set_value:
project = mock.Mock()
set_option('key', 'value', project)
set_value.assert_called_once_with(project, 'key', 'value')
开发者ID:755,项目名称:sentry,代码行数:6,代码来源:tests.py
注:本文中的sentry.plugins.helpers.set_option函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论