本文整理汇总了Python中sentry.utils.http.absolute_uri函数的典型用法代码示例。如果您正苦于以下问题:Python absolute_uri函数的具体用法?Python absolute_uri怎么用?Python absolute_uri使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了absolute_uri函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_user
def edit_user(request, user_id):
if not request.is_superuser():
return HttpResponseRedirect(auth.get_login_url())
try:
user = User.objects.get(pk=user_id)
except User.DoesNotExist:
return HttpResponseRedirect(absolute_uri('/manage/users/'))
form = ChangeUserForm(request.POST or None, instance=user)
if form.is_valid():
user = form.save()
return HttpResponseRedirect(absolute_uri('/manage/users/'))
project_list = Project.objects.filter(
status=0,
organization__member_set__user=user,
).order_by('-date_added')
context = {
'form': form,
'the_user': user,
'project_list': project_list,
}
context.update(csrf(request))
return render_to_response('sentry/admin/users/edit.html', context, request)
示例2: remove_user
def remove_user(request, user_id):
if six.text_type(user_id) == six.text_type(request.user.id):
return HttpResponseRedirect(absolute_uri('/manage/users/'))
try:
user = User.objects.get(pk=user_id)
except User.DoesNotExist:
return HttpResponseRedirect(absolute_uri('/manage/users/'))
form = RemoveUserForm(request.POST or None)
if form.is_valid():
if form.cleaned_data['removal_type'] == '2':
user.delete()
else:
User.objects.filter(pk=user.pk).update(is_active=False)
return HttpResponseRedirect(absolute_uri('/manage/users/'))
context = csrf(request)
context.update({
'form': form,
'the_user': user,
})
return render_to_response('sentry/admin/users/remove.html', context, request)
示例3: build_saml_config
def build_saml_config(provider_config, org):
"""
Construct the SAML configuration dict to be passed into the OneLogin SAML
library.
For more details about the structure of this object see the
SAML2Provider.build_config method.
"""
avd = provider_config.get('advanced', {})
security_config = {
'authnRequestsSigned': avd.get('authn_request_signed', False),
'logoutRequestSigned': avd.get('logout_request_signed', False),
'logoutResponseSigned': avd.get('logout_response_signed', False),
'signMetadata': avd.get('metadata_signed', False),
'wantMessagesSigned': avd.get('want_message_signed', False),
'wantAssertionsSigned': avd.get('want_assertion_signed', False),
'wantAssertionsEncrypted': avd.get('want_assertion_encrypted', False),
'signatureAlgorithm': avd.get('signature_algorithm', OneLogin_Saml2_Constants.RSA_SHA256),
'digestAlgorithm': avd.get('digest_algorithm', OneLogin_Saml2_Constants.SHA256),
'wantNameId': False,
}
idp = provider_config['idp']
# TODO(epurkhiser): This is also available in the helper and should probably come from there.
acs_url = absolute_uri(reverse('sentry-auth-organization-saml-acs', args=[org]))
sls_url = absolute_uri(reverse('sentry-auth-organization-saml-sls', args=[org]))
metadata_url = absolute_uri(reverse('sentry-auth-organization-saml-metadata', args=[org]))
saml_config = {
'strict': True,
'idp': {
'entityId': idp['entity_id'],
'x509cert': idp['x509cert'],
'singleSignOnService': {'url': idp['sso_url']},
'singleLogoutService': {'url': idp['slo_url']},
},
'sp': {
'entityId': metadata_url,
'assertionConsumerService': {
'url': acs_url,
'binding': OneLogin_Saml2_Constants.BINDING_HTTP_POST,
},
'singleLogoutService': {
'url': sls_url,
'binding': OneLogin_Saml2_Constants.BINDING_HTTP_REDIRECT,
},
},
'security': security_config,
}
if avd.get('x509cert') is not None:
saml_config['sp']['x509cert'] = avd['x509cert']
if avd.get('private_key') is not None:
saml_config['sp']['privateKey'] = avd['private_key']
return saml_config
示例4: handle
def handle(self, request, organization, team, project):
token = None
if request.method == "POST":
op = request.POST.get("op")
if op == "regenerate-token":
token = self._regenerate_token(project)
messages.add_message(request, messages.SUCCESS, OK_TOKEN_REGENERATED)
elif op == "enable":
self._handle_enable_plugin(request, project)
elif op == "disable":
self._handle_disable_plugin(request, project)
return HttpResponseRedirect(request.path)
if token is None:
token = ProjectOption.objects.get_value(project, "sentry:release-token")
if token is None:
token = self._regenerate_token(project)
enabled_plugins = []
other_plugins = []
for plugin in self._iter_plugins():
if plugin.is_enabled(project):
hook_url = absolute_uri(
reverse(
"sentry-release-hook",
kwargs={
"plugin_id": plugin.slug,
"project_id": project.id,
"signature": self._get_signature(project.id, plugin.slug, token),
},
)
)
content = plugin.get_release_doc_html(hook_url=hook_url)
enabled_plugins.append((plugin, mark_safe(content)))
elif plugin.can_configure_for_project(project):
other_plugins.append(plugin)
context = {
"page": "release-tracking",
"token": token,
"enabled_plugins": enabled_plugins,
"other_plugins": other_plugins,
"webhook_url": absolute_uri(
reverse(
"sentry-release-hook",
kwargs={
"plugin_id": "builtin",
"project_id": project.id,
"signature": self._get_signature(project.id, "builtin", token),
},
)
),
}
return self.respond("sentry/project-release-tracking.html", context)
示例5: dispatch
def dispatch(self, request, pipeline):
client_key = request.GET.get('clientKey')
if client_key is None:
return self.redirect(
'https://bitbucket.org/site/addons/authorize?descriptor_uri=%s&redirect_uri=%s' % (
absolute_uri('/extensions/bitbucket/descriptor/'),
absolute_uri('/extensions/bitbucket/setup/'),
))
pipeline.bind_state('bitbucket_client_key', client_key)
return pipeline.next_step()
示例6: get_absolute_url
def get_absolute_url(self):
# HACK(dcramer): quick and dirty way to support code/users
try:
url_name = self.URL_NAMES[self.key]
except KeyError:
url_name = self.DEFAULT_URL_NAME
return absolute_uri(reverse(url_name, args=[
self.project.organization.slug, self.project.slug, self.key]))
return absolute_uri(reverse(url_name, args=[
self.project.organization.slug, self.project.slug]))
示例7: test_send_alert_event
def test_send_alert_event(self, safe_urlopen):
group = self.create_group(project=self.project)
event = self.create_event(group=group)
rule_future = RuleFuture(
rule=self.rule,
kwargs={'sentry_app': self.sentry_app},
)
with self.feature('organizations:sentry10'):
with self.tasks():
notify_sentry_app(event, [rule_future])
data = json.loads(faux(safe_urlopen).kwargs['data'])
assert data == {
'action': 'triggered',
'installation': {
'uuid': self.install.uuid,
},
'data': {
'event': DictContaining(
event_id=event.event_id,
url=absolute_uri(reverse('sentry-api-0-project-event-details', args=[
self.organization.slug,
self.project.slug,
event.id,
])),
web_url=absolute_uri(reverse('sentry-organization-event-detail', args=[
self.organization.slug,
group.id,
event.id,
])),
issue_url=absolute_uri(
'/api/0/issues/{}/'.format(group.id),
),
),
'triggered_rule': self.rule.label,
},
'actor': {
'type': 'application',
'id': 'sentry',
'name': 'Sentry',
}
}
assert faux(safe_urlopen).kwarg_equals('headers', DictContaining(
'Content-Type',
'Request-ID',
'Sentry-Hook-Resource',
'Sentry-Hook-Timestamp',
'Sentry-Hook-Signature',
))
示例8: get
def get(self, request):
org = Organization(
id=1,
slug='organization',
name='My Company',
)
team = Team(
id=1,
slug='team',
name='My Team',
organization=org,
)
project = Project(
id=1,
organization=org,
team=team,
slug='project',
name='My Project',
)
release = Release(
project=project,
version=sha1(uuid4().hex).hexdigest(),
)
release_link = absolute_uri(reverse('sentry-release-details', kwargs={
'organization_slug': org.slug,
'project_id': project.slug,
'version': release.version,
}))
project_link = absolute_uri(reverse('sentry-stream', kwargs={
'organization_slug': org.slug,
'project_id': project.slug,
}))
preview = MailPreview(
html_template='sentry/emails/activity/release.html',
text_template='sentry/emails/activity/release.txt',
context={
'release': release,
'project': project,
'release_link': release_link,
'project_link': project_link,
},
)
return render_to_response('sentry/debug/mail/preview.html', {
'preview': preview,
})
示例9: handle
def handle(self, request, organization, team, project):
token = None
if request.method == 'POST':
op = request.POST.get('op')
if op == 'regenerate-token':
token = self._regenerate_token(project)
messages.add_message(
request, messages.SUCCESS,
OK_TOKEN_REGENERATED,
)
elif op == 'enable':
self._handle_enable_plugin(request, project)
elif op == 'disable':
self._handle_disable_plugin(request, project)
return HttpResponseRedirect(request.path)
if token is None:
token = ProjectOption.objects.get_value(project, 'sentry:release-token')
if token is None:
token = self._regenerate_token(project)
enabled_plugins = []
other_plugins = []
for plugin in self._iter_plugins():
if plugin.is_enabled(project):
hook_url = absolute_uri(reverse('sentry-release-hook', kwargs={
'plugin_id': plugin.slug,
'project_id': project.id,
'signature': self._get_signature(project.id, plugin.slug, token),
}))
content = plugin.get_release_doc_html(hook_url=hook_url)
enabled_plugins.append((plugin, mark_safe(content)))
elif plugin.can_configure_for_project(project):
other_plugins.append(plugin)
context = {
'page': 'release-tracking',
'token': token,
'enabled_plugins': enabled_plugins,
'other_plugins': other_plugins,
'webhook_url': absolute_uri(reverse('sentry-release-hook', kwargs={
'plugin_id': 'builtin',
'project_id': project.id,
'signature': self._get_signature(project.id, 'builtin', token),
}))
}
return self.respond('sentry/project-release-tracking.html', context)
示例10: dispatch
def dispatch(self, request, pipeline):
if 'completed_installation_guide' in request.GET:
return pipeline.next_step()
return render_to_response(
template='sentry/integrations/gitlab-config.html',
context={
'next_url': '%s%s' % (absolute_uri('extensions/gitlab/setup/'), '?completed_installation_guide'),
'setup_values': [
{'label': 'Name', 'value': 'Sentry'},
{'label': 'Redirect URI', 'value': absolute_uri('/extensions/gitlab/setup/')},
{'label': 'Scopes', 'value': 'api'}
]
},
request=request,
)
示例11: get_absolute_url
def get_absolute_url(self):
# HACK(dcramer): quick and dirty way to support code/users
if self.key == 'sentry:user':
url_name = 'sentry-user-details'
elif self.key == 'sentry:filename':
url_name = 'sentry-explore-code-details'
elif self.key == 'sentry:function':
url_name = 'sentry-explore-code-details-by-function'
else:
url_name = 'sentry-explore-tag-value'
return absolute_uri(reverse(url_name, args=[
self.project.organization.slug, self.project.slug, self.key, self.id]))
return absolute_uri(reverse(url_name, args=[
self.project.organization.slug, self.project.slug, self.id]))
示例12: send_invite_email
def send_invite_email(self):
from sentry.utils.email import MessageBuilder
context = {
'email': self.email,
'organization': self.organization,
'url': absolute_uri(reverse('sentry-accept-invite', kwargs={
'member_id': self.id,
'token': self.token,
})),
}
msg = MessageBuilder(
subject='Join %s in using Sentry' % self.organization.name,
template='sentry/emails/member-invite.txt',
html_template='sentry/emails/member-invite.html',
type='organization.invite',
context=context,
)
try:
msg.send_async([self.get_email()])
except Exception as e:
logger = get_logger(name='sentry.mail')
logger.exception(e)
示例13: get
def get(self, request):
return self.respond(
{
'key': BITBUCKET_KEY,
'name': 'Sentry for Bitbucket',
'description': 'A Sentry integration',
'vendor': {
'name': 'Sentry.io',
'url': 'https://sentry.io/'
},
'baseUrl': absolute_uri(),
'authentication': {
'type': 'JWT',
},
'lifecycle': {
'installed': '/extensions/bitbucket/installed/',
'uninstalled': '/extensions/bitbucket/uninstalled/'
},
'scopes': scopes,
'contexts': ['account'],
# When the user is redirected the URL will become:
# https://sentry.io/extensions/bitbucket/setup/?jwt=1212121212
'modules': {
'postInstallRedirect': {
'url': '/extensions/bitbucket/setup/',
'key': 'redirect'
}
}
}
)
示例14: check
def check(self):
# There is no queue, and celery is not running, so never show error
if settings.CELERY_ALWAYS_EAGER:
return []
last_ping = options.get('sentry:last_worker_ping') or 0
if last_ping >= time() - 300:
return []
backlogged, size = None, 0
from sentry.monitoring.queues import backend
if backend is not None:
size = backend.get_size('default')
backlogged = size > 0
message = "Background workers haven't checked in recently. "
if backlogged:
message += "It seems that you have a backlog of %d tasks. Either your workers aren't running or you need more capacity." % size
else:
message += "This is likely an issue with your configuration or the workers aren't running."
return [
Problem(
message,
url=absolute_uri('/manage/queue/'),
),
]
示例15: test_inbound_status_sync_unresolve
def test_inbound_status_sync_unresolve(self):
responses.add(
responses.GET,
'https://instance.visualstudio.com/c0bf429a-c03c-4a99-9336-d45be74db5a6/_apis/wit/workitemtypes/Bug/states',
json=WORK_ITEM_STATES,
)
work_item_id = 33
num_groups = 5
external_issue = ExternalIssue.objects.create(
organization_id=self.organization.id,
integration_id=self.model.id,
key=work_item_id,
)
groups = [
self.create_linked_group(
external_issue,
self.project,
GroupStatus.RESOLVED) for _ in range(num_groups)]
# Change so that state is changing from resolved to unresolved
work_item = self.set_workitem_state('Resolved', 'Active')
with self.feature('organizations:integrations-issue-sync'):
resp = self.client.post(
absolute_uri('/extensions/vsts/issue-updated/'),
data=work_item,
HTTP_SHARED_SECRET=self.shared_secret,
)
assert resp.status_code == 200
group_ids = [g.id for g in groups]
assert len(
Group.objects.filter(
id__in=group_ids,
status=GroupStatus.UNRESOLVED)) == num_groups
assert len(Activity.objects.filter(group_id__in=group_ids)) == num_groups