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


Python bans.get_user_ban函数代码示例

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


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

示例1: test_expired_ban

    def test_expired_ban(self):
        """user is not caught by expired ban"""
        Ban.objects.create(banned_value='bo*',
                           expires_on=timezone.now() - timedelta(days=7))

        self.assertIsNone(get_user_ban(self.user))
        self.assertFalse(self.user.ban_cache.is_banned)
开发者ID:CAvancouver,项目名称:Misago,代码行数:7,代码来源:test_bans.py

示例2: test_expired_ban

    def test_expired_ban(self):
        """user is not caught by expired ban"""
        Ban.objects.create(banned_value='bo*',
                           valid_until=date.today() - timedelta(days=7))

        self.assertIsNone(get_user_ban(self.user))
        self.assertFalse(self.user.ban_cache.is_banned)
开发者ID:dahito,项目名称:Misago,代码行数:7,代码来源:test_bans.py

示例3: process_request

 def process_request(self, request):
     if request.user.is_anonymous():
         request.user = AnonymousUser()
     elif not request.user.is_superuser:
         if get_request_ip_ban(request) or get_user_ban(request.user):
             logout(request)
     request.user.ip = request._misago_real_ip
开发者ID:ChristosChristofidis,项目名称:Misago,代码行数:7,代码来源:middleware.py

示例4: reset_password_form

def reset_password_form(request, user_id, token):
    User = get_user_model()
    requesting_user = get_object_or_404(User.objects, pk=user_id)

    try:
        if (request.user.is_authenticated() and
                request.user.id != requesting_user.id):
            message = _("%(user)s, your link has expired. "
                        "Please request new link and try again.")
            message = message % {'user': requesting_user.username}
            raise ResetError(message)

        if not is_password_change_token_valid(requesting_user, token):
            message = _("%(user)s, your link is invalid. "
                        "Please try again or request new link.")
            message = message % {'user': requesting_user.username}
            raise ResetError(message)

        ban = get_user_ban(requesting_user)
        if ban:
            raise Banned(ban)
    except ResetError as e:
        return render(request, 'misago/forgottenpassword/error.html', {
                'message': e.args[0],
            }, status=400)

    api_url = reverse('misago:api:change_forgotten_password', kwargs={
        'user_id': user_id,
        'token': token,
    })

    request.frontend_context['CHANGE_PASSWORD_API_URL'] = api_url
    return render(request, 'misago/forgottenpassword/form.html')
开发者ID:Thuruv,项目名称:Misago,代码行数:33,代码来源:forgottenpassword.py

示例5: activate_by_token

def activate_by_token(request, user_id, token):
    User = get_user_model()
    inactive_user = get_object_or_404(User.objects, pk=user_id)

    try:
        if not inactive_user.requires_activation:
            message = _("%(user)s, your account is already active.")
            message = message % {"user": inactive_user.username}
            raise ActivationStopped(message)

        if not is_activation_token_valid(inactive_user, token):
            message = _("%(user)s, your activation link is invalid. " "Try again or request new activation link.")
            message = message % {"user": inactive_user.username}
            raise ActivationError(message)

        ban = get_user_ban(inactive_user)
        if ban:
            raise Banned(ban)
    except ActivationStopped as e:
        return render(request, "misago/activation/stopped.html", {"message": e.args[0]})
    except ActivationError as e:
        return render(request, "misago/activation/error.html", {"message": e.args[0]}, status=400)

    inactive_user.requires_activation = ACTIVATION_REQUIRED_NONE
    inactive_user.save(update_fields=["requires_activation"])

    message = _("%(user)s, your account has been activated!")

    return render(request, "misago/activation/done.html", {"message": message % {"user": inactive_user.username}})
开发者ID:Thuruv,项目名称:Misago,代码行数:29,代码来源:activation.py

示例6: get_context_data

    def get_context_data(self, request, profile):
        ban = get_user_ban(profile)

        request.frontend_context['PROFILE_BAN'] = BanDetailsSerializer(ban).data

        return {
            'ban': ban,
        }
开发者ID:dasdsadadaddasa,项目名称:PythonScientists,代码行数:8,代码来源:profile.py

示例7: user_ban

