本文整理汇总了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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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')
示例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')