本文整理汇总了Python中sentry.web.helpers.get_login_url函数的典型用法代码示例。如果您正苦于以下问题:Python get_login_url函数的具体用法?Python get_login_url怎么用?Python get_login_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_login_url函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: wrapped
def wrapped(request, *args, **kwargs):
if not request.user.is_authenticated():
request.session['_next'] = request.build_absolute_uri()
return HttpResponseRedirect(get_login_url())
if not request.user.is_staff:
return render_to_response('sentry/missing_permissions.html', status=400)
return func(request, *args, **kwargs)
开发者ID:Crowdbooster,项目名称:sentry,代码行数:7,代码来源:decorators.py
示例2: edit_user
def edit_user(request, user_id):
if not request.is_superuser():
return HttpResponseRedirect(get_login_url())
try:
user = User.objects.get(pk=user_id)
except User.DoesNotExist:
return HttpResponseRedirect(reverse('sentry-admin-users'))
form = ChangeUserForm(request.POST or None, instance=user)
if form.is_valid():
user = form.save()
return HttpResponseRedirect(reverse('sentry-admin-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:WhoTrades,项目名称:sentry,代码行数:27,代码来源:admin.py
示例3: dashboard
def dashboard(request):
project_list = get_project_list(request.user, key='slug')
if len(project_list) == 0 and not request.user.is_authenticated():
return HttpResponseRedirect(get_login_url())
if project_list:
cutoff = datetime.datetime.now() - datetime.timedelta(days=1)
base_qs = Group.objects.filter(
project__in=project_list.values(),
status=0,
).select_related('project').order_by('-score')
top_event_list = list(base_qs.filter(
last_seen__gte=cutoff
)[:10])
new_event_list = list(base_qs.filter(
first_seen__gte=cutoff,
)[:10])
else:
top_event_list = None
new_event_list = None
return render_to_response('sentry/dashboard.html', {
'top_event_list': top_event_list,
'new_event_list': new_event_list,
}, request)
开发者ID:mrooney,项目名称:sentry,代码行数:27,代码来源:generic.py
示例4: dashboard
def dashboard(request):
project_list = get_project_list(request.user, key='slug')
if len(project_list) == 1:
return HttpResponseRedirect(reverse('sentry', kwargs={'project_id': project_list.keys()[0]}))
if len(project_list) == 0 and not request.user.is_authenticated():
return HttpResponseRedirect(get_login_url())
return render_to_response('sentry/dashboard.html', request=request)
开发者ID:Technigami,项目名称:sentry,代码行数:7,代码来源:generic.py
示例5: dashboard
def dashboard(request):
project_list = get_project_list(request.user, key='slug')
if len(project_list) == 0 and not request.user.is_authenticated():
return HttpResponseRedirect(get_login_url())
if project_list:
cutoff = datetime.datetime.now() - datetime.timedelta(days=1)
base_qs = Group.objects.filter(
project__in=project_list.values(),
status=0,
).select_related('project').order_by('-score')
# TODO: change this to calculate the most frequent events in the time period,
# not just events seen within the time period that have at one time been frequent
top_event_list = list(base_qs.filter(
last_seen__gte=cutoff
)[:10])
new_event_list = list(base_qs.filter(
active_at__gte=cutoff,
)[:10])
else:
top_event_list = None
new_event_list = None
return render_to_response('sentry/dashboard.html', {
'top_event_list': top_event_list,
'new_event_list': new_event_list,
}, request)
开发者ID:SimpleTax,项目名称:sentry,代码行数:29,代码来源:generic.py
示例6: handle_auth_required
def handle_auth_required(self, request, *args, **kwargs):
request.session["_next"] = request.get_full_path()
if "organization_slug" in kwargs:
redirect_to = reverse("sentry-auth-organization", args=[kwargs["organization_slug"]])
else:
redirect_to = get_login_url()
return self.redirect(redirect_to)
开发者ID:zenefits,项目名称:sentry,代码行数:7,代码来源:base.py
示例7: _wrapped
def _wrapped(request, *args, **kwargs):
if not request.user.is_authenticated():
request.session['_next'] = request.get_full_path()
return HttpResponseRedirect(get_login_url())
if not request.user.has_perm(perm):
return render_to_response('sentry/missing_permissions.html', status=400)
return func(request, *args, **kwargs)
开发者ID:TracyWebTech,项目名称:sentry,代码行数:7,代码来源:decorators.py
示例8: dashboard
def dashboard(request):
project_list = get_project_list(request.user, key='slug')
if len(project_list) == 0 and not request.user.is_authenticated():
return HttpResponseRedirect(get_login_url())
return render_to_response('sentry/dashboard.html', {
}, request)
开发者ID:NewAgeDev,项目名称:sentry,代码行数:7,代码来源:generic.py
示例9: handle_auth_required
def handle_auth_required(self, request, *args, **kwargs):
request.session['_next'] = request.get_full_path()
if 'organization_slug' in kwargs:
redirect_to = reverse('sentry-auth-organization',
args=[kwargs['organization_slug']])
else:
redirect_to = get_login_url()
return self.redirect(redirect_to)
开发者ID:carriercomm,项目名称:sentry-1,代码行数:8,代码来源:base.py
示例10: test_get_login_url
def test_get_login_url(self):
with self.Settings(LOGIN_URL='/really-a-404'):
url = get_login_url(True)
self.assertEquals(url, reverse('sentry-login'))
with self.Settings(LOGIN_URL=reverse('sentry-fake-login')):
url = get_login_url(True)
self.assertEquals(url, reverse('sentry-fake-login'))
# should still be cached
with self.Settings(LOGIN_URL='/really-a-404'):
url = get_login_url(False)
self.assertEquals(url, reverse('sentry-fake-login'))
with self.Settings(SENTRY_LOGIN_URL=None):
url = get_login_url(True)
self.assertEquals(url, reverse('sentry-login'))
开发者ID:Crowdbooster,项目名称:sentry,代码行数:17,代码来源:tests.py
示例11: handle
def handle(self, request, organization, member_id):
try:
member = OrganizationMember.objects.get(
Q(user__is_active=True) | Q(user__isnull=True),
organization=organization,
id=member_id,
)
except OrganizationMember.DoesNotExist:
return self.redirect(get_login_url())
if request.POST.get('op') == 'reinvite' and member.is_pending:
return self.resend_invite(request, organization, member)
can_admin = request.access.has_scope('member:delete')
if can_admin and not request.is_superuser():
acting_member = OrganizationMember.objects.get(
user=request.user,
organization=organization,
)
if roles.get(acting_member.role).priority < roles.get(member.role).priority:
can_admin = False
else:
allowed_roles = [
r for r in roles.get_all()
if r.priority <= roles.get(acting_member.role).priority
]
can_admin = bool(allowed_roles)
elif request.is_superuser():
allowed_roles = roles.get_all()
if member.user == request.user or not can_admin:
return self.view_member(request, organization, member)
form = self.get_form(request, member, allowed_roles)
if form.is_valid():
member = form.save(request.user, organization, request.META['REMOTE_ADDR'])
messages.add_message(request, messages.SUCCESS,
_('Your changes were saved.'))
redirect = reverse('sentry-organization-member-settings',
args=[organization.slug, member.id])
return self.redirect(redirect)
context = {
'member': member,
'form': form,
'role_list': [
(r, r in allowed_roles)
for r in roles.get_all()
]
}
return self.respond('sentry/organization-member-settings.html', context)
开发者ID:WhoTrades,项目名称:sentry,代码行数:56,代码来源:organization_member_settings.py
示例12: wrapped
def wrapped(request, *args, **kwargs):
if not request.user.is_authenticated():
request.session['_next'] = request.get_full_path()
if 'organization_slug' in kwargs:
redirect_uri = reverse('sentry-auth-organization',
args=[kwargs['organization_slug']])
else:
redirect_uri = get_login_url()
return HttpResponseRedirect(redirect_uri)
return func(request, *args, **kwargs)
开发者ID:AyrtonRicardo,项目名称:sentry,代码行数:10,代码来源:decorators.py
示例13: create_new_user
def create_new_user(request):
if not request.is_superuser():
return HttpResponseRedirect(get_login_url())
form = NewUserForm(request.POST or None, initial={
'send_welcome_mail': True,
'create_project': True,
})
if form.is_valid():
user = form.save(commit=False)
# create a random password
password = uuid.uuid4().hex
user.set_password(password)
user.save()
if form.cleaned_data['send_welcome_mail']:
context = {
'username': user.username,
'password': password,
'url': absolute_uri(get_login_url()),
}
body = render_to_string('sentry/emails/welcome_mail.txt', context, request)
try:
send_mail(
'%s Welcome to Sentry' % (options.get('mail.subject-prefix'),),
body, options.get('mail.from'), [user.email],
fail_silently=False
)
except Exception as e:
logger = logging.getLogger('sentry.mail.errors')
logger.exception(e)
return HttpResponseRedirect(reverse('sentry-admin-users'))
context = {
'form': form,
}
context.update(csrf(request))
return render_to_response('sentry/admin/users/new.html', context, request)
开发者ID:WhoTrades,项目名称:sentry,代码行数:43,代码来源:admin.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, 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
示例16: get_login_redirect
def get_login_redirect(request, default=None):
if default is None:
default = get_login_url()
# If there is a pending 2fa authentication bound to the session then
# we need to go to the 2fa dialog.
if has_pending_2fa(request):
return reverse('sentry-2fa-dialog')
# If we have a different URL to go after the 2fa flow we want to go to
# that now here.
after_2fa = request.session.pop('_after_2fa', None)
if after_2fa is not None:
return after_2fa
login_url = request.session.pop('_next', None) or default
if login_url.startswith(('http://', 'https://')):
login_url = default
elif login_url.startswith(get_login_url()):
login_url = default
return login_url
开发者ID:WhoTrades,项目名称:sentry,代码行数:21,代码来源:auth.py
示例17: configure_plugin
def configure_plugin(request, slug):
plugin = plugins.get(slug)
if not plugin.has_site_conf():
return HttpResponseRedirect(get_login_url())
view = plugin.configure(request=request)
if isinstance(view, HttpResponse):
return view
return render_to_response('sentry/admin/plugins/configure.html', {
'plugin': plugin,
'title': plugin.get_conf_title(),
'slug': plugin.slug,
'view': view,
}, request)
开发者ID:WhoTrades,项目名称:sentry,代码行数:15,代码来源:admin.py
示例18: _wrapped
def _wrapped(request, project_id=None, *args, **kwargs):
# If we're asking for anything other than implied access, the user
# must be authenticated
if group_or_func is not None and not request.user.is_authenticated():
request.session['_next'] = request.build_absolute_uri()
return HttpResponseRedirect(get_login_url())
# XXX: if project_id isn't set, should we only allow superuser?
if not project_id:
return func(request, None, *args, **kwargs)
if project_id.isdigit():
lookup_kwargs = {'id': int(project_id)}
else:
lookup_kwargs = {'slug': project_id}
if request.user.is_superuser:
if project_id:
try:
project = Project.objects.get_from_cache(**lookup_kwargs)
except Project.DoesNotExist:
if project_id.isdigit():
# It could be a numerical slug
try:
project = Project.objects.get_from_cache(slug=project_id)
except Project.DoesNotExist:
return HttpResponseRedirect(reverse('sentry'))
else:
return HttpResponseRedirect(reverse('sentry'))
else:
project = None
return func(request, project, *args, **kwargs)
if project_id:
key, value = lookup_kwargs.items()[0]
project_list = get_project_list(request.user, group_or_func, key=key)
try:
project = project_list[value]
except KeyError:
return HttpResponseRedirect(reverse('sentry'))
else:
project = None
return func(request, project, *args, **kwargs)
开发者ID:Crowdbooster,项目名称:sentry,代码行数:45,代码来源:decorators.py
示例19: dispatch
def dispatch(self, request, *args, **kwargs):
if self.auth_required and not request.user.is_authenticated():
request.session['_next'] = request.get_full_path()
return self.redirect(get_login_url())
if self.sudo_required and not request.is_sudo():
return redirect_to_sudo(request.get_full_path())
args, kwargs = self.convert_args(request, *args, **kwargs)
if not self.has_permission(request, *args, **kwargs):
redirect_uri = self.get_no_permission_url(request, *args, **kwargs)
return self.redirect(redirect_uri)
self.request = request
self.default_context = self.get_context_data(request, *args, **kwargs)
return self.handle(request, *args, **kwargs)
开发者ID:BlueMoebius,项目名称:sentry,代码行数:18,代码来源:base.py
示例20: email_unsubscribe_project
def email_unsubscribe_project(request, project_id):
# For now we only support getting here from the signed link.
if not request.user_from_signed_request:
raise Http404()
try:
project = Project.objects.get(pk=project_id)
except Project.DoesNotExist:
raise Http404()
if request.method == 'POST':
if 'cancel' not in request.POST:
UserOption.objects.set_value(
request.user, project, 'mail:alert', 0)
return HttpResponseRedirect(get_login_url())
context = csrf(request)
context['project'] = project
return render_to_response('sentry/account/email_unsubscribe_project.html',
context, request)
开发者ID:WhoTrades,项目名称:sentry,代码行数:19,代码来源:accounts.py
注:本文中的sentry.web.helpers.get_login_url函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论