def user_ban(request, profile):
    ban = get_user_ban(profile)

    request.frontend_context['PROFILE_BAN'] = ban.get_serialized_message()

    return render(request, 'misago/profile/ban_details.html', {
        'profile': profile,
        'ban': ban,
    })
开发者ID:nescode,项目名称:Misago,代码行数:9,代码来源:profile.py

示例8: test_permanent_ban

    def test_permanent_ban(self):
        """user is caught by permanent ban"""
        Ban.objects.create(banned_value="bob", user_message="User reason", staff_message="Staff reason")

        user_ban = get_user_ban(self.user)
        self.assertIsNotNone(user_ban)
        self.assertEqual(user_ban.user_message, "User reason")
        self.assertEqual(user_ban.staff_message, "Staff reason")
        self.assertTrue(self.user.ban_cache.is_banned)
开发者ID:ZerGabriel,项目名称:Misago,代码行数:9,代码来源:test_bans.py

示例9: user_ban

def user_ban(request, profile):
    ban = get_user_ban(profile)
    if not ban:
        raise Http404()

    return render(request, 'misago/profile/ban_details.html', {
        'profile': profile,
        'ban': ban
    })
开发者ID:David1119,项目名称:Misago,代码行数:9,代码来源:profile.py

示例10: ban

    def ban(self, request, pk=None):
        profile = self.get_user(pk)
        allow_see_ban_details(request.user, profile)

        ban = get_user_ban(profile)
        if (ban):
            return Response(BanDetailsSerializer(ban).data)
        else:
            return Response({})
开发者ID:Didan,项目名称:Misago,代码行数:9,代码来源:users.py

示例11: user_ban

def user_ban(request, profile):
    ban = get_user_ban(profile)

    request.frontend_context['PROFILE_BAN'] = BanDetailsSerializer(ban).data

    return render(request, 'misago/profile/ban_details.html', {
        'profile': profile,
        'ban': ban,
    })
开发者ID:mayblue9,项目名称:Misago,代码行数:9,代码来源:profile.py

示例12: can_see_ban_details

 def can_see_ban_details(request, profile):
     if request.user.is_authenticated():
         if request.user.acl['can_see_ban_details']:
             from misago.users.bans import get_user_ban
             return bool(get_user_ban(profile))
         else:
             return False
     else:
         return False
开发者ID:Backenkoehler,项目名称:Misago,代码行数:9,代码来源:apps.py

示例13: test_ban_user

    def test_ban_user(self):
        """ban_user utility bans user"""
        user = UserModel.objects.create_user('Bob', '[email protected]', 'pass123')

        ban = ban_user(user, 'User reason', 'Staff reason')
        self.assertEqual(ban.user_message, 'User reason')
        self.assertEqual(ban.staff_message, 'Staff reason')

        db_ban = get_user_ban(user)
        self.assertEqual(ban.pk, db_ban.ban_id)
开发者ID:dasdsadadaddasa,项目名称:PythonScientists,代码行数:10,代码来源:test_bans.py

示例14: test_ban_user

    def test_ban_user(self):
        """ban_user bans user"""
        User = get_user_model()
        user = User.objects.create_user("Bob", "[email protected]", "pass123")

        ban = ban_user(user, "User reason", "Staff reason")
        self.assertEqual(ban.user_message, "User reason")
        self.assertEqual(ban.staff_message, "Staff reason")

        db_ban = get_user_ban(user)
        self.assertEqual(ban.pk, db_ban.ban_id)
开发者ID:ZerGabriel,项目名称:Misago,代码行数:11,代码来源:test_bans.py

示例15: test_temporary_ban

    def test_temporary_ban(self):
        """user is caught by temporary ban"""
        Ban.objects.create(banned_value='bo*',
                           user_message='User reason',
                           staff_message='Staff reason',
                           expires_on=timezone.now() + timedelta(days=7))

        user_ban = get_user_ban(self.user)
        self.assertIsNotNone(user_ban)
        self.assertEqual(user_ban.user_message, 'User reason')
        self.assertEqual(user_ban.staff_message, 'Staff reason')
        self.assertTrue(self.user.ban_cache.is_banned)
开发者ID:CAvancouver,项目名称:Misago,代码行数:12,代码来源:test_bans.py


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