本文整理汇总了Python中sentry.utils.http.absolute_uri函数的典型用法代码示例。如果您正苦于以下问题:Python absolute_uri函数的具体用法?Python absolute_uri怎么用?Python absolute_uri使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了absolute_uri函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:duanshuaimin,项目名称:sentry,代码行数:27,代码来源:admin.py
示例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)
开发者ID:duanshuaimin,项目名称:sentry,代码行数:25,代码来源:admin.py
示例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
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:59,代码来源:saml2.py
示例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)
开发者ID:AyrtonRicardo,项目名称:sentry,代码行数:56,代码来源:project_release_tracking.py
示例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()
开发者ID:binlee1990,项目名称:sentry,代码行数:10,代码来源:provider.py
示例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]))
开发者ID:ChadKillingsworth,项目名称:sentry,代码行数:11,代码来源:tagkey.py
示例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',
))
开发者ID:yaoqi,项目名称:sentry,代码行数:52,代码来源:test_sentry_apps.py
示例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,
})
开发者ID:carriercomm,项目名称:sentry-1,代码行数:49,代码来源:debug_new_release_email.py
示例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)
开发者ID:ForkRepo,项目名称:sentry,代码行数:49,代码来源:project_release_tracking.py
示例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,
)
开发者ID:Kayle009,项目名称:sentry,代码行数:15,代码来源:integration.py
示例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]))
开发者ID:KinKir,项目名称:sentry,代码行数:15,代码来源:tagvalue.py
示例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)
开发者ID:WhoTrades,项目名称:sentry,代码行数:25,代码来源:organizationmember.py
示例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'
}
}
}
)
开发者ID:Kayle009,项目名称:sentry,代码行数:30,代码来源:descriptor.py
示例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/'),
),
]
开发者ID:Kayle009,项目名称:sentry,代码行数:26,代码来源:celery_alive.py
示例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
开发者ID:Kayle009,项目名称:sentry,代码行数:35,代码来源:test_webhooks.py
示例16: send_invite_email
def send_invite_email(self):
from django.core.mail import send_mail
from sentry.web.helpers import render_to_string
context = {
'email':
self.email,
'team':
self.team,
'url':
absolute_uri(
reverse(
'sentry-accept-invite',
kwargs={
'member_id': self.id,
'token': self.token,
})),
}
body = render_to_string('sentry/emails/member_invite.txt', context)
try:
send_mail(
'%sInvite to join team: %s' % (settings.EMAIL_SUBJECT_PREFIX,
self.team.name),
body,
settings.SERVER_EMAIL, [self.email],
fail_silently=False)
except Exception, e:
logger = logging.getLogger('sentry.mail.errors')
logger.exception(e)
开发者ID:theatlantic,项目名称:django-sentry,代码行数:30,代码来源:models.py
示例17: send_recover_mail
def send_recover_mail(self):
from django.core.mail import send_mail
from sentry.web.helpers import render_to_string
context = {
'user':
self.user,
'domain':
urlparse.urlparse(settings.SENTRY_URL_PREFIX).hostname,
'url':
absolute_uri(
reverse(
'sentry-account-recover-confirm',
args=[self.user.id, self.hash])),
}
body = render_to_string('sentry/emails/recover_account.txt', context)
try:
send_mail(
'%sPassword Recovery' % (settings.EMAIL_SUBJECT_PREFIX, ),
body,
settings.SERVER_EMAIL, [self.user.email],
fail_silently=False)
except Exception, e:
logger = logging.getLogger('sentry.mail.errors')
logger.exception(e)
开发者ID:theatlantic,项目名称:django-sentry,代码行数:26,代码来源:models.py
示例18: render
def render(self, context):
from sentry.utils.http import absolute_uri
# Attempt to resolve all arguments into actual variables.
# This converts a value such as `"foo"` into the string `foo`
# and will look up a value such as `foo` from the context as
# the variable `foo`. If the variable does not exist, silently
# resolve as an empty string, which matches the behavior
# `SimpleTagNode`
args = []
for arg in self.args:
try:
arg = template.Variable(arg).resolve(context)
except template.VariableDoesNotExist:
arg = ''
args.append(arg)
# No args is just fine
if not args:
rv = ''
# If there's only 1 argument, there's nothing to format
elif len(args) == 1:
rv = args[0]
else:
rv = args[0].format(*args[1:])
rv = absolute_uri(rv)
# We're doing an `as foo` and we want to assign the result
# to a variable instead of actually returning.
if self.target_var is not None:
context[self.target_var] = rv
rv = ''
return rv
开发者ID:binlee1990,项目名称:sentry,代码行数:35,代码来源:sentry_helpers.py
示例19: request_access
def request_access(request):
org = Organization(
id=1,
slug='example',
name='Example',
)
team = Team(
id=1,
slug='example',
name='Example',
organization=org,
)
return MailPreview(
html_template='sentry/emails/request-team-access.html',
text_template='sentry/emails/request-team-access.txt',
context={
'email': '[email protected]',
'name': 'George Bush',
'organization': org,
'team': team,
'url': absolute_uri(reverse('sentry-organization-members', kwargs={
'organization_slug': org.slug,
}) + '?ref=access-requests'),
},
).render()
开发者ID:zooming-tan,项目名称:sentry,代码行数:26,代码来源:mail.py
示例20: serialize
def serialize(self, obj, attrs, user):
from sentry.api.endpoints.project_releases_token import _get_webhook_url
doc = ''
if self.project is not None:
release_token = ProjectOption.objects.get_value(self.project, 'sentry:release-token')
if release_token is not None:
webhook_url = _get_webhook_url(self.project, obj.slug, release_token)
if hasattr(obj, 'get_release_doc_html'):
try:
doc = obj.get_release_doc_html(webhook_url)
except NotImplementedError:
pass
contexts = []
if hasattr(obj, 'get_custom_contexts'):
contexts.extend(x.type for x in obj.get_custom_contexts() or ())
d = {
'id': obj.slug,
'name': six.text_type(obj.get_title()),
'slug': obj.slug or slugify(six.text_type(obj.get_title())),
'shortName': six.text_type(obj.get_short_title()),
'type': obj.get_plugin_type(),
'canDisable': obj.can_disable,
'isTestable': hasattr(obj, 'is_testable') and obj.is_testable(),
'hasConfiguration': obj.has_project_conf(),
'metadata': obj.get_metadata(),
'contexts': contexts,
'status': obj.get_status(),
'assets': [
{
'url': absolute_uri(get_asset_url(obj.asset_key or obj.slug, asset)),
} for asset in obj.get_assets()
],
'doc': doc,
}
if self.project:
d['enabled'] = obj.is_enabled(self.project)
if obj.version:
d['version'] = six.text_type(obj.version)
if obj.author:
d['author'] = {
'name': six.text_type(obj.author),
'url': six.text_type(obj.author_url)
}
d['isHidden'] = d.get('enabled', False) is False and obj.is_hidden()
if obj.description:
d['description'] = six.text_type(obj.description)
if obj.resource_links:
d['resourceLinks'] = [
{'title': title, 'url': url} for [title, url] in obj.resource_links
]
return d
开发者ID:Kayle009,项目名称:sentry,代码行数:60,代码来源:plugin.py
注:本文中的sentry.utils.http.absolute_uri函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论