Exemple #1
0
 def test_not_banned(self):
     IPBlock.objects.create(
         ip='.'.join(reversed(self.ip.split('.'))),
         moderator=self.staff,
         timestamp=Now(),
     )
     self.assertFalse(is_ip_blocked(self.request))
Exemple #2
0
 def test_banned(self):
     IPBlock.objects.create(
         ip=self.ip,
         moderator=self.staff,
         timestamp=Now(),
     )
     self.assertTrue(is_ip_blocked(self.request))
 def test_not_banned(self):
     IPBlock.objects.create(
         ip='.'.join(reversed(self.ip.split('.'))),
         moderator=self.staff,
         timestamp=Now(),
     )
     self.assertFalse(is_ip_blocked(self.request))
 def test_banned(self):
     IPBlock.objects.create(
         ip=self.ip,
         moderator=self.staff,
         timestamp=Now(),
     )
     self.assertTrue(is_ip_blocked(self.request))
Exemple #5
0
def require_unblocked_ip(request):
    if is_ip_blocked(request):
        raise PermissionDenied()
def require_unblocked_ip(request):
    if is_ip_blocked(request):
        raise PermissionDenied()