当前位置: 首页>>代码示例>>Python>>正文


Python helpers.get_login_url函数代码示例

本文整理汇总了Python中sentry.web.helpers.get_login_url函数的典型用法代码示例。如果您正苦于以下问题:Python get_login_url函数的具体用法?Python get_login_url怎么用?Python get_login_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_login_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的sentry.web.helpers.get_login_url函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。