Rafał Pitoń 8 лет назад
Родитель
Сommit
1b776ca648

+ 15 - 7
misago/users/forms/admin.py

@@ -457,7 +457,11 @@ class BanUsersForm(forms.Form):
 
 
 class BanForm(forms.ModelForm):
-    check_type = forms.TypedChoiceField(label=_("Check type"), coerce=int, choices=Ban.CHOICES,)
+    check_type = forms.TypedChoiceField(
+        label=_("Check type"),
+        coerce=int,
+        choices=Ban.CHOICES,
+    )
     registration_only = YesNoSwitch(
         label=_("Restrict this ban to registrations"),
         help_text=_(
@@ -527,12 +531,16 @@ class BanForm(forms.ModelForm):
 
 
 class SearchBansForm(forms.Form):
-    check_type = forms.ChoiceField(label=_("Type"), required=False, choices=[
-        ('', _('All bans')),
-        ('names', _('Usernames')),
-        ('emails', _('E-mails')),
-        ('ips', _('IPs')),
-    ],)
+    check_type = forms.ChoiceField(
+        label=_("Type"),
+        required=False,
+        choices=[
+            ('', _('All bans')),
+            ('names', _('Usernames')),
+            ('emails', _('E-mails')),
+            ('ips', _('IPs')),
+        ],
+    )
     value = forms.CharField(label=_("Banned value begins with"), required=False)
     registration_only = forms.ChoiceField(
         label=_("Registration only"),

+ 1 - 0
misago/users/forms/register.py

@@ -2,6 +2,7 @@ from django import forms
 from django.contrib.auth import get_user_model
 from django.contrib.auth.password_validation import validate_password
 from django.core.exceptions import ValidationError
+from django.utils.translation import ugettext as _
 
 from misago.users import validators
 from misago.users.bans import get_email_ban, get_ip_ban, get_username_ban

+ 5 - 1
misago/users/migrations/0008_ban_registration_only.py

@@ -20,6 +20,10 @@ class Migration(migrations.Migration):
         migrations.AlterField(
             model_name='ban',
             name='check_type',
-            field=models.PositiveIntegerField(choices=[(0, 'Username'), (1, 'E-mail address'), (2, 'IP address')], db_index=True, default=0),
+            field=models.PositiveIntegerField(
+                choices=[(0, 'Username'), (1, 'E-mail address'), (2, 'IP address')],
+                db_index=True,
+                default=0
+            ),
         ),
     ]

+ 1 - 1
misago/users/models/ban.py

@@ -45,7 +45,7 @@ class BansManager(models.Manager):
 
         queryset = self.filter(
             is_checked=True,
-            registration_only=registration_only
+            registration_only=registration_only,
         )
 
         if len(checks) == 1:

+ 15 - 9
misago/users/tests/test_user_create_api.py

@@ -73,9 +73,11 @@ class UserCreateTests(UserTestCase):
         )
 
         self.assertEqual(response.status_code, 400)
-        self.assertEqual(response.json(), {
-            '__all__': ["You can't register account like this."],
-        })
+        self.assertEqual(
+            response.json(), {
+                '__all__': ["You can't register account like this."],
+            }
+        )
 
     def test_registration_validates_username(self):
         """api validates usernames"""
@@ -112,9 +114,11 @@ class UserCreateTests(UserTestCase):
         )
 
         self.assertEqual(response.status_code, 400)
-        self.assertEqual(response.json(), {
-            'username': ["You can't register account like this."],
-        })
+        self.assertEqual(
+            response.json(), {
+                'username': ["You can't register account like this."],
+            }
+        )
 
     def test_registration_validates_username_registration_ban(self):
         """api validates username registration-only ban"""
@@ -134,9 +138,11 @@ class UserCreateTests(UserTestCase):
         )
 
         self.assertEqual(response.status_code, 400)
-        self.assertEqual(response.json(), {
-            'username': ["You can't register account like this."],
-        })
+        self.assertEqual(
+            response.json(), {
+                'username': ["You can't register account like this."],
+            }
+        )
 
     def test_registration_validates_email(self):
         """api validates usernames"""