Browse Source

Merge pull request #1154 from rafalp/rename-usermodel-to-user

Rename UserModel to User
Rafał Pitoń 6 years ago
parent
commit
39e104a9fa
91 changed files with 391 additions and 468 deletions
  1. 5 5
      misago/admin/tests/test_admin_views.py
  2. 4 4
      misago/admin/views/index.py
  3. 9 9
      misago/core/tests/test_mail.py
  4. 5 5
      misago/faker/management/commands/createfakefollowers.py
  5. 4 4
      misago/faker/management/commands/createfakethreads.py
  6. 2 2
      misago/faker/management/commands/createfakeusers.py
  7. 3 3
      misago/markup/mentions.py
  8. 2 2
      misago/markup/tests/test_parser.py
  9. 3 7
      misago/readtracker/tests/test_clearreadtracker.py
  10. 2 2
      misago/readtracker/tests/test_poststracker.py
  11. 2 2
      misago/threads/api/postingendpoint/participants.py
  12. 5 7
      misago/threads/api/postingendpoint/subscribe.py
  13. 3 3
      misago/threads/api/threadendpoints/patch.py
  14. 2 4
      misago/threads/participants.py
  15. 3 3
      misago/threads/tests/test_anonymize_data.py
  16. 3 3
      misago/threads/tests/test_delete_user_likes.py
  17. 2 4
      misago/threads/tests/test_emailnotification_middleware.py
  18. 2 2
      misago/threads/tests/test_mergeconflict.py
  19. 23 33
      misago/threads/tests/test_participants.py
  20. 6 10
      misago/threads/tests/test_post_mentions.py
  21. 3 3
      misago/threads/tests/test_post_model.py
  22. 26 52
      misago/threads/tests/test_privatethread_patch_api.py
  23. 4 6
      misago/threads/tests/test_privatethread_reply_api.py
  24. 5 5
      misago/threads/tests/test_privatethread_start_api.py
  25. 11 11
      misago/threads/tests/test_subscription_middleware.py
  26. 2 2
      misago/threads/tests/test_subscriptions.py
  27. 2 2
      misago/threads/tests/test_sync_unread_private_threads.py
  28. 8 10
      misago/threads/tests/test_thread_model.py
  29. 3 3
      misago/threads/tests/test_thread_pollvotes_api.py
  30. 7 11
      misago/threads/tests/test_threadparticipant_model.py
  31. 4 4
      misago/threads/testutils.py
  32. 2 2
      misago/users/activepostersranking.py
  33. 3 3
      misago/users/api/auth.py
  34. 4 4
      misago/users/api/mention.py
  35. 5 5
      misago/users/api/userendpoints/create.py
  36. 1 1
      misago/users/api/userendpoints/list.py
  37. 2 2
      misago/users/api/usernamechanges.py
  38. 2 2
      misago/users/api/users.py
  39. 6 6
      misago/users/authbackends.py
  40. 8 8
      misago/users/forms/admin.py
  41. 4 4
      misago/users/forms/auth.py
  42. 2 2
      misago/users/forms/register.py
  43. 3 4
      misago/users/management/commands/deleteinactiveusers.py
  44. 2 2
      misago/users/management/commands/deletemarkedusers.py
  45. 2 2
      misago/users/management/commands/deleteprofilefield.py
  46. 2 2
      misago/users/management/commands/listusedprofilefields.py
  47. 2 2
      misago/users/management/commands/populateonlinetracker.py
  48. 3 3
      misago/users/management/commands/synchronizeusers.py
  49. 2 2
      misago/users/search.py
  50. 2 2
      misago/users/serializers/auth.py
  51. 3 3
      misago/users/serializers/moderation.py
  52. 3 3
      misago/users/serializers/options.py
  53. 2 2
      misago/users/serializers/user.py
  54. 2 2
      misago/users/signals.py
  55. 8 8
      misago/users/social/pipeline.py
  56. 5 7
      misago/users/tests/test_activepostersranking.py
  57. 8 8
      misago/users/tests/test_audittrail.py
  58. 15 15
      misago/users/tests/test_auth_api.py
  59. 2 2
      misago/users/tests/test_auth_backend.py
  60. 2 2
      misago/users/tests/test_avatarserver_views.py
  61. 3 3
      misago/users/tests/test_bans.py
  62. 1 1
      misago/users/tests/test_bio_profilefield.py
  63. 2 2
      misago/users/tests/test_credentialchange.py
  64. 2 2
      misago/users/tests/test_datadownloadsadmin_views.py
  65. 15 15
      misago/users/tests/test_deleteinactiveusers.py
  66. 9 9
      misago/users/tests/test_deletemarkedusers.py
  67. 3 3
      misago/users/tests/test_deleteprofilefield.py
  68. 6 6
      misago/users/tests/test_forgottenpassword_views.py
  69. 1 1
      misago/users/tests/test_gender_profilefield.py
  70. 3 3
      misago/users/tests/test_invalidatebans.py
  71. 1 1
      misago/users/tests/test_joinip_profilefield.py
  72. 5 5
      misago/users/tests/test_listusedprofilefields.py
  73. 2 2
      misago/users/tests/test_misagoavatars_tags.py
  74. 2 2
      misago/users/tests/test_populateonlinetracker.py
  75. 3 3
      misago/users/tests/test_profile_views.py
  76. 1 1
      misago/users/tests/test_profilefields.py
  77. 7 13
      misago/users/tests/test_removeoldips.py
  78. 2 2
      misago/users/tests/test_search.py
  79. 20 24
      misago/users/tests/test_social_pipeline.py
  80. 3 3
      misago/users/tests/test_tokens.py
  81. 1 1
      misago/users/tests/test_twitter_profilefield.py
  82. 2 2
      misago/users/tests/test_user_changeemail_api.py
  83. 2 4
      misago/users/tests/test_user_details_api.py
  84. 3 5
      misago/users/tests/test_user_editdetails_api.py
  85. 1 1
      misago/users/tests/test_user_model.py
  86. 3 3
      misago/users/tests/test_user_username_api.py
  87. 3 3
      misago/users/tests/test_validators.py
  88. 5 5
      misago/users/validators.py
  89. 3 3
      misago/users/views/activation.py
  90. 3 3
      misago/users/views/avatarserver.py
  91. 2 4
      misago/users/views/profile.py

+ 5 - 5
misago/admin/tests/test_admin_views.py

@@ -6,7 +6,7 @@ from misago.admin.testutils import AdminTestCase
 from misago.admin.views import get_protected_namespace
 from misago.admin.views import get_protected_namespace
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class MockRequest(object):
 class MockRequest(object):
@@ -56,7 +56,7 @@ class AdminLoginViewTests(TestCase):
 
 
     def test_login_denies_non_staff_non_superuser(self):
     def test_login_denies_non_staff_non_superuser(self):
         """login rejects user thats non staff and non superuser"""
         """login rejects user thats non staff and non superuser"""
-        user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         user.is_staff = False
         user.is_staff = False
         user.is_superuser = False
         user.is_superuser = False
@@ -71,7 +71,7 @@ class AdminLoginViewTests(TestCase):
 
 
     def test_login_denies_non_staff_superuser(self):
     def test_login_denies_non_staff_superuser(self):
         """login rejects user thats non staff and superuser"""
         """login rejects user thats non staff and superuser"""
-        user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         user.is_staff = False
         user.is_staff = False
         user.is_superuser = True
         user.is_superuser = True
@@ -86,7 +86,7 @@ class AdminLoginViewTests(TestCase):
 
 
     def test_login_signs_in_staff_non_superuser(self):
     def test_login_signs_in_staff_non_superuser(self):
         """login passess user thats staff and non superuser"""
         """login passess user thats staff and non superuser"""
-        user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         user.is_staff = True
         user.is_staff = True
         user.is_superuser = False
         user.is_superuser = False
@@ -101,7 +101,7 @@ class AdminLoginViewTests(TestCase):
 
 
     def test_login_signs_in_staff_superuser(self):
     def test_login_signs_in_staff_superuser(self):
         """login passess user thats staff and superuser"""
         """login passess user thats staff and superuser"""
-        user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         user.is_staff = True
         user.is_staff = True
         user.is_superuser = True
         user.is_superuser = True

+ 4 - 4
misago/admin/views/index.py

@@ -15,18 +15,18 @@ from . import render
 
 
 VERSION_CHECK_CACHE_KEY = "misago_version_check"
 VERSION_CHECK_CACHE_KEY = "misago_version_check"
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 def admin_index(request):
 def admin_index(request):
-    inactive_users_queryset = UserModel.objects.exclude(
-        requires_activation=UserModel.ACTIVATION_NONE
+    inactive_users_queryset = User.objects.exclude(
+        requires_activation=User.ACTIVATION_NONE
     )
     )
 
 
     db_stats = {
     db_stats = {
         "threads": Thread.objects.count(),
         "threads": Thread.objects.count(),
         "posts": Post.objects.count(),
         "posts": Post.objects.count(),
-        "users": UserModel.objects.count(),
+        "users": User.objects.count(),
         "inactive_users": inactive_users_queryset.count(),
         "inactive_users": inactive_users_queryset.count(),
     }
     }
 
 

+ 9 - 9
misago/core/tests/test_mail.py

@@ -9,17 +9,17 @@ from misago.conf.dynamicsettings import DynamicSettings
 from misago.core.mail import build_mail, mail_user, mail_users
 from misago.core.mail import build_mail, mail_user, mail_users
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class MailTests(TestCase):
 class MailTests(TestCase):
     def test_building_mail_without_context_raises_value_error(self):
     def test_building_mail_without_context_raises_value_error(self):
-        user = UserModel.objects.create_user("Bob", "bob@bob.com", "pass123")
+        user = User.objects.create_user("Bob", "bob@bob.com", "pass123")
         with self.assertRaises(ValueError):
         with self.assertRaises(ValueError):
             build_mail(user, "Misago Test Mail", "misago/emails/base")
             build_mail(user, "Misago Test Mail", "misago/emails/base")
 
 
     def test_building_mail_without_settings_in_context_raises_value_error(self):
     def test_building_mail_without_settings_in_context_raises_value_error(self):
-        user = UserModel.objects.create_user("Bob", "bob@bob.com", "pass123")
+        user = User.objects.create_user("Bob", "bob@bob.com", "pass123")
         with self.assertRaises(ValueError):
         with self.assertRaises(ValueError):
             build_mail(
             build_mail(
                 user, "Misago Test Mail", "misago/emails/base", context={"settings": {}}
                 user, "Misago Test Mail", "misago/emails/base", context={"settings": {}}
@@ -27,7 +27,7 @@ class MailTests(TestCase):
 
 
     def test_mail_user(self):
     def test_mail_user(self):
         """mail_user sets message in backend"""
         """mail_user sets message in backend"""
-        user = UserModel.objects.create_user("Bob", "bob@bob.com", "pass123")
+        user = User.objects.create_user("Bob", "bob@bob.com", "pass123")
 
 
         cache_versions = get_cache_versions()
         cache_versions = get_cache_versions()
         settings = DynamicSettings(cache_versions)
         settings = DynamicSettings(cache_versions)
@@ -55,11 +55,11 @@ class MailTests(TestCase):
         settings = DynamicSettings(cache_versions)
         settings = DynamicSettings(cache_versions)
 
 
         test_users = [
         test_users = [
-            UserModel.objects.create_user("Alpha", "alpha@test.com", "pass123"),
-            UserModel.objects.create_user("Beta", "beta@test.com", "pass123"),
-            UserModel.objects.create_user("Niner", "niner@test.com", "pass123"),
-            UserModel.objects.create_user("Foxtrot", "foxtrot@test.com", "pass123"),
-            UserModel.objects.create_user("Uniform", "uniform@test.com", "pass123"),
+            User.objects.create_user("Alpha", "alpha@test.com", "pass123"),
+            User.objects.create_user("Beta", "beta@test.com", "pass123"),
+            User.objects.create_user("Niner", "niner@test.com", "pass123"),
+            User.objects.create_user("Foxtrot", "foxtrot@test.com", "pass123"),
+            User.objects.create_user("Uniform", "uniform@test.com", "pass123"),
         ]
         ]
 
 
         mail_users(
         mail_users(

+ 5 - 5
misago/faker/management/commands/createfakefollowers.py

@@ -7,14 +7,14 @@ from django.core.management.base import BaseCommand
 from misago.core.management.progressbar import show_progress
 from misago.core.management.progressbar import show_progress
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class Command(BaseCommand):
 class Command(BaseCommand):
     help = "Adds random followers for testing purposes"
     help = "Adds random followers for testing purposes"
 
 
     def handle(self, *args, **options):
     def handle(self, *args, **options):
-        total_users = UserModel.objects.count()
+        total_users = User.objects.count()
 
 
         message = "Adding fake followers to %s users...\n"
         message = "Adding fake followers to %s users...\n"
         self.stdout.write(message % total_users)
         self.stdout.write(message % total_users)
@@ -24,7 +24,7 @@ class Command(BaseCommand):
 
 
         start_time = time.time()
         start_time = time.time()
         show_progress(self, processed_count, total_users)
         show_progress(self, processed_count, total_users)
-        for user in UserModel.objects.iterator():
+        for user in User.objects.iterator():
             user.followed_by.clear()
             user.followed_by.clear()
 
 
             if random.randint(1, 100) > 10:
             if random.randint(1, 100) > 10:
@@ -33,7 +33,7 @@ class Command(BaseCommand):
                 continue  # 10% active users
                 continue  # 10% active users
 
 
             users_to_add = random.randint(1, total_users / 5)
             users_to_add = random.randint(1, total_users / 5)
-            random_queryset = UserModel.objects.exclude(id=user.id).order_by("?")
+            random_queryset = User.objects.exclude(id=user.id).order_by("?")
             while users_to_add > 0:
             while users_to_add > 0:
                 new_follower = random_queryset[:1][0]
                 new_follower = random_queryset[:1][0]
                 if not new_follower.is_following(user):
                 if not new_follower.is_following(user):
@@ -45,7 +45,7 @@ class Command(BaseCommand):
             show_progress(self, processed_count, total_users)
             show_progress(self, processed_count, total_users)
 
 
         self.stdout.write("\nSyncing models...")
         self.stdout.write("\nSyncing models...")
-        for user in UserModel.objects.iterator():
+        for user in User.objects.iterator():
             user.followers = user.followed_by.count()
             user.followers = user.followed_by.count()
             user.following = user.follows.count()
             user.following = user.follows.count()
             user.save(update_fields=["followers", "following"])
             user.save(update_fields=["followers", "following"])

+ 4 - 4
misago/faker/management/commands/createfakethreads.py

@@ -17,7 +17,7 @@ from misago.threads.models import Post, Thread
 
 
 PLACEKITTEN_URL = "https://placekitten.com/g/%s/%s"
 PLACEKITTEN_URL = "https://placekitten.com/g/%s/%s"
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 corpus = EnglishCorpus()
 corpus = EnglishCorpus()
 corpus_short = EnglishCorpus(max_length=150)
 corpus_short = EnglishCorpus(max_length=150)
@@ -53,7 +53,7 @@ class Command(BaseCommand):
             with atomic():
             with atomic():
                 datetime = timezone.now()
                 datetime = timezone.now()
                 category = random.choice(categories)
                 category = random.choice(categories)
-                user = UserModel.objects.order_by("?")[:1][0]
+                user = User.objects.order_by("?")[:1][0]
 
 
                 thread_is_unapproved = random.randint(0, 100) > 90
                 thread_is_unapproved = random.randint(0, 100) > 90
                 thread_is_hidden = random.randint(0, 100) > 90
                 thread_is_hidden = random.randint(0, 100) > 90
@@ -108,7 +108,7 @@ class Command(BaseCommand):
 
 
                 for _ in range(thread_replies):
                 for _ in range(thread_replies):
                     datetime = timezone.now()
                     datetime = timezone.now()
-                    user = UserModel.objects.order_by("?")[:1][0]
+                    user = User.objects.order_by("?")[:1][0]
 
 
                     original, parsed = self.fake_post_content()
                     original, parsed = self.fake_post_content()
 
 
@@ -135,7 +135,7 @@ class Command(BaseCommand):
                         post.is_hidden = True
                         post.is_hidden = True
 
 
                         if random.randint(0, 100) < 80:
                         if random.randint(0, 100) < 80:
-                            user = UserModel.objects.order_by("?")[:1][0]
+                            user = User.objects.order_by("?")[:1][0]
                             post.hidden_by = user
                             post.hidden_by = user
                             post.hidden_by_name = user.username
                             post.hidden_by_name = user.username
                             post.hidden_by_slug = user.username
                             post.hidden_by_slug = user.username

+ 2 - 2
misago/faker/management/commands/createfakeusers.py

@@ -13,7 +13,7 @@ from misago.users.avatars import dynamic, gallery
 from misago.users.models import Rank
 from misago.users.models import Rank
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class Command(BaseCommand):
 class Command(BaseCommand):
@@ -47,7 +47,7 @@ class Command(BaseCommand):
                     fake.user_name(),
                     fake.user_name(),
                 ]
                 ]
 
 
-                user = UserModel.objects.create_user(
+                user = User.objects.create_user(
                     random.choice(possible_usernames),
                     random.choice(possible_usernames),
                     fake.email(),
                     fake.email(),
                     "pass123",
                     "pass123",

+ 3 - 3
misago/markup/mentions.py

@@ -39,7 +39,7 @@ def add_mentions_to_element(request, element, mentions_dict):
 
 
 
 
 def parse_string(request, element, mentions_dict):
 def parse_string(request, element, mentions_dict):
-    UserModel = get_user_model()
+    User = get_user_model()
 
 
     def replace_mentions(matchobj):
     def replace_mentions(matchobj):
         if len(mentions_dict) >= MENTIONS_LIMIT:
         if len(mentions_dict) >= MENTIONS_LIMIT:
@@ -52,8 +52,8 @@ def parse_string(request, element, mentions_dict):
                 mentions_dict[username] = request.user
                 mentions_dict[username] = request.user
             else:
             else:
                 try:
                 try:
-                    mentions_dict[username] = UserModel.objects.get(slug=username)
-                except UserModel.DoesNotExist:
+                    mentions_dict[username] = User.objects.get(slug=username)
+                except User.DoesNotExist:
                     mentions_dict[username] = None
                     mentions_dict[username] = None
 
 
         if mentions_dict[username]:
         if mentions_dict[username]:

+ 2 - 2
misago/markup/tests/test_parser.py

@@ -4,7 +4,7 @@ from django.test import TestCase
 from misago.markup.parser import parse
 from misago.markup.parser import parse
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class MockRequest(object):
 class MockRequest(object):
@@ -167,7 +167,7 @@ Lorem ipsum.
 
 
     def test_complex_paragraph(self):
     def test_complex_paragraph(self):
         """parser minifies complex paragraph"""
         """parser minifies complex paragraph"""
-        user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass123")
+        user = User.objects.create_user("Bob", "bob@test.com", "Pass123")
 
 
         test_text = (
         test_text = (
             """
             """

+ 3 - 7
misago/readtracker/tests/test_clearreadtracker.py

@@ -13,17 +13,13 @@ from misago.readtracker.models import PostRead
 from misago.threads import testutils
 from misago.threads import testutils
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class ClearReadTrackerTests(TestCase):
 class ClearReadTrackerTests(TestCase):
     def setUp(self):
     def setUp(self):
-        self.user_a = UserModel.objects.create_user(
-            "UserA", "testa@user.com", "Pass.123"
-        )
-        self.user_b = UserModel.objects.create_user(
-            "UserB", "testb@user.com", "Pass.123"
-        )
+        self.user_a = User.objects.create_user("UserA", "testa@user.com", "Pass.123")
+        self.user_b = User.objects.create_user("UserB", "testb@user.com", "Pass.123")
 
 
         self.category = Category.objects.get(slug="first-category")
         self.category = Category.objects.get(slug="first-category")
 
 

+ 2 - 2
misago/readtracker/tests/test_poststracker.py

@@ -11,7 +11,7 @@ from misago.readtracker.models import PostRead
 from misago.threads import testutils
 from misago.threads import testutils
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class AnonymousUser(object):
 class AnonymousUser(object):
@@ -21,7 +21,7 @@ class AnonymousUser(object):
 
 
 class PostsTrackerTests(TestCase):
 class PostsTrackerTests(TestCase):
     def setUp(self):
     def setUp(self):
-        self.user = UserModel.objects.create_user("UserA", "testa@user.com", "Pass.123")
+        self.user = User.objects.create_user("UserA", "testa@user.com", "Pass.123")
         self.category = Category.objects.get(slug="first-category")
         self.category = Category.objects.get(slug="first-category")
         self.thread = testutils.post_thread(self.category)
         self.thread = testutils.post_thread(self.category)
 
 

+ 2 - 2
misago/threads/api/postingendpoint/participants.py

@@ -12,7 +12,7 @@ from misago.threads.permissions import allow_message_user
 from . import PostingEndpoint, PostingMiddleware
 from . import PostingEndpoint, PostingMiddleware
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class ParticipantsMiddleware(PostingMiddleware):
 class ParticipantsMiddleware(PostingMiddleware):
@@ -76,7 +76,7 @@ class ParticipantsSerializer(serializers.Serializer):
 
 
     def get_users(self, usernames):
     def get_users(self, usernames):
         users = []
         users = []
-        for user in UserModel.objects.filter(slug__in=usernames):
+        for user in User.objects.filter(slug__in=usernames):
             try:
             try:
                 user_acl = useracl.get_user_acl(
                 user_acl = useracl.get_user_acl(
                     user, self.context["request"].cache_versions
                     user, self.context["request"].cache_versions

+ 5 - 7
misago/threads/api/postingendpoint/subscribe.py

@@ -5,7 +5,7 @@ from misago.threads.models import Subscription
 from . import PostingEndpoint, PostingMiddleware
 from . import PostingEndpoint, PostingMiddleware
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class SubscribeMiddleware(PostingMiddleware):
 class SubscribeMiddleware(PostingMiddleware):
@@ -20,21 +20,20 @@ class SubscribeMiddleware(PostingMiddleware):
         if self.mode != PostingEndpoint.START:
         if self.mode != PostingEndpoint.START:
             return
             return
 
 
-        if self.user.subscribe_to_started_threads == UserModel.SUBSCRIPTION_NONE:
+        if self.user.subscribe_to_started_threads == User.SUBSCRIPTION_NONE:
             return
             return
 
 
         self.user.subscription_set.create(
         self.user.subscription_set.create(
             category=self.thread.category,
             category=self.thread.category,
             thread=self.thread,
             thread=self.thread,
-            send_email=self.user.subscribe_to_started_threads
-            == UserModel.SUBSCRIPTION_ALL,
+            send_email=self.user.subscribe_to_started_threads == User.SUBSCRIPTION_ALL,
         )
         )
 
 
     def subscribe_replied_thread(self):
     def subscribe_replied_thread(self):
         if self.mode != PostingEndpoint.REPLY:
         if self.mode != PostingEndpoint.REPLY:
             return
             return
 
 
-        if self.user.subscribe_to_replied_threads == UserModel.SUBSCRIPTION_NONE:
+        if self.user.subscribe_to_replied_threads == User.SUBSCRIPTION_NONE:
             return
             return
 
 
         try:
         try:
@@ -53,6 +52,5 @@ class SubscribeMiddleware(PostingMiddleware):
         self.user.subscription_set.create(
         self.user.subscription_set.create(
             category=self.thread.category,
             category=self.thread.category,
             thread=self.thread,
             thread=self.thread,
-            send_email=self.user.subscribe_to_replied_threads
-            == UserModel.SUBSCRIPTION_ALL,
+            send_email=self.user.subscribe_to_replied_threads == User.SUBSCRIPTION_ALL,
         )
         )

+ 3 - 3
misago/threads/api/threadendpoints/patch.py

@@ -45,7 +45,7 @@ from misago.threads.validators import validate_thread_title
 
 
 PATCH_LIMIT = settings.MISAGO_THREADS_PER_PAGE + settings.MISAGO_THREADS_TAIL
 PATCH_LIMIT = settings.MISAGO_THREADS_PER_PAGE + settings.MISAGO_THREADS_TAIL
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 thread_patch_dispatcher = ApiPatch()
 thread_patch_dispatcher = ApiPatch()
 
 
@@ -301,8 +301,8 @@ def patch_add_participant(request, thread, value):
         username = str(value).strip().lower()
         username = str(value).strip().lower()
         if not username:
         if not username:
             raise PermissionDenied(_("You have to enter new participant's username."))
             raise PermissionDenied(_("You have to enter new participant's username."))
-        participant = UserModel.objects.get(slug=username)
-    except UserModel.DoesNotExist:
+        participant = User.objects.get(slug=username)
+    except User.DoesNotExist:
         raise PermissionDenied(_("No user with such name exists."))
         raise PermissionDenied(_("No user with such name exists."))
 
 
     if participant in [p.user for p in thread.participants_list]:
     if participant in [p.user for p in thread.participants_list]:

+ 2 - 4
misago/threads/participants.py

@@ -7,7 +7,7 @@ from .events import record_event
 from .models import ThreadParticipant
 from .models import ThreadParticipant
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 def has_participants(thread):
 def has_participants(thread):
@@ -64,9 +64,7 @@ def set_users_unread_private_threads_sync(
     if not users_ids:
     if not users_ids:
         return
         return
 
 
-    UserModel.objects.filter(id__in=set(users_ids)).update(
-        sync_unread_private_threads=True
-    )
+    User.objects.filter(id__in=set(users_ids)).update(sync_unread_private_threads=True)
 
 
 
 
 def set_owner(thread, user):
 def set_owner(thread, user):

+ 3 - 3
misago/threads/tests/test_anonymize_data.py

@@ -19,12 +19,12 @@ from misago.threads.participants import (
 )
 )
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 def get_mock_user():
 def get_mock_user():
-    seed = UserModel.objects.count() + 1
-    return UserModel.objects.create_user(
+    seed = User.objects.count() + 1
+    return User.objects.create_user(
         "bob%s" % seed, "user%s@test.com" % seed, "Pass.123"
         "bob%s" % seed, "user%s@test.com" % seed, "Pass.123"
     )
     )
 
 

+ 3 - 3
misago/threads/tests/test_delete_user_likes.py

@@ -9,12 +9,12 @@ from misago.threads.api.postendpoints.patch_post import patch_is_liked
 from misago.threads.models import Post
 from misago.threads.models import Post
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 def get_mock_user():
 def get_mock_user():
-    seed = UserModel.objects.count() + 1
-    return UserModel.objects.create_user(
+    seed = User.objects.count() + 1
+    return User.objects.create_user(
         "bob%s" % seed, "user%s@test.com" % seed, "Pass.123"
         "bob%s" % seed, "user%s@test.com" % seed, "Pass.123"
     )
     )
 
 

+ 2 - 4
misago/threads/tests/test_emailnotification_middleware.py

@@ -13,7 +13,7 @@ from misago.threads.test import patch_category_acl, patch_other_user_category_ac
 from misago.users.testutils import AuthenticatedUserTestCase
 from misago.users.testutils import AuthenticatedUserTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class EmailNotificationTests(AuthenticatedUserTestCase):
 class EmailNotificationTests(AuthenticatedUserTestCase):
@@ -29,9 +29,7 @@ class EmailNotificationTests(AuthenticatedUserTestCase):
             "misago:api:thread-post-list", kwargs={"thread_pk": self.thread.pk}
             "misago:api:thread-post-list", kwargs={"thread_pk": self.thread.pk}
         )
         )
 
 
-        self.other_user = UserModel.objects.create_user(
-            "BobBobertson", "bob@boberson.com"
-        )
+        self.other_user = User.objects.create_user("BobBobertson", "bob@boberson.com")
 
 
     @patch_category_acl({"can_reply_threads": True})
     @patch_category_acl({"can_reply_threads": True})
     def test_no_subscriptions(self):
     def test_no_subscriptions(self):

+ 2 - 2
misago/threads/tests/test_mergeconflict.py

@@ -9,13 +9,13 @@ from misago.threads import testutils
 from misago.threads.mergeconflict import MergeConflict
 from misago.threads.mergeconflict import MergeConflict
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class MergeConflictTests(TestCase):
 class MergeConflictTests(TestCase):
     def setUp(self):
     def setUp(self):
         self.category = Category.objects.get(slug="first-category")
         self.category = Category.objects.get(slug="first-category")
-        self.user = UserModel.objects.create_user("bob", "bob@test.com", "Pass.123")
+        self.user = User.objects.create_user("bob", "bob@test.com", "Pass.123")
 
 
     def create_plain_thread(self):
     def create_plain_thread(self):
         return testutils.post_thread(self.category)
         return testutils.post_thread(self.category)

+ 23 - 33
misago/threads/tests/test_participants.py

@@ -12,7 +12,7 @@ from misago.threads.participants import (
 )
 )
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class ParticipantsTests(TestCase):
 class ParticipantsTests(TestCase):
@@ -51,8 +51,8 @@ class ParticipantsTests(TestCase):
     def test_has_participants(self):
     def test_has_participants(self):
         """has_participants returns true if thread has participants"""
         """has_participants returns true if thread has participants"""
         users = [
         users = [
-            UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123"),
-            UserModel.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123"),
+            User.objects.create_user("Bob", "bob@boberson.com", "Pass.123"),
+            User.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123"),
         ]
         ]
 
 
         self.assertFalse(has_participants(self.thread))
         self.assertFalse(has_participants(self.thread))
@@ -68,10 +68,8 @@ class ParticipantsTests(TestCase):
         make_participants_aware sets participants_list and participant
         make_participants_aware sets participants_list and participant
         annotations on list of threads
         annotations on list of threads
         """
         """
-        user = UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
-        other_user = UserModel.objects.create_user(
-            "Bob2", "bob2@boberson.com", "Pass.123"
-        )
+        user = User.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
+        other_user = User.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123")
 
 
         self.assertFalse(hasattr(self.thread, "participants_list"))
         self.assertFalse(hasattr(self.thread, "participants_list"))
         self.assertFalse(hasattr(self.thread, "participant"))
         self.assertFalse(hasattr(self.thread, "participant"))
@@ -95,10 +93,8 @@ class ParticipantsTests(TestCase):
         make_participants_aware sets participants_list and participant
         make_participants_aware sets participants_list and participant
         annotations on thread model
         annotations on thread model
         """
         """
-        user = UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
-        other_user = UserModel.objects.create_user(
-            "Bob2", "bob2@boberson.com", "Pass.123"
-        )
+        user = User.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
+        other_user = User.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123")
 
 
         self.assertFalse(hasattr(self.thread, "participants_list"))
         self.assertFalse(hasattr(self.thread, "participants_list"))
         self.assertFalse(hasattr(self.thread, "participant"))
         self.assertFalse(hasattr(self.thread, "participant"))
@@ -125,7 +121,7 @@ class ParticipantsTests(TestCase):
 
 
     def test_set_owner(self):
     def test_set_owner(self):
         """set_owner sets user as thread owner"""
         """set_owner sets user as thread owner"""
-        user = UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
 
 
         set_owner(self.thread, user)
         set_owner(self.thread, user)
 
 
@@ -138,13 +134,13 @@ class ParticipantsTests(TestCase):
         flag on users provided to true
         flag on users provided to true
         """
         """
         users = [
         users = [
-            UserModel.objects.create_user("Bob1", "bob1@boberson.com", "Pass.123"),
-            UserModel.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123"),
+            User.objects.create_user("Bob1", "bob1@boberson.com", "Pass.123"),
+            User.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123"),
         ]
         ]
 
 
         set_users_unread_private_threads_sync(users=users)
         set_users_unread_private_threads_sync(users=users)
         for user in users:
         for user in users:
-            UserModel.objects.get(pk=user.pk, sync_unread_private_threads=True)
+            User.objects.get(pk=user.pk, sync_unread_private_threads=True)
 
 
     def test_set_participants_unread_private_threads_sync(self):
     def test_set_participants_unread_private_threads_sync(self):
         """
         """
@@ -152,54 +148,48 @@ class ParticipantsTests(TestCase):
         flag on participants provided to true
         flag on participants provided to true
         """
         """
         users = [
         users = [
-            UserModel.objects.create_user("Bob1", "bob1@boberson.com", "Pass.123"),
-            UserModel.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123"),
+            User.objects.create_user("Bob1", "bob1@boberson.com", "Pass.123"),
+            User.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123"),
         ]
         ]
 
 
         participants = [ThreadParticipant(user=u) for u in users]
         participants = [ThreadParticipant(user=u) for u in users]
 
 
         set_users_unread_private_threads_sync(participants=participants)
         set_users_unread_private_threads_sync(participants=participants)
         for user in users:
         for user in users:
-            UserModel.objects.get(pk=user.pk, sync_unread_private_threads=True)
+            User.objects.get(pk=user.pk, sync_unread_private_threads=True)
 
 
     def test_set_participants_users_unread_private_threads_sync(self):
     def test_set_participants_users_unread_private_threads_sync(self):
         """
         """
         set_users_unread_private_threads_sync sets sync_unread_private_threads
         set_users_unread_private_threads_sync sets sync_unread_private_threads
         flag on users and participants provided to true
         flag on users and participants provided to true
         """
         """
-        users = [UserModel.objects.create_user("Bob1", "bob1@boberson.com", "Pass.123")]
+        users = [User.objects.create_user("Bob1", "bob1@boberson.com", "Pass.123")]
 
 
         participants = [ThreadParticipant(user=u) for u in users]
         participants = [ThreadParticipant(user=u) for u in users]
 
 
-        users.append(
-            UserModel.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123")
-        )
+        users.append(User.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123"))
 
 
         set_users_unread_private_threads_sync(users=users, participants=participants)
         set_users_unread_private_threads_sync(users=users, participants=participants)
         for user in users:
         for user in users:
-            UserModel.objects.get(pk=user.pk, sync_unread_private_threads=True)
+            User.objects.get(pk=user.pk, sync_unread_private_threads=True)
 
 
     def test_set_users_unread_private_threads_sync_exclude_user(self):
     def test_set_users_unread_private_threads_sync_exclude_user(self):
         """exclude_user kwarg works"""
         """exclude_user kwarg works"""
         users = [
         users = [
-            UserModel.objects.create_user("Bob1", "bob1@boberson.com", "Pass.123"),
-            UserModel.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123"),
+            User.objects.create_user("Bob1", "bob1@boberson.com", "Pass.123"),
+            User.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123"),
         ]
         ]
 
 
         set_users_unread_private_threads_sync(users=users, exclude_user=users[0])
         set_users_unread_private_threads_sync(users=users, exclude_user=users[0])
 
 
-        self.assertFalse(
-            UserModel.objects.get(pk=users[0].pk).sync_unread_private_threads
-        )
-        self.assertTrue(
-            UserModel.objects.get(pk=users[1].pk).sync_unread_private_threads
-        )
+        self.assertFalse(User.objects.get(pk=users[0].pk).sync_unread_private_threads)
+        self.assertTrue(User.objects.get(pk=users[1].pk).sync_unread_private_threads)
 
 
     def test_set_users_unread_private_threads_sync_noop(self):
     def test_set_users_unread_private_threads_sync_noop(self):
         """excluding only user is noop"""
         """excluding only user is noop"""
-        user = UserModel.objects.create_user("Bob1", "bob1@boberson.com", "Pass.123")
+        user = User.objects.create_user("Bob1", "bob1@boberson.com", "Pass.123")
 
 
         with self.assertNumQueries(0):
         with self.assertNumQueries(0):
             set_users_unread_private_threads_sync(users=[user], exclude_user=user)
             set_users_unread_private_threads_sync(users=[user], exclude_user=user)
 
 
-        self.assertFalse(UserModel.objects.get(pk=user.pk).sync_unread_private_threads)
+        self.assertFalse(User.objects.get(pk=user.pk).sync_unread_private_threads)

+ 6 - 10
misago/threads/tests/test_post_mentions.py

@@ -7,7 +7,7 @@ from misago.markup.mentions import MENTIONS_LIMIT
 from misago.threads import testutils
 from misago.threads import testutils
 from misago.users.testutils import AuthenticatedUserTestCase
 from misago.users.testutils import AuthenticatedUserTestCase
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class PostMentionsTests(AuthenticatedUserTestCase):
 class PostMentionsTests(AuthenticatedUserTestCase):
@@ -63,7 +63,7 @@ class PostMentionsTests(AuthenticatedUserTestCase):
 
 
         for i in range(MENTIONS_LIMIT + 5):
         for i in range(MENTIONS_LIMIT + 5):
             users.append(
             users.append(
-                UserModel.objects.create_user(
+                User.objects.create_user(
                     "Mention%s" % i, "mention%s@bob.com" % i, "pass123"
                     "Mention%s" % i, "mention%s@bob.com" % i, "pass123"
                 )
                 )
             )
             )
@@ -82,10 +82,8 @@ class PostMentionsTests(AuthenticatedUserTestCase):
 
 
     def test_mention_update(self):
     def test_mention_update(self):
         """edit post endpoint updates mentions"""
         """edit post endpoint updates mentions"""
-        user_a = UserModel.objects.create_user("Mention", "mention@test.com", "pass123")
-        user_b = UserModel.objects.create_user(
-            "MentionB", "mentionb@test.com", "pass123"
-        )
+        user_a = User.objects.create_user("Mention", "mention@test.com", "pass123")
+        user_b = User.objects.create_user("MentionB", "mentionb@test.com", "pass123")
 
 
         response = self.client.post(
         response = self.client.post(
             self.post_link, data={"post": "This is test response, @%s!" % user_a}
             self.post_link, data={"post": "This is test response, @%s!" % user_a}
@@ -130,10 +128,8 @@ class PostMentionsTests(AuthenticatedUserTestCase):
 
 
     def test_mentions_merge(self):
     def test_mentions_merge(self):
         """posts merge sums mentions"""
         """posts merge sums mentions"""
-        user_a = UserModel.objects.create_user("Mention", "mention@test.com", "pass123")
-        user_b = UserModel.objects.create_user(
-            "MentionB", "mentionb@test.com", "pass123"
-        )
+        user_a = User.objects.create_user("Mention", "mention@test.com", "pass123")
+        user_b = User.objects.create_user("MentionB", "mentionb@test.com", "pass123")
 
 
         response = self.client.post(
         response = self.client.post(
             self.post_link, data={"post": "This is test response, @%s!" % user_a}
             self.post_link, data={"post": "This is test response, @%s!" % user_a}

+ 3 - 3
misago/threads/tests/test_post_model.py

@@ -9,12 +9,12 @@ from misago.threads.checksums import update_post_checksum
 from misago.threads.models import Post, Thread
 from misago.threads.models import Post, Thread
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class PostModelTests(TestCase):
 class PostModelTests(TestCase):
     def setUp(self):
     def setUp(self):
-        self.user = UserModel.objects.create_user("Bob", "bob@bob.com", "Pass.123")
+        self.user = User.objects.create_user("Bob", "bob@bob.com", "Pass.123")
 
 
         datetime = timezone.now()
         datetime = timezone.now()
 
 
@@ -57,7 +57,7 @@ class PostModelTests(TestCase):
         with self.assertRaises(ValueError):
         with self.assertRaises(ValueError):
             self.post.merge(self.post)
             self.post.merge(self.post)
 
 
-        other_user = UserModel.objects.create_user("Jeff", "Je@ff.com", "Pass.123")
+        other_user = User.objects.create_user("Jeff", "Je@ff.com", "Pass.123")
 
 
         other_thread = Thread.objects.create(
         other_thread = Thread.objects.create(
             category=self.category,
             category=self.category,

+ 26 - 52
misago/threads/tests/test_privatethread_patch_api.py

@@ -10,7 +10,7 @@ from misago.threads.models import Thread, ThreadParticipant
 
 
 from .test_privatethreads import PrivateThreadsTestCase
 from .test_privatethreads import PrivateThreadsTestCase
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class PrivateThreadPatchApiTestCase(PrivateThreadsTestCase):
 class PrivateThreadPatchApiTestCase(PrivateThreadsTestCase):
@@ -20,7 +20,7 @@ class PrivateThreadPatchApiTestCase(PrivateThreadsTestCase):
         self.thread = testutils.post_thread(self.category, poster=self.user)
         self.thread = testutils.post_thread(self.category, poster=self.user)
         self.api_link = self.thread.get_api_url()
         self.api_link = self.thread.get_api_url()
 
 
-        self.other_user = UserModel.objects.create_user(
+        self.other_user = User.objects.create_user(
             "BobBoberson", "bob@boberson.com", "pass123"
             "BobBoberson", "bob@boberson.com", "pass123"
         )
         )
 
 
@@ -136,7 +136,7 @@ class PrivateThreadAddParticipantApiTests(PrivateThreadPatchApiTestCase):
         ThreadParticipant.objects.set_owner(self.thread, self.user)
         ThreadParticipant.objects.set_owner(self.thread, self.user)
 
 
         for i in range(3):
         for i in range(3):
-            user = UserModel.objects.create_user(
+            user = User.objects.create_user(
                 "User%s" % i, "user%s@example.com" % i, "Pass.123"
                 "User%s" % i, "user%s@example.com" % i, "Pass.123"
             )
             )
             ThreadParticipant.objects.add_participants(self.thread, [user])
             ThreadParticipant.objects.add_participants(self.thread, [user])
@@ -350,11 +350,9 @@ class PrivateThreadRemoveParticipantApiTests(PrivateThreadPatchApiTestCase):
         self.assertTrue(event.event_type, "participant_left")
         self.assertTrue(event.event_type, "participant_left")
 
 
         # valid users were flagged for sync
         # valid users were flagged for sync
+        self.assertTrue(User.objects.get(pk=self.user.pk).sync_unread_private_threads)
         self.assertTrue(
         self.assertTrue(
-            UserModel.objects.get(pk=self.user.pk).sync_unread_private_threads
-        )
-        self.assertTrue(
-            UserModel.objects.get(pk=self.other_user.pk).sync_unread_private_threads
+            User.objects.get(pk=self.other_user.pk).sync_unread_private_threads
         )
         )
 
 
         # user was removed from participation
         # user was removed from participation
@@ -389,11 +387,9 @@ class PrivateThreadRemoveParticipantApiTests(PrivateThreadPatchApiTestCase):
         self.assertTrue(event.event_type, "participant_left")
         self.assertTrue(event.event_type, "participant_left")
 
 
         # valid users were flagged for sync
         # valid users were flagged for sync
+        self.assertTrue(User.objects.get(pk=self.user.pk).sync_unread_private_threads)
         self.assertTrue(
         self.assertTrue(
-            UserModel.objects.get(pk=self.user.pk).sync_unread_private_threads
-        )
-        self.assertTrue(
-            UserModel.objects.get(pk=self.other_user.pk).sync_unread_private_threads
+            User.objects.get(pk=self.other_user.pk).sync_unread_private_threads
         )
         )
 
 
         # user was removed from participation
         # user was removed from participation
@@ -403,9 +399,7 @@ class PrivateThreadRemoveParticipantApiTests(PrivateThreadPatchApiTestCase):
     @patch_user_acl({"can_moderate_private_threads": True})
     @patch_user_acl({"can_moderate_private_threads": True})
     def test_moderator_remove_user(self):
     def test_moderator_remove_user(self):
         """api allows moderator to remove other user"""
         """api allows moderator to remove other user"""
-        removed_user = UserModel.objects.create_user(
-            "Vigilante", "test@test.com", "pass123"
-        )
+        removed_user = User.objects.create_user("Vigilante", "test@test.com", "pass123")
 
 
         ThreadParticipant.objects.set_owner(self.thread, self.other_user)
         ThreadParticipant.objects.set_owner(self.thread, self.other_user)
         ThreadParticipant.objects.add_participants(
         ThreadParticipant.objects.add_participants(
@@ -429,14 +423,12 @@ class PrivateThreadRemoveParticipantApiTests(PrivateThreadPatchApiTestCase):
         self.assertTrue(event.event_type, "participant_removed")
         self.assertTrue(event.event_type, "participant_removed")
 
 
         # valid users were flagged for sync
         # valid users were flagged for sync
+        self.assertTrue(User.objects.get(pk=self.user.pk).sync_unread_private_threads)
         self.assertTrue(
         self.assertTrue(
-            UserModel.objects.get(pk=self.user.pk).sync_unread_private_threads
+            User.objects.get(pk=self.other_user.pk).sync_unread_private_threads
         )
         )
         self.assertTrue(
         self.assertTrue(
-            UserModel.objects.get(pk=self.other_user.pk).sync_unread_private_threads
-        )
-        self.assertTrue(
-            UserModel.objects.get(pk=removed_user.pk).sync_unread_private_threads
+            User.objects.get(pk=removed_user.pk).sync_unread_private_threads
         )
         )
 
 
         # user was removed from participation
         # user was removed from participation
@@ -465,11 +457,9 @@ class PrivateThreadRemoveParticipantApiTests(PrivateThreadPatchApiTestCase):
         self.assertTrue(event.event_type, "participant_removed")
         self.assertTrue(event.event_type, "participant_removed")
 
 
         # valid users were flagged for sync
         # valid users were flagged for sync
+        self.assertTrue(User.objects.get(pk=self.user.pk).sync_unread_private_threads)
         self.assertTrue(
         self.assertTrue(
-            UserModel.objects.get(pk=self.user.pk).sync_unread_private_threads
-        )
-        self.assertTrue(
-            UserModel.objects.get(pk=self.other_user.pk).sync_unread_private_threads
+            User.objects.get(pk=self.other_user.pk).sync_unread_private_threads
         )
         )
 
 
         # user was removed from participation
         # user was removed from participation
@@ -500,11 +490,9 @@ class PrivateThreadRemoveParticipantApiTests(PrivateThreadPatchApiTestCase):
         self.assertTrue(event.event_type, "owner_left")
         self.assertTrue(event.event_type, "owner_left")
 
 
         # valid users were flagged for sync
         # valid users were flagged for sync
+        self.assertTrue(User.objects.get(pk=self.user.pk).sync_unread_private_threads)
         self.assertTrue(
         self.assertTrue(
-            UserModel.objects.get(pk=self.user.pk).sync_unread_private_threads
-        )
-        self.assertTrue(
-            UserModel.objects.get(pk=self.other_user.pk).sync_unread_private_threads
+            User.objects.get(pk=self.other_user.pk).sync_unread_private_threads
         )
         )
 
 
         # user was removed from participation
         # user was removed from participation
@@ -528,9 +516,7 @@ class PrivateThreadRemoveParticipantApiTests(PrivateThreadPatchApiTestCase):
             Thread.objects.get(pk=self.thread.pk)
             Thread.objects.get(pk=self.thread.pk)
 
 
         # valid users were flagged for sync
         # valid users were flagged for sync
-        self.assertTrue(
-            UserModel.objects.get(pk=self.user.pk).sync_unread_private_threads
-        )
+        self.assertTrue(User.objects.get(pk=self.user.pk).sync_unread_private_threads)
 
 
 
 
 class PrivateThreadTakeOverApiTests(PrivateThreadPatchApiTestCase):
 class PrivateThreadTakeOverApiTests(PrivateThreadPatchApiTestCase):
@@ -641,11 +627,9 @@ class PrivateThreadTakeOverApiTests(PrivateThreadPatchApiTestCase):
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.status_code, 200)
 
 
         # valid users were flagged for sync
         # valid users were flagged for sync
-        self.assertFalse(
-            UserModel.objects.get(pk=self.user.pk).sync_unread_private_threads
-        )
+        self.assertFalse(User.objects.get(pk=self.user.pk).sync_unread_private_threads)
         self.assertTrue(
         self.assertTrue(
-            UserModel.objects.get(pk=self.other_user.pk).sync_unread_private_threads
+            User.objects.get(pk=self.other_user.pk).sync_unread_private_threads
         )
         )
 
 
         # ownership was transfered
         # ownership was transfered
@@ -661,9 +645,7 @@ class PrivateThreadTakeOverApiTests(PrivateThreadPatchApiTestCase):
     @patch_user_acl({"can_moderate_private_threads": True})
     @patch_user_acl({"can_moderate_private_threads": True})
     def test_moderator_change_owner(self):
     def test_moderator_change_owner(self):
         """moderator can change thread owner to other user"""
         """moderator can change thread owner to other user"""
-        new_owner = UserModel.objects.create_user(
-            "NewOwner", "new@owner.com", "pass123"
-        )
+        new_owner = User.objects.create_user("NewOwner", "new@owner.com", "pass123")
 
 
         ThreadParticipant.objects.set_owner(self.thread, self.other_user)
         ThreadParticipant.objects.set_owner(self.thread, self.other_user)
         ThreadParticipant.objects.add_participants(self.thread, [self.user, new_owner])
         ThreadParticipant.objects.add_participants(self.thread, [self.user, new_owner])
@@ -675,14 +657,10 @@ class PrivateThreadTakeOverApiTests(PrivateThreadPatchApiTestCase):
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.status_code, 200)
 
 
         # valid users were flagged for sync
         # valid users were flagged for sync
+        self.assertTrue(User.objects.get(pk=new_owner.pk).sync_unread_private_threads)
+        self.assertFalse(User.objects.get(pk=self.user.pk).sync_unread_private_threads)
         self.assertTrue(
         self.assertTrue(
-            UserModel.objects.get(pk=new_owner.pk).sync_unread_private_threads
-        )
-        self.assertFalse(
-            UserModel.objects.get(pk=self.user.pk).sync_unread_private_threads
-        )
-        self.assertTrue(
-            UserModel.objects.get(pk=self.other_user.pk).sync_unread_private_threads
+            User.objects.get(pk=self.other_user.pk).sync_unread_private_threads
         )
         )
 
 
         # ownership was transferred
         # ownership was transferred
@@ -709,11 +687,9 @@ class PrivateThreadTakeOverApiTests(PrivateThreadPatchApiTestCase):
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.status_code, 200)
 
 
         # valid users were flagged for sync
         # valid users were flagged for sync
-        self.assertFalse(
-            UserModel.objects.get(pk=self.user.pk).sync_unread_private_threads
-        )
+        self.assertFalse(User.objects.get(pk=self.user.pk).sync_unread_private_threads)
         self.assertTrue(
         self.assertTrue(
-            UserModel.objects.get(pk=self.other_user.pk).sync_unread_private_threads
+            User.objects.get(pk=self.other_user.pk).sync_unread_private_threads
         )
         )
 
 
         # ownership was transfered
         # ownership was transfered
@@ -742,11 +718,9 @@ class PrivateThreadTakeOverApiTests(PrivateThreadPatchApiTestCase):
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.status_code, 200)
 
 
         # valid users were flagged for sync
         # valid users were flagged for sync
-        self.assertFalse(
-            UserModel.objects.get(pk=self.user.pk).sync_unread_private_threads
-        )
+        self.assertFalse(User.objects.get(pk=self.user.pk).sync_unread_private_threads)
         self.assertTrue(
         self.assertTrue(
-            UserModel.objects.get(pk=self.other_user.pk).sync_unread_private_threads
+            User.objects.get(pk=self.other_user.pk).sync_unread_private_threads
         )
         )
 
 
         # ownership was transferred
         # ownership was transferred

+ 4 - 6
misago/threads/tests/test_privatethread_reply_api.py

@@ -6,7 +6,7 @@ from misago.threads.models import ThreadParticipant
 from .test_privatethreads import PrivateThreadsTestCase
 from .test_privatethreads import PrivateThreadsTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class PrivateThreadReplyApiTestCase(PrivateThreadsTestCase):
 class PrivateThreadReplyApiTestCase(PrivateThreadsTestCase):
@@ -16,7 +16,7 @@ class PrivateThreadReplyApiTestCase(PrivateThreadsTestCase):
         self.thread = testutils.post_thread(self.category, poster=self.user)
         self.thread = testutils.post_thread(self.category, poster=self.user)
         self.api_link = self.thread.get_posts_api_url()
         self.api_link = self.thread.get_posts_api_url()
 
 
-        self.other_user = UserModel.objects.create_user(
+        self.other_user = User.objects.create_user(
             "BobBoberson", "bob@boberson.com", "pass123"
             "BobBoberson", "bob@boberson.com", "pass123"
         )
         )
 
 
@@ -38,9 +38,7 @@ class PrivateThreadReplyApiTestCase(PrivateThreadsTestCase):
         self.assertEqual(self.user.audittrail_set.count(), 1)
         self.assertEqual(self.user.audittrail_set.count(), 1)
 
 
         # valid user was flagged to sync
         # valid user was flagged to sync
-        self.assertFalse(
-            UserModel.objects.get(pk=self.user.pk).sync_unread_private_threads
-        )
+        self.assertFalse(User.objects.get(pk=self.user.pk).sync_unread_private_threads)
         self.assertTrue(
         self.assertTrue(
-            UserModel.objects.get(pk=self.other_user.pk).sync_unread_private_threads
+            User.objects.get(pk=self.other_user.pk).sync_unread_private_threads
         )
         )

+ 5 - 5
misago/threads/tests/test_privatethread_start_api.py

@@ -9,7 +9,7 @@ from misago.threads.models import ThreadParticipant
 from misago.threads.test import other_user_cant_use_private_threads
 from misago.threads.test import other_user_cant_use_private_threads
 from misago.users.testutils import AuthenticatedUserTestCase
 from misago.users.testutils import AuthenticatedUserTestCase
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class StartPrivateThreadTests(AuthenticatedUserTestCase):
 class StartPrivateThreadTests(AuthenticatedUserTestCase):
@@ -19,7 +19,7 @@ class StartPrivateThreadTests(AuthenticatedUserTestCase):
         self.category = Category.objects.private_threads()
         self.category = Category.objects.private_threads()
         self.api_link = reverse("misago:api:private-thread-list")
         self.api_link = reverse("misago:api:private-thread-list")
 
 
-        self.other_user = UserModel.objects.create_user(
+        self.other_user = User.objects.create_user(
             "BobBoberson", "bob@boberson.com", "pass123"
             "BobBoberson", "bob@boberson.com", "pass123"
         )
         )
 
 
@@ -212,7 +212,7 @@ class StartPrivateThreadTests(AuthenticatedUserTestCase):
 
 
     def test_cant_invite_followers_only(self):
     def test_cant_invite_followers_only(self):
         """api validates that you cant invite followers-only user to thread"""
         """api validates that you cant invite followers-only user to thread"""
-        user_constant = UserModel.LIMIT_INVITES_TO_FOLLOWED
+        user_constant = User.LIMIT_INVITES_TO_FOLLOWED
         self.other_user.limits_private_thread_invites_to = user_constant
         self.other_user.limits_private_thread_invites_to = user_constant
         self.other_user.save()
         self.other_user.save()
 
 
@@ -272,7 +272,7 @@ class StartPrivateThreadTests(AuthenticatedUserTestCase):
 
 
     def test_cant_invite_anyone(self):
     def test_cant_invite_anyone(self):
         """api validates that you cant invite nobody user to thread"""
         """api validates that you cant invite nobody user to thread"""
-        user_constant = UserModel.LIMIT_INVITES_TO_NOBODY
+        user_constant = User.LIMIT_INVITES_TO_NOBODY
         self.other_user.limits_private_thread_invites_to = user_constant
         self.other_user.limits_private_thread_invites_to = user_constant
         self.other_user.save()
         self.other_user.save()
 
 
@@ -364,7 +364,7 @@ class StartPrivateThreadTests(AuthenticatedUserTestCase):
         )
         )
 
 
         # other user has sync_unread_private_threads flag
         # other user has sync_unread_private_threads flag
-        user_to_sync = UserModel.objects.get(sync_unread_private_threads=True)
+        user_to_sync = User.objects.get(sync_unread_private_threads=True)
         self.assertEqual(user_to_sync, self.other_user)
         self.assertEqual(user_to_sync, self.other_user)
 
 
         # notification about new private thread was sent to other user
         # notification about new private thread was sent to other user

+ 11 - 11
misago/threads/tests/test_subscription_middleware.py

@@ -8,7 +8,7 @@ from misago.threads.test import patch_category_acl
 from misago.users.testutils import AuthenticatedUserTestCase
 from misago.users.testutils import AuthenticatedUserTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class SubscriptionMiddlewareTestCase(AuthenticatedUserTestCase):
 class SubscriptionMiddlewareTestCase(AuthenticatedUserTestCase):
@@ -25,8 +25,8 @@ class SubscribeStartedThreadTests(SubscriptionMiddlewareTestCase):
     @patch_category_acl({"can_start_threads": True})
     @patch_category_acl({"can_start_threads": True})
     def test_dont_subscribe(self):
     def test_dont_subscribe(self):
         """middleware makes no subscription to thread"""
         """middleware makes no subscription to thread"""
-        self.user.subscribe_to_started_threads = UserModel.SUBSCRIPTION_NONE
-        self.user.subscribe_to_replied_threads = UserModel.SUBSCRIPTION_NOTIFY
+        self.user.subscribe_to_started_threads = User.SUBSCRIPTION_NONE
+        self.user.subscribe_to_replied_threads = User.SUBSCRIPTION_NOTIFY
         self.user.save()
         self.user.save()
 
 
         response = self.client.post(
         response = self.client.post(
@@ -45,7 +45,7 @@ class SubscribeStartedThreadTests(SubscriptionMiddlewareTestCase):
     @patch_category_acl({"can_start_threads": True})
     @patch_category_acl({"can_start_threads": True})
     def test_subscribe(self):
     def test_subscribe(self):
         """middleware subscribes thread"""
         """middleware subscribes thread"""
-        self.user.subscribe_to_started_threads = UserModel.SUBSCRIPTION_NOTIFY
+        self.user.subscribe_to_started_threads = User.SUBSCRIPTION_NOTIFY
         self.user.save()
         self.user.save()
 
 
         response = self.client.post(
         response = self.client.post(
@@ -68,7 +68,7 @@ class SubscribeStartedThreadTests(SubscriptionMiddlewareTestCase):
     @patch_category_acl({"can_start_threads": True})
     @patch_category_acl({"can_start_threads": True})
     def test_email_subscribe(self):
     def test_email_subscribe(self):
         """middleware subscribes thread with an email"""
         """middleware subscribes thread with an email"""
-        self.user.subscribe_to_started_threads = UserModel.SUBSCRIPTION_ALL
+        self.user.subscribe_to_started_threads = User.SUBSCRIPTION_ALL
         self.user.save()
         self.user.save()
 
 
         response = self.client.post(
         response = self.client.post(
@@ -100,8 +100,8 @@ class SubscribeRepliedThreadTests(SubscriptionMiddlewareTestCase):
     @patch_category_acl({"can_reply_threads": True})
     @patch_category_acl({"can_reply_threads": True})
     def test_dont_subscribe(self):
     def test_dont_subscribe(self):
         """middleware makes no subscription to thread"""
         """middleware makes no subscription to thread"""
-        self.user.subscribe_to_started_threads = UserModel.SUBSCRIPTION_NOTIFY
-        self.user.subscribe_to_replied_threads = UserModel.SUBSCRIPTION_NONE
+        self.user.subscribe_to_started_threads = User.SUBSCRIPTION_NOTIFY
+        self.user.subscribe_to_replied_threads = User.SUBSCRIPTION_NONE
         self.user.save()
         self.user.save()
 
 
         response = self.client.post(
         response = self.client.post(
@@ -115,7 +115,7 @@ class SubscribeRepliedThreadTests(SubscriptionMiddlewareTestCase):
     @patch_category_acl({"can_reply_threads": True})
     @patch_category_acl({"can_reply_threads": True})
     def test_subscribe(self):
     def test_subscribe(self):
         """middleware subscribes thread"""
         """middleware subscribes thread"""
-        self.user.subscribe_to_replied_threads = UserModel.SUBSCRIPTION_NOTIFY
+        self.user.subscribe_to_replied_threads = User.SUBSCRIPTION_NOTIFY
         self.user.save()
         self.user.save()
 
 
         response = self.client.post(
         response = self.client.post(
@@ -132,7 +132,7 @@ class SubscribeRepliedThreadTests(SubscriptionMiddlewareTestCase):
     @patch_category_acl({"can_reply_threads": True})
     @patch_category_acl({"can_reply_threads": True})
     def test_email_subscribe(self):
     def test_email_subscribe(self):
         """middleware subscribes thread with an email"""
         """middleware subscribes thread with an email"""
-        self.user.subscribe_to_replied_threads = UserModel.SUBSCRIPTION_ALL
+        self.user.subscribe_to_replied_threads = User.SUBSCRIPTION_ALL
         self.user.save()
         self.user.save()
 
 
         response = self.client.post(
         response = self.client.post(
@@ -149,7 +149,7 @@ class SubscribeRepliedThreadTests(SubscriptionMiddlewareTestCase):
     @patch_category_acl({"can_reply_threads": True})
     @patch_category_acl({"can_reply_threads": True})
     def test_subscribe_with_events(self):
     def test_subscribe_with_events(self):
         """middleware omits events when testing for replied thread"""
         """middleware omits events when testing for replied thread"""
-        self.user.subscribe_to_replied_threads = UserModel.SUBSCRIPTION_ALL
+        self.user.subscribe_to_replied_threads = User.SUBSCRIPTION_ALL
         self.user.save()
         self.user.save()
 
 
         # set event in thread
         # set event in thread
@@ -171,7 +171,7 @@ class SubscribeRepliedThreadTests(SubscriptionMiddlewareTestCase):
     @patch_user_acl({"can_omit_flood_protection": True})
     @patch_user_acl({"can_omit_flood_protection": True})
     def test_dont_subscribe_replied(self):
     def test_dont_subscribe_replied(self):
         """middleware omits threads user already replied"""
         """middleware omits threads user already replied"""
-        self.user.subscribe_to_replied_threads = UserModel.SUBSCRIPTION_ALL
+        self.user.subscribe_to_replied_threads = User.SUBSCRIPTION_ALL
         self.user.save()
         self.user.save()
 
 
         response = self.client.post(
         response = self.client.post(

+ 2 - 2
misago/threads/tests/test_subscriptions.py

@@ -10,7 +10,7 @@ from misago.threads.subscriptions import make_subscription_aware
 from misago.users.models import AnonymousUser
 from misago.users.models import AnonymousUser
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class SubscriptionsTests(TestCase):
 class SubscriptionsTests(TestCase):
@@ -18,7 +18,7 @@ class SubscriptionsTests(TestCase):
         self.category = list(Category.objects.all_categories()[:1])[0]
         self.category = list(Category.objects.all_categories()[:1])[0]
         self.thread = self.post_thread(timezone.now() - timedelta(days=10))
         self.thread = self.post_thread(timezone.now() - timedelta(days=10))
 
 
-        self.user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        self.user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
         self.anon = AnonymousUser()
         self.anon = AnonymousUser()
 
 
     def post_thread(self, datetime):
     def post_thread(self, datetime):

+ 2 - 2
misago/threads/tests/test_sync_unread_private_threads.py

@@ -6,14 +6,14 @@ from misago.threads.models import ThreadParticipant
 from .test_privatethreads import PrivateThreadsTestCase
 from .test_privatethreads import PrivateThreadsTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class SyncUnreadPrivateThreadsTestCase(PrivateThreadsTestCase):
 class SyncUnreadPrivateThreadsTestCase(PrivateThreadsTestCase):
     def setUp(self):
     def setUp(self):
         super().setUp()
         super().setUp()
 
 
-        self.other_user = UserModel.objects.create_user(
+        self.other_user = User.objects.create_user(
             "BobBoberson", "bob@boberson.com", "pass123"
             "BobBoberson", "bob@boberson.com", "pass123"
         )
         )
 
 

+ 8 - 10
misago/threads/tests/test_thread_model.py

@@ -9,7 +9,7 @@ from misago.threads import testutils
 from misago.threads.models import Poll, Post, Thread, ThreadParticipant
 from misago.threads.models import Poll, Post, Thread, ThreadParticipant
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class ThreadModelTests(TestCase):
 class ThreadModelTests(TestCase):
@@ -46,7 +46,7 @@ class ThreadModelTests(TestCase):
 
 
     def test_synchronize(self):
     def test_synchronize(self):
         """synchronize method updates thread data to reflect its contents"""
         """synchronize method updates thread data to reflect its contents"""
-        user = UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
 
 
         self.assertEqual(self.thread.replies, 0)
         self.assertEqual(self.thread.replies, 0)
 
 
@@ -226,7 +226,7 @@ class ThreadModelTests(TestCase):
 
 
     def test_set_first_post(self):
     def test_set_first_post(self):
         """set_first_post sets first post and poster data on thread"""
         """set_first_post sets first post and poster data on thread"""
-        user = UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
 
 
         datetime = timezone.now() + timedelta(5)
         datetime = timezone.now() + timedelta(5)
 
 
@@ -251,7 +251,7 @@ class ThreadModelTests(TestCase):
 
 
     def test_set_last_post(self):
     def test_set_last_post(self):
         """set_last_post sets first post and poster data on thread"""
         """set_last_post sets first post and poster data on thread"""
-        user = UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
 
 
         datetime = timezone.now() + timedelta(5)
         datetime = timezone.now() + timedelta(5)
 
 
@@ -276,7 +276,7 @@ class ThreadModelTests(TestCase):
 
 
     def test_set_best_answer(self):
     def test_set_best_answer(self):
         """set_best_answer sets best answer and setter data on thread"""
         """set_best_answer sets best answer and setter data on thread"""
-        user = UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
 
 
         best_answer = Post.objects.create(
         best_answer = Post.objects.create(
             category=self.category,
             category=self.category,
@@ -318,7 +318,7 @@ class ThreadModelTests(TestCase):
 
 
     def test_set_invalid_best_answer(self):
     def test_set_invalid_best_answer(self):
         """set_best_answer implements some assertions for data integrity"""
         """set_best_answer implements some assertions for data integrity"""
-        user = UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
 
 
         other_thread = testutils.post_thread(self.category)
         other_thread = testutils.post_thread(self.category)
         with self.assertRaises(ValueError):
         with self.assertRaises(ValueError):
@@ -398,10 +398,8 @@ class ThreadModelTests(TestCase):
         private thread gets deleted automatically
         private thread gets deleted automatically
         when there are no participants left in it
         when there are no participants left in it
         """
         """
-        user_a = UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
-        user_b = UserModel.objects.create_user(
-            "Weebl", "weebl@weeblson.com", "Pass.123"
-        )
+        user_a = User.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
+        user_b = User.objects.create_user("Weebl", "weebl@weeblson.com", "Pass.123")
 
 
         ThreadParticipant.objects.add_participants(self.thread, [user_a, user_b])
         ThreadParticipant.objects.add_participants(self.thread, [user_a, user_b])
         self.assertEqual(self.thread.participants.count(), 2)
         self.assertEqual(self.thread.participants.count(), 2)

+ 3 - 3
misago/threads/tests/test_thread_pollvotes_api.py

@@ -11,7 +11,7 @@ from misago.threads.test import patch_category_acl
 from .test_thread_poll_api import ThreadPollApiTestCase
 from .test_thread_poll_api import ThreadPollApiTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class ThreadGetVotesTests(ThreadPollApiTestCase):
 class ThreadGetVotesTests(ThreadPollApiTestCase):
@@ -112,7 +112,7 @@ class ThreadGetVotesTests(ThreadPollApiTestCase):
             [[v["username"] for v in c["voters"]] for c in response_json][0][0], "bob"
             [[v["username"] for v in c["voters"]] for c in response_json][0][0], "bob"
         )
         )
 
 
-        user = UserModel.objects.get(slug="bob")
+        user = User.objects.get(slug="bob")
 
 
         self.assertEqual(
         self.assertEqual(
             [[v["url"] for v in c["voters"]] for c in response_json][0][0],
             [[v["url"] for v in c["voters"]] for c in response_json][0][0],
@@ -141,7 +141,7 @@ class ThreadGetVotesTests(ThreadPollApiTestCase):
             [[v["username"] for v in c["voters"]] for c in response_json][0][0], "bob"
             [[v["username"] for v in c["voters"]] for c in response_json][0][0], "bob"
         )
         )
 
 
-        user = UserModel.objects.get(slug="bob")
+        user = User.objects.get(slug="bob")
 
 
         self.assertEqual(
         self.assertEqual(
             [[v["url"] for v in c["voters"]] for c in response_json][0][0],
             [[v["url"] for v in c["voters"]] for c in response_json][0][0],

+ 7 - 11
misago/threads/tests/test_threadparticipant_model.py

@@ -6,7 +6,7 @@ from misago.categories.models import Category
 from misago.threads.models import Post, Thread, ThreadParticipant
 from misago.threads.models import Post, Thread, ThreadParticipant
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class ThreadParticipantTests(TestCase):
 class ThreadParticipantTests(TestCase):
@@ -44,10 +44,8 @@ class ThreadParticipantTests(TestCase):
 
 
     def test_set_owner(self):
     def test_set_owner(self):
         """set_owner makes user thread owner"""
         """set_owner makes user thread owner"""
-        user = UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
-        other_user = UserModel.objects.create_user(
-            "Bob2", "bob2@boberson.com", "Pass.123"
-        )
+        user = User.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
+        other_user = User.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123")
 
 
         ThreadParticipant.objects.set_owner(self.thread, user)
         ThreadParticipant.objects.set_owner(self.thread, user)
         self.assertEqual(self.thread.participants.count(), 1)
         self.assertEqual(self.thread.participants.count(), 1)
@@ -68,8 +66,8 @@ class ThreadParticipantTests(TestCase):
     def test_add_participants(self):
     def test_add_participants(self):
         """add_participant adds participant to thread"""
         """add_participant adds participant to thread"""
         users = [
         users = [
-            UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123"),
-            UserModel.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123"),
+            User.objects.create_user("Bob", "bob@boberson.com", "Pass.123"),
+            User.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123"),
         ]
         ]
 
 
         ThreadParticipant.objects.add_participants(self.thread, users)
         ThreadParticipant.objects.add_participants(self.thread, users)
@@ -81,10 +79,8 @@ class ThreadParticipantTests(TestCase):
 
 
     def test_remove_participant(self):
     def test_remove_participant(self):
         """remove_participant deletes participant from thread"""
         """remove_participant deletes participant from thread"""
-        user = UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
-        other_user = UserModel.objects.create_user(
-            "Bob2", "bob2@boberson.com", "Pass.123"
-        )
+        user = User.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
+        other_user = User.objects.create_user("Bob2", "bob2@boberson.com", "Pass.123")
 
 
         ThreadParticipant.objects.add_participants(self.thread, [user])
         ThreadParticipant.objects.add_participants(self.thread, [user])
         ThreadParticipant.objects.add_participants(self.thread, [other_user])
         ThreadParticipant.objects.add_participants(self.thread, [other_user])

+ 4 - 4
misago/threads/testutils.py

@@ -9,7 +9,7 @@ from .checksums import update_post_checksum
 from .models import Poll, Post, Thread
 from .models import Poll, Post, Thread
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 def post_thread(
 def post_thread(
@@ -142,9 +142,9 @@ def post_poll(thread, poster):
 
 
     # one user voted for Alpha choice
     # one user voted for Alpha choice
     try:
     try:
-        user = UserModel.objects.get(slug="bob")
-    except UserModel.DoesNotExist:
-        user = UserModel.objects.create_user("bob", "bob@test.com", "Pass.123")
+        user = User.objects.get(slug="bob")
+    except User.DoesNotExist:
+        user = User.objects.create_user("bob", "bob@test.com", "Pass.123")
 
 
     poll.pollvote_set.create(
     poll.pollvote_set.create(
         category=thread.category,
         category=thread.category,

+ 2 - 2
misago/users/activepostersranking.py

@@ -10,7 +10,7 @@ from misago.conf import settings
 from .models import ActivityRanking
 from .models import ActivityRanking
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 def get_active_posters_ranking():
 def get_active_posters_ranking():
@@ -35,7 +35,7 @@ def build_active_posters_ranking():
         ranked_categories.append(category.pk)
         ranked_categories.append(category.pk)
 
 
     queryset = (
     queryset = (
-        UserModel.objects.filter(
+        User.objects.filter(
             is_active=True,
             is_active=True,
             post__posted_on__gte=tracked_since,
             post__posted_on__gte=tracked_since,
             post__category__in=ranked_categories,
             post__category__in=ranked_categories,

+ 3 - 3
misago/users/api/auth.py

@@ -30,7 +30,7 @@ from misago.users.tokens import (
 from .rest_permissions import UnbannedAnonOnly, UnbannedOnly
 from .rest_permissions import UnbannedAnonOnly, UnbannedOnly
 
 
 
 
-UserModel = auth.get_user_model()
+User = auth.get_user_model()
 
 
 
 
 def gateway(request):
 def gateway(request):
@@ -180,8 +180,8 @@ def change_forgotten_password(request, pk, token):
 
 
     try:
     try:
         try:
         try:
-            user = UserModel.objects.get(pk=pk, is_active=True)
-        except UserModel.DoesNotExist:
+            user = User.objects.get(pk=pk, is_active=True)
+        except User.DoesNotExist:
             raise PasswordChangeFailed(invalid_message)
             raise PasswordChangeFailed(invalid_message)
 
 
         if request.user.is_authenticated and request.user.id != user.id:
         if request.user.is_authenticated and request.user.id != user.id:

+ 4 - 4
misago/users/api/mention.py

@@ -7,7 +7,7 @@ from django.contrib.staticfiles.templatetags.staticfiles import static
 from misago.conf import settings
 from misago.conf import settings
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 @api_view()
 @api_view()
@@ -16,9 +16,9 @@ def mention_suggestions(request):
 
 
     query = request.query_params.get("q", "").lower().strip()[:100]
     query = request.query_params.get("q", "").lower().strip()[:100]
     if query:
     if query:
-        queryset = UserModel.objects.filter(
-            slug__startswith=query, is_active=True
-        ).order_by("slug")[:10]
+        queryset = User.objects.filter(slug__startswith=query, is_active=True).order_by(
+            "slug"
+        )[:10]
 
 
         for user in queryset:
         for user in queryset:
             try:
             try:

+ 5 - 5
misago/users/api/userendpoints/create.py

@@ -18,7 +18,7 @@ from misago.users.registration import (
 )
 )
 from misago.users.setupnewuser import setup_new_user
 from misago.users.setupnewuser import setup_new_user
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 @csrf_protect
 @csrf_protect
@@ -41,12 +41,12 @@ def create_endpoint(request):
 
 
     activation_kwargs = {}
     activation_kwargs = {}
     if request.settings.account_activation == "user":
     if request.settings.account_activation == "user":
-        activation_kwargs = {"requires_activation": UserModel.ACTIVATION_USER}
+        activation_kwargs = {"requires_activation": User.ACTIVATION_USER}
     elif request.settings.account_activation == "admin":
     elif request.settings.account_activation == "admin":
-        activation_kwargs = {"requires_activation": UserModel.ACTIVATION_ADMIN}
+        activation_kwargs = {"requires_activation": User.ACTIVATION_ADMIN}
 
 
     try:
     try:
-        new_user = UserModel.objects.create_user(
+        new_user = User.objects.create_user(
             form.cleaned_data["username"],
             form.cleaned_data["username"],
             form.cleaned_data["email"],
             form.cleaned_data["email"],
             form.cleaned_data["password"],
             form.cleaned_data["password"],
@@ -63,7 +63,7 @@ def create_endpoint(request):
     save_user_agreements(new_user, form)
     save_user_agreements(new_user, form)
     send_welcome_email(request, new_user)
     send_welcome_email(request, new_user)
 
 
-    if new_user.requires_activation == UserModel.ACTIVATION_NONE:
+    if new_user.requires_activation == User.ACTIVATION_NONE:
         authenticated_user = authenticate(
         authenticated_user = authenticate(
             username=new_user.email, password=form.cleaned_data["password"]
             username=new_user.email, password=form.cleaned_data["password"]
         )
         )

+ 1 - 1
misago/users/api/userendpoints/list.py

@@ -9,7 +9,7 @@ from misago.users.serializers import UserCardSerializer
 from misago.users.viewmodels import ActivePosters, RankUsers
 from misago.users.viewmodels import ActivePosters, RankUsers
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 def active(request):
 def active(request):

+ 2 - 2
misago/users/api/usernamechanges.py

@@ -14,7 +14,7 @@ from misago.users.serializers import UsernameChangeSerializer
 from .rest_permissions import BasePermission
 from .rest_permissions import BasePermission
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class UsernameChangesViewSetPermission(BasePermission):
 class UsernameChangesViewSetPermission(BasePermission):
@@ -42,7 +42,7 @@ class UsernameChangesViewSet(viewsets.GenericViewSet):
 
 
         if self.request.query_params.get("user"):
         if self.request.query_params.get("user"):
             user_pk = get_int_or_404(self.request.query_params.get("user"))
             user_pk = get_int_or_404(self.request.query_params.get("user"))
-            queryset = get_object_or_404(UserModel.objects, pk=user_pk).namechanges
+            queryset = get_object_or_404(User.objects, pk=user_pk).namechanges
 
 
         if self.request.query_params.get("search"):
         if self.request.query_params.get("search"):
             search_phrase = self.request.query_params.get("search").strip()
             search_phrase = self.request.query_params.get("search").strip()

+ 2 - 2
misago/users/api/users.py

@@ -53,7 +53,7 @@ from .userendpoints.signature import signature_endpoint
 from .userendpoints.username import moderate_username_endpoint, username_endpoint
 from .userendpoints.username import moderate_username_endpoint, username_endpoint
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class UserViewSetPermission(BasePermission):
 class UserViewSetPermission(BasePermission):
@@ -75,7 +75,7 @@ def allow_self_only(user, pk, message):
 class UserViewSet(viewsets.GenericViewSet):
 class UserViewSet(viewsets.GenericViewSet):
     permission_classes = (UserViewSetPermission,)
     permission_classes = (UserViewSetPermission,)
     parser_classes = (FormParser, JSONParser, MultiPartParser)
     parser_classes = (FormParser, JSONParser, MultiPartParser)
-    queryset = UserModel.objects
+    queryset = User.objects
 
 
     def get_queryset(self):
     def get_queryset(self):
         relations = ("rank", "online_tracker", "ban_cache")
         relations = ("rank", "online_tracker", "ban_cache")

+ 6 - 6
misago/users/authbackends.py

@@ -2,7 +2,7 @@ from django.contrib.auth import get_user_model
 from django.contrib.auth.backends import ModelBackend
 from django.contrib.auth.backends import ModelBackend
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class MisagoBackend(ModelBackend):
 class MisagoBackend(ModelBackend):
@@ -16,20 +16,20 @@ class MisagoBackend(ModelBackend):
             return None
             return None
 
 
         try:
         try:
-            user = UserModel.objects.get_by_username_or_email(username)
-        except UserModel.DoesNotExist:
+            user = User.objects.get_by_username_or_email(username)
+        except User.DoesNotExist:
             # Run the default password hasher once to reduce the timing
             # Run the default password hasher once to reduce the timing
             # difference between an existing and a non-existing user (#20760).
             # difference between an existing and a non-existing user (#20760).
-            UserModel().set_password(password)
+            User().set_password(password)
         else:
         else:
             if user.check_password(password) and self.user_can_authenticate(user):
             if user.check_password(password) and self.user_can_authenticate(user):
                 return user
                 return user
 
 
     def get_user(self, pk):
     def get_user(self, pk):
         try:
         try:
-            manager = UserModel._default_manager
+            manager = User._default_manager
             relations = ("rank", "online_tracker", "ban_cache")
             relations = ("rank", "online_tracker", "ban_cache")
             user = manager.select_related(*relations).get(pk=pk)
             user = manager.select_related(*relations).get(pk=pk)
-        except UserModel.DoesNotExist:
+        except User.DoesNotExist:
             return None
             return None
         return user if self.user_can_authenticate(user) else None
         return user if self.user_can_authenticate(user) else None

+ 8 - 8
misago/users/forms/admin.py

@@ -14,7 +14,7 @@ from misago.users.profilefields import profilefields
 from misago.users.utils import hash_email
 from misago.users.utils import hash_email
 from misago.users.validators import validate_email, validate_username
 from misago.users.validators import validate_email, validate_username
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class UserBaseForm(forms.ModelForm):
 class UserBaseForm(forms.ModelForm):
@@ -23,7 +23,7 @@ class UserBaseForm(forms.ModelForm):
     email = forms.EmailField(label=_("E-mail address"))
     email = forms.EmailField(label=_("E-mail address"))
 
 
     class Meta:
     class Meta:
-        model = UserModel
+        model = User
         fields = ["username", "email", "title"]
         fields = ["username", "email", "title"]
 
 
     def __init__(self, *args, **kwargs):
     def __init__(self, *args, **kwargs):
@@ -67,7 +67,7 @@ class NewUserForm(UserBaseForm):
     )
     )
 
 
     class Meta:
     class Meta:
-        model = UserModel
+        model = User
         fields = ["username", "email", "title"]
         fields = ["username", "email", "title"]
 
 
 
 
@@ -167,18 +167,18 @@ class EditUserForm(UserBaseForm):
     limits_private_thread_invites_to = forms.TypedChoiceField(
     limits_private_thread_invites_to = forms.TypedChoiceField(
         label=_("Who can add user to private threads"),
         label=_("Who can add user to private threads"),
         coerce=int,
         coerce=int,
-        choices=UserModel.LIMIT_INVITES_TO_CHOICES,
+        choices=User.LIMIT_INVITES_TO_CHOICES,
     )
     )
 
 
     subscribe_to_started_threads = forms.TypedChoiceField(
     subscribe_to_started_threads = forms.TypedChoiceField(
-        label=_("Started threads"), coerce=int, choices=UserModel.SUBSCRIPTION_CHOICES
+        label=_("Started threads"), coerce=int, choices=User.SUBSCRIPTION_CHOICES
     )
     )
     subscribe_to_replied_threads = forms.TypedChoiceField(
     subscribe_to_replied_threads = forms.TypedChoiceField(
-        label=_("Replid threads"), coerce=int, choices=UserModel.SUBSCRIPTION_CHOICES
+        label=_("Replid threads"), coerce=int, choices=User.SUBSCRIPTION_CHOICES
     )
     )
 
 
     class Meta:
     class Meta:
-        model = UserModel
+        model = User
         fields = [
         fields = [
             "username",
             "username",
             "email",
             "email",
@@ -659,7 +659,7 @@ class RequestDataDownloadsForm(forms.Form):
             username_match = Q(slug__in=data["user_identifiers"])
             username_match = Q(slug__in=data["user_identifiers"])
             email_match = Q(email_hash__in=map(hash_email, data["user_identifiers"]))
             email_match = Q(email_hash__in=map(hash_email, data["user_identifiers"]))
 
 
-            data["users"] = list(UserModel.objects.filter(username_match | email_match))
+            data["users"] = list(User.objects.filter(username_match | email_match))
 
 
             if len(data["users"]) != len(data["user_identifiers"]):
             if len(data["users"]) != len(data["user_identifiers"]):
                 raise forms.ValidationError(
                 raise forms.ValidationError(

+ 4 - 4
misago/users/forms/auth.py

@@ -8,7 +8,7 @@ from django.utils.translation import gettext_lazy as _
 from misago.users.bans import get_user_ban
 from misago.users.bans import get_user_ban
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class MisagoAuthMixin(object):
 class MisagoAuthMixin(object):
@@ -126,11 +126,11 @@ class GetUserForm(MisagoAuthMixin, forms.Form):
             )
             )
 
 
         try:
         try:
-            user = UserModel.objects.get_by_email(data["email"])
+            user = User.objects.get_by_email(data["email"])
             if not user.is_active:
             if not user.is_active:
-                raise UserModel.DoesNotExist()
+                raise User.DoesNotExist()
             self.user_cache = user
             self.user_cache = user
-        except UserModel.DoesNotExist:
+        except User.DoesNotExist:
             raise forms.ValidationError(
             raise forms.ValidationError(
                 _("No user with this e-mail exists."), code="not_found"
                 _("No user with this e-mail exists."), code="not_found"
             )
             )

+ 2 - 2
misago/users/forms/register.py

@@ -12,7 +12,7 @@ from misago.users.validators import (
 )
 )
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class BaseRegisterForm(forms.Form):
 class BaseRegisterForm(forms.Form):
@@ -89,7 +89,7 @@ class RegisterForm(BaseRegisterForm):
         if cleaned_data.get("password"):
         if cleaned_data.get("password"):
             validate_password(
             validate_password(
                 cleaned_data["password"],
                 cleaned_data["password"],
-                user=UserModel(
+                user=User(
                     username=cleaned_data.get("username"),
                     username=cleaned_data.get("username"),
                     email=cleaned_data.get("email"),
                     email=cleaned_data.get("email"),
                 ),
                 ),

+ 3 - 4
misago/users/management/commands/deleteinactiveusers.py

@@ -8,7 +8,7 @@ from misago.conf import settings
 from misago.core.pgutils import chunk_queryset
 from misago.core.pgutils import chunk_queryset
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class Command(BaseCommand):
 class Command(BaseCommand):
@@ -27,9 +27,8 @@ class Command(BaseCommand):
             days=settings.MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS
             days=settings.MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS
         )
         )
 
 
-        queryset = UserModel.objects.filter(
-            requires_activation__gt=UserModel.ACTIVATION_NONE,
-            joined_on__lt=joined_on_cutoff,
+        queryset = User.objects.filter(
+            requires_activation__gt=User.ACTIVATION_NONE, joined_on__lt=joined_on_cutoff
         )
         )
 
 
         for user in chunk_queryset(queryset):
         for user in chunk_queryset(queryset):

+ 2 - 2
misago/users/management/commands/deletemarkedusers.py

@@ -7,7 +7,7 @@ from misago.core.pgutils import chunk_queryset
 from misago.users.permissions import can_delete_own_account
 from misago.users.permissions import can_delete_own_account
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class Command(BaseCommand):
 class Command(BaseCommand):
@@ -19,7 +19,7 @@ class Command(BaseCommand):
     def handle(self, *args, **options):
     def handle(self, *args, **options):
         users_deleted = 0
         users_deleted = 0
 
 
-        queryset = UserModel.objects.filter(is_deleting_account=True)
+        queryset = User.objects.filter(is_deleting_account=True)
 
 
         for user in chunk_queryset(queryset):
         for user in chunk_queryset(queryset):
             if can_delete_own_account(user, user):
             if can_delete_own_account(user, user):

+ 2 - 2
misago/users/management/commands/deleteprofilefield.py

@@ -3,7 +3,7 @@ from django.core.management.base import CommandError, BaseCommand
 
 
 from misago.core.pgutils import chunk_queryset
 from misago.core.pgutils import chunk_queryset
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class Command(BaseCommand):
 class Command(BaseCommand):
@@ -20,7 +20,7 @@ class Command(BaseCommand):
 
 
         fields_deleted = 0
         fields_deleted = 0
 
 
-        queryset = UserModel.objects.filter(profile_fields__has_keys=[fieldname])
+        queryset = User.objects.filter(profile_fields__has_keys=[fieldname])
 
 
         for user in chunk_queryset(queryset):
         for user in chunk_queryset(queryset):
             if fieldname in user.profile_fields.keys():
             if fieldname in user.profile_fields.keys():

+ 2 - 2
misago/users/management/commands/listusedprofilefields.py

@@ -4,7 +4,7 @@ from django.core.management.base import BaseCommand
 from misago.core.pgutils import chunk_queryset
 from misago.core.pgutils import chunk_queryset
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class Command(BaseCommand):
 class Command(BaseCommand):
@@ -13,7 +13,7 @@ class Command(BaseCommand):
     def handle(self, *args, **options):
     def handle(self, *args, **options):
         keys = {}
         keys = {}
 
 
-        for user in chunk_queryset(UserModel.objects.all()):
+        for user in chunk_queryset(User.objects.all()):
             for key in user.profile_fields.keys():
             for key in user.profile_fields.keys():
                 keys.setdefault(key, 0)
                 keys.setdefault(key, 0)
                 keys[key] += 1
                 keys[key] += 1

+ 2 - 2
misago/users/management/commands/populateonlinetracker.py

@@ -5,7 +5,7 @@ from misago.core.pgutils import chunk_queryset
 from misago.users.models import Online
 from misago.users.models import Online
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class Command(BaseCommand):
 class Command(BaseCommand):
@@ -13,7 +13,7 @@ class Command(BaseCommand):
 
 
     def handle(self, *args, **options):
     def handle(self, *args, **options):
         entries_created = 0
         entries_created = 0
-        queryset = UserModel.objects.filter(online_tracker__isnull=True)
+        queryset = User.objects.filter(online_tracker__isnull=True)
         for user in chunk_queryset(queryset):
         for user in chunk_queryset(queryset):
             Online.objects.create(user=user, last_click=user.last_login)
             Online.objects.create(user=user, last_click=user.last_login)
             entries_created += 1
             entries_created += 1

+ 3 - 3
misago/users/management/commands/synchronizeusers.py

@@ -8,14 +8,14 @@ from misago.core.management.progressbar import show_progress
 from misago.core.pgutils import chunk_queryset
 from misago.core.pgutils import chunk_queryset
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class Command(BaseCommand):
 class Command(BaseCommand):
     help = "Synchronizes users"
     help = "Synchronizes users"
 
 
     def handle(self, *args, **options):
     def handle(self, *args, **options):
-        users_to_sync = UserModel.objects.count()
+        users_to_sync = User.objects.count()
 
 
         if not users_to_sync:
         if not users_to_sync:
             self.stdout.write("\n\nNo users were found")
             self.stdout.write("\n\nNo users were found")
@@ -31,7 +31,7 @@ class Command(BaseCommand):
         show_progress(self, synchronized_count, users_to_sync)
         show_progress(self, synchronized_count, users_to_sync)
         start_time = time.time()
         start_time = time.time()
 
 
-        for user in chunk_queryset(UserModel.objects.all()):
+        for user in chunk_queryset(User.objects.all()):
             user.threads = user.thread_set.filter(
             user.threads = user.thread_set.filter(
                 category__in=categories, is_hidden=False, is_unapproved=False
                 category__in=categories, is_hidden=False, is_unapproved=False
             ).count()
             ).count()

+ 2 - 2
misago/users/search.py

@@ -11,7 +11,7 @@ from .serializers import UserCardSerializer
 HEAD_RESULTS = 8
 HEAD_RESULTS = 8
 TAIL_RESULTS = 8
 TAIL_RESULTS = 8
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class SearchUsers(SearchProvider):
 class SearchUsers(SearchProvider):
@@ -38,7 +38,7 @@ class SearchUsers(SearchProvider):
 
 
 
 
 def search_users(**filters):
 def search_users(**filters):
-    queryset = UserModel.objects.order_by("slug").select_related(
+    queryset = User.objects.order_by("slug").select_related(
         "rank", "ban_cache", "online_tracker"
         "rank", "ban_cache", "online_tracker"
     )
     )
 
 

+ 2 - 2
misago/users/serializers/auth.py

@@ -7,7 +7,7 @@ from misago.acl.useracl import serialize_user_acl
 
 
 from .user import UserSerializer
 from .user import UserSerializer
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 __all__ = ["AuthenticatedUserSerializer", "AnonymousUserSerializer"]
 __all__ = ["AuthenticatedUserSerializer", "AnonymousUserSerializer"]
 
 
@@ -26,7 +26,7 @@ class AuthenticatedUserSerializer(UserSerializer, AuthFlags):
     is_anonymous = serializers.SerializerMethodField()
     is_anonymous = serializers.SerializerMethodField()
 
 
     class Meta:
     class Meta:
-        model = UserModel
+        model = User
         fields = UserSerializer.Meta.fields + [
         fields = UserSerializer.Meta.fields + [
             "has_usable_password",
             "has_usable_password",
             "is_hiding_presence",
             "is_hiding_presence",

+ 3 - 3
misago/users/serializers/moderation.py

@@ -6,14 +6,14 @@ from django.utils.translation import ngettext
 from misago.conf import settings
 from misago.conf import settings
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 __all__ = ["ModerateAvatarSerializer", "ModerateSignatureSerializer"]
 __all__ = ["ModerateAvatarSerializer", "ModerateSignatureSerializer"]
 
 
 
 
 class ModerateAvatarSerializer(serializers.ModelSerializer):
 class ModerateAvatarSerializer(serializers.ModelSerializer):
     class Meta:
     class Meta:
-        model = UserModel
+        model = User
         fields = [
         fields = [
             "is_avatar_locked",
             "is_avatar_locked",
             "avatar_lock_user_message",
             "avatar_lock_user_message",
@@ -23,7 +23,7 @@ class ModerateAvatarSerializer(serializers.ModelSerializer):
 
 
 class ModerateSignatureSerializer(serializers.ModelSerializer):
 class ModerateSignatureSerializer(serializers.ModelSerializer):
     class Meta:
     class Meta:
-        model = UserModel
+        model = User
         fields = [
         fields = [
             "signature",
             "signature",
             "is_signature_locked",
             "is_signature_locked",

+ 3 - 3
misago/users/serializers/options.py

@@ -9,7 +9,7 @@ from misago.users.permissions import allow_delete_own_account
 from misago.users.validators import validate_email, validate_username
 from misago.users.validators import validate_email, validate_username
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 __all__ = [
 __all__ = [
     "ForumOptionsSerializer",
     "ForumOptionsSerializer",
@@ -23,7 +23,7 @@ __all__ = [
 
 
 class ForumOptionsSerializer(serializers.ModelSerializer):
 class ForumOptionsSerializer(serializers.ModelSerializer):
     class Meta:
     class Meta:
-        model = UserModel
+        model = User
         fields = [
         fields = [
             "is_hiding_presence",
             "is_hiding_presence",
             "limits_private_thread_invites_to",
             "limits_private_thread_invites_to",
@@ -39,7 +39,7 @@ class ForumOptionsSerializer(serializers.ModelSerializer):
 
 
 class EditSignatureSerializer(serializers.ModelSerializer):
 class EditSignatureSerializer(serializers.ModelSerializer):
     class Meta:
     class Meta:
-        model = UserModel
+        model = User
         fields = ["signature"]
         fields = ["signature"]
 
 
     def validate(self, data):
     def validate(self, data):

+ 2 - 2
misago/users/serializers/user.py

@@ -8,7 +8,7 @@ from misago.core.serializers import MutableFields
 from . import RankSerializer
 from . import RankSerializer
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 __all__ = ["StatusSerializer", "UserSerializer", "UserCardSerializer"]
 __all__ = ["StatusSerializer", "UserSerializer", "UserCardSerializer"]
 
 
@@ -41,7 +41,7 @@ class UserSerializer(serializers.ModelSerializer, MutableFields):
     url = serializers.SerializerMethodField()
     url = serializers.SerializerMethodField()
 
 
     class Meta:
     class Meta:
-        model = UserModel
+        model = User
         fields = [
         fields = [
             "id",
             "id",
             "username",
             "username",

+ 2 - 2
misago/users/signals.py

@@ -14,7 +14,7 @@ from .models import AuditTrail
 from .profilefields import profilefields
 from .profilefields import profilefields
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 anonymize_user_data = Signal()
 anonymize_user_data = Signal()
 archive_user_data = Signal()
 archive_user_data = Signal()
@@ -94,7 +94,7 @@ def remove_old_registrations_ips(sender, **kwargs):
     ip_is_too_new = Q(joined_on__gt=datetime_cutoff)
     ip_is_too_new = Q(joined_on__gt=datetime_cutoff)
     ip_is_already_removed = Q(joined_from_ip__isnull=True)
     ip_is_already_removed = Q(joined_from_ip__isnull=True)
 
 
-    queryset = UserModel.objects.exclude(ip_is_too_new | ip_is_already_removed)
+    queryset = User.objects.exclude(ip_is_too_new | ip_is_already_removed)
     queryset.update(joined_from_ip=None)
     queryset.update(joined_from_ip=None)
 
 
 
 

+ 8 - 8
misago/users/social/pipeline.py

@@ -30,7 +30,7 @@ from misago.users.validators import (
 from .utils import get_social_auth_backend_name, perpare_username
 from .utils import get_social_auth_backend_name, perpare_username
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 def validate_ip_not_banned(strategy, details, backend, user=None, *args, **kwargs):
 def validate_ip_not_banned(strategy, details, backend, user=None, *args, **kwargs):
@@ -68,8 +68,8 @@ def associate_by_email(strategy, details, backend, user=None, *args, **kwargs):
         return None
         return None
 
 
     try:
     try:
-        user = UserModel.objects.get_by_email(email)
-    except UserModel.DoesNotExist:
+        user = User.objects.get_by_email(email)
+    except User.DoesNotExist:
         return None
         return None
 
 
     backend_name = get_social_auth_backend_name(backend.name)
     backend_name = get_social_auth_backend_name(backend.name)
@@ -158,9 +158,9 @@ def create_user(strategy, details, backend, user=None, *args, **kwargs):
 
 
     activation_kwargs = {}
     activation_kwargs = {}
     if settings.account_activation == "admin":
     if settings.account_activation == "admin":
-        activation_kwargs = {"requires_activation": UserModel.ACTIVATION_ADMIN}
+        activation_kwargs = {"requires_activation": User.ACTIVATION_ADMIN}
 
 
-    new_user = UserModel.objects.create_user(
+    new_user = User.objects.create_user(
         username, email, joined_from_ip=request.user_ip, **activation_kwargs
         username, email, joined_from_ip=request.user_ip, **activation_kwargs
     )
     )
 
 
@@ -197,12 +197,12 @@ def create_user_with_form(strategy, details, backend, user=None, *args, **kwargs
 
 
         activation_kwargs = {}
         activation_kwargs = {}
         if settings.account_activation == "admin":
         if settings.account_activation == "admin":
-            activation_kwargs = {"requires_activation": UserModel.ACTIVATION_ADMIN}
+            activation_kwargs = {"requires_activation": User.ACTIVATION_ADMIN}
         elif settings.account_activation == "user" and not email_verified:
         elif settings.account_activation == "user" and not email_verified:
-            activation_kwargs = {"requires_activation": UserModel.ACTIVATION_USER}
+            activation_kwargs = {"requires_activation": User.ACTIVATION_USER}
 
 
         try:
         try:
-            new_user = UserModel.objects.create_user(
+            new_user = User.objects.create_user(
                 form.cleaned_data["username"],
                 form.cleaned_data["username"],
                 form.cleaned_data["email"],
                 form.cleaned_data["email"],
                 joined_from_ip=request.user_ip,
                 joined_from_ip=request.user_ip,

+ 5 - 7
misago/users/tests/test_activepostersranking.py

@@ -12,7 +12,7 @@ from misago.users.activepostersranking import (
 from misago.users.testutils import AuthenticatedUserTestCase
 from misago.users.testutils import AuthenticatedUserTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class TestActivePostersRanking(AuthenticatedUserTestCase):
 class TestActivePostersRanking(AuthenticatedUserTestCase):
@@ -30,15 +30,13 @@ class TestActivePostersRanking(AuthenticatedUserTestCase):
         self.assertEqual(empty_ranking["users_count"], 0)
         self.assertEqual(empty_ranking["users_count"], 0)
 
 
         # other user that will be posting
         # other user that will be posting
-        other_user = UserModel.objects.create_user(
-            "OtherUser", "other@user.com", "pass123"
-        )
+        other_user = User.objects.create_user("OtherUser", "other@user.com", "pass123")
 
 
         # lurker user that won't post anything
         # lurker user that won't post anything
-        UserModel.objects.create_user("Lurker", "lurker@user.com", "pass123")
+        User.objects.create_user("Lurker", "lurker@user.com", "pass123")
 
 
         # unranked user that posted something 400 days ago
         # unranked user that posted something 400 days ago
-        unranked_user = UserModel.objects.create_user(
+        unranked_user = User.objects.create_user(
             "UnrankedUser", "unranked@user.com", "pass123"
             "UnrankedUser", "unranked@user.com", "pass123"
         )
         )
 
 
@@ -68,7 +66,7 @@ class TestActivePostersRanking(AuthenticatedUserTestCase):
         self.assertEqual(ranking["users"][1].score, 1)
         self.assertEqual(ranking["users"][1].score, 1)
 
 
         # disabled users are not ranked
         # disabled users are not ranked
-        disabled = UserModel.objects.create_user(
+        disabled = User.objects.create_user(
             "DisabledUser", "disabled@user.com", "pass123"
             "DisabledUser", "disabled@user.com", "pass123"
         )
         )
 
 

+ 8 - 8
misago/users/tests/test_audittrail.py

@@ -9,7 +9,7 @@ from misago.users.signals import remove_old_ips
 from misago.users.testutils import UserTestCase
 from misago.users.testutils import UserTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 USER_IP = "13.41.51.41"
 USER_IP = "13.41.51.41"
 
 
@@ -25,7 +25,7 @@ class CreateAuditTrailTests(UserTestCase):
     def setUp(self):
     def setUp(self):
         super().setUp()
         super().setUp()
 
 
-        self.obj = UserModel.objects.create_user("BobBoberson", "bob@example.com")
+        self.obj = User.objects.create_user("BobBoberson", "bob@example.com")
 
 
     def test_create_audit_require_model(self):
     def test_create_audit_require_model(self):
         """create_audit_trail requires model instance"""
         """create_audit_trail requires model instance"""
@@ -89,15 +89,15 @@ class CreateAuditTrailTests(UserTestCase):
         audit_trail = user.audittrail_set.all()[0]
         audit_trail = user.audittrail_set.all()[0]
         audit_trail.delete()
         audit_trail.delete()
 
 
-        UserModel.objects.get(id=user.id)
-        UserModel.objects.get(id=self.obj.id)
+        User.objects.get(id=user.id)
+        User.objects.get(id=self.obj.id)
 
 
 
 
 class CreateUserAuditTrailTests(UserTestCase):
 class CreateUserAuditTrailTests(UserTestCase):
     def setUp(self):
     def setUp(self):
         super().setUp()
         super().setUp()
 
 
-        self.obj = UserModel.objects.create_user("BobBoberson", "bob@example.com")
+        self.obj = User.objects.create_user("BobBoberson", "bob@example.com")
 
 
     def test_create_user_audit_require_model(self):
     def test_create_user_audit_require_model(self):
         """create_user_audit_trail requires model instance"""
         """create_user_audit_trail requires model instance"""
@@ -155,15 +155,15 @@ class CreateUserAuditTrailTests(UserTestCase):
         audit_trail = user.audittrail_set.all()[0]
         audit_trail = user.audittrail_set.all()[0]
         audit_trail.delete()
         audit_trail.delete()
 
 
-        UserModel.objects.get(id=user.id)
-        UserModel.objects.get(id=self.obj.id)
+        User.objects.get(id=user.id)
+        User.objects.get(id=self.obj.id)
 
 
 
 
 class RemoveOldAuditTrailsTest(UserTestCase):
 class RemoveOldAuditTrailsTest(UserTestCase):
     def setUp(self):
     def setUp(self):
         super().setUp()
         super().setUp()
 
 
-        self.obj = UserModel.objects.create_user("BobBoberson", "bob@example.com")
+        self.obj = User.objects.create_user("BobBoberson", "bob@example.com")
 
 
     def test_recent_audit_trail_is_kept(self):
     def test_recent_audit_trail_is_kept(self):
         """remove_old_ips keeps recent audit trails"""
         """remove_old_ips keeps recent audit trails"""

+ 15 - 15
misago/users/tests/test_auth_api.py

@@ -6,7 +6,7 @@ from misago.users.models import Ban
 from misago.users.tokens import make_password_change_token
 from misago.users.tokens import make_password_change_token
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class GatewayTests(TestCase):
 class GatewayTests(TestCase):
@@ -29,7 +29,7 @@ class GatewayTests(TestCase):
 
 
     def test_login(self):
     def test_login(self):
         """api signs user in"""
         """api signs user in"""
-        user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         response = self.client.post(
         response = self.client.post(
             "/api/auth/", data={"username": "Bob", "password": "Pass.123"}
             "/api/auth/", data={"username": "Bob", "password": "Pass.123"}
@@ -46,7 +46,7 @@ class GatewayTests(TestCase):
 
 
     def test_login_whitespaces_password(self):
     def test_login_whitespaces_password(self):
         """api signs user in with password left untouched"""
         """api signs user in with password left untouched"""
-        user = UserModel.objects.create_user("Bob", "bob@test.com", " Pass.123 ")
+        user = User.objects.create_user("Bob", "bob@test.com", " Pass.123 ")
 
 
         response = self.client.post(
         response = self.client.post(
             "/api/auth/", data={"username": "Bob", "password": "Pass.123"}
             "/api/auth/", data={"username": "Bob", "password": "Pass.123"}
@@ -92,7 +92,7 @@ class GatewayTests(TestCase):
 
 
     def test_login_not_usable_password(self):
     def test_login_not_usable_password(self):
         """login api fails to sign user with not-usable password in"""
         """login api fails to sign user with not-usable password in"""
-        UserModel.objects.create_user("Bob", "bob@test.com")
+        User.objects.create_user("Bob", "bob@test.com")
 
 
         response = self.client.post(
         response = self.client.post(
             "/api/auth/", data={"username": "Bob", "password": "Pass.123"}
             "/api/auth/", data={"username": "Bob", "password": "Pass.123"}
@@ -105,7 +105,7 @@ class GatewayTests(TestCase):
 
 
     def test_login_banned(self):
     def test_login_banned(self):
         """login api fails to sign banned user in"""
         """login api fails to sign banned user in"""
-        UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         ban = Ban.objects.create(
         ban = Ban.objects.create(
             check_type=Ban.USERNAME,
             check_type=Ban.USERNAME,
@@ -133,7 +133,7 @@ class GatewayTests(TestCase):
 
 
     def test_login_banned_staff(self):
     def test_login_banned_staff(self):
         """login api signs banned staff member in"""
         """login api signs banned staff member in"""
-        user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         user.is_staff = True
         user.is_staff = True
         user.save()
         user.save()
@@ -158,7 +158,7 @@ class GatewayTests(TestCase):
 
 
     def test_login_ban_registration_only(self):
     def test_login_ban_registration_only(self):
         """login api ignores registration-only bans"""
         """login api ignores registration-only bans"""
-        user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         Ban.objects.create(
         Ban.objects.create(
             check_type=Ban.USERNAME, banned_value="bob", registration_only=True
             check_type=Ban.USERNAME, banned_value="bob", registration_only=True
@@ -178,7 +178,7 @@ class GatewayTests(TestCase):
 
 
     def test_login_inactive_admin(self):
     def test_login_inactive_admin(self):
         """login api fails to sign admin-activated user in"""
         """login api fails to sign admin-activated user in"""
-        UserModel.objects.create_user(
+        User.objects.create_user(
             "Bob", "bob@test.com", "Pass.123", requires_activation=1
             "Bob", "bob@test.com", "Pass.123", requires_activation=1
         )
         )
 
 
@@ -198,7 +198,7 @@ class GatewayTests(TestCase):
 
 
     def test_login_inactive_user(self):
     def test_login_inactive_user(self):
         """login api fails to sign user-activated user in"""
         """login api fails to sign user-activated user in"""
-        UserModel.objects.create_user(
+        User.objects.create_user(
             "Bob", "bob@test.com", "Pass.123", requires_activation=2
             "Bob", "bob@test.com", "Pass.123", requires_activation=2
         )
         )
 
 
@@ -218,7 +218,7 @@ class GatewayTests(TestCase):
 
 
     def test_login_disabled_user(self):
     def test_login_disabled_user(self):
         """its impossible to sign in to disabled account"""
         """its impossible to sign in to disabled account"""
-        user = UserModel.objects.create_user(
+        user = User.objects.create_user(
             "Bob", "bob@test.com", "Pass.123", is_active=False
             "Bob", "bob@test.com", "Pass.123", is_active=False
         )
         )
 
 
@@ -250,7 +250,7 @@ class UserCredentialsTests(TestCase):
 
 
 class SendActivationApiTests(TestCase):
 class SendActivationApiTests(TestCase):
     def setUp(self):
     def setUp(self):
-        self.user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        self.user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
         self.user.requires_activation = 1
         self.user.requires_activation = 1
         self.user.save()
         self.user.save()
 
 
@@ -368,7 +368,7 @@ class SendActivationApiTests(TestCase):
 
 
 class SendPasswordFormApiTests(TestCase):
 class SendPasswordFormApiTests(TestCase):
     def setUp(self):
     def setUp(self):
-        self.user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        self.user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         self.link = "/api/auth/send-password-form/"
         self.link = "/api/auth/send-password-form/"
 
 
@@ -479,7 +479,7 @@ class SendPasswordFormApiTests(TestCase):
 
 
 class ChangePasswordApiTests(TestCase):
 class ChangePasswordApiTests(TestCase):
     def setUp(self):
     def setUp(self):
-        self.user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        self.user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         self.link = "/api/auth/change-password/%s/%s/"
         self.link = "/api/auth/change-password/%s/%s/"
 
 
@@ -491,7 +491,7 @@ class ChangePasswordApiTests(TestCase):
         )
         )
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.status_code, 200)
 
 
-        user = UserModel.objects.get(id=self.user.pk)
+        user = User.objects.get(id=self.user.pk)
         self.assertTrue(user.check_password("n3wp4ss!"))
         self.assertTrue(user.check_password("n3wp4ss!"))
 
 
     def test_submit_with_whitespaces(self):
     def test_submit_with_whitespaces(self):
@@ -502,7 +502,7 @@ class ChangePasswordApiTests(TestCase):
         )
         )
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.status_code, 200)
 
 
-        user = UserModel.objects.get(id=self.user.pk)
+        user = User.objects.get(id=self.user.pk)
         self.assertTrue(user.check_password(" n3wp4ss! "))
         self.assertTrue(user.check_password(" n3wp4ss! "))
 
 
     def test_submit_invalid_data(self):
     def test_submit_invalid_data(self):

+ 2 - 2
misago/users/tests/test_auth_backend.py

@@ -4,7 +4,7 @@ from django.test import TestCase
 from misago.users.authbackends import MisagoBackend
 from misago.users.authbackends import MisagoBackend
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 backend = MisagoBackend()
 backend = MisagoBackend()
 
 
@@ -12,7 +12,7 @@ backend = MisagoBackend()
 class MisagoBackendTests(TestCase):
 class MisagoBackendTests(TestCase):
     def setUp(self):
     def setUp(self):
         self.password = "Pass.123"
         self.password = "Pass.123"
-        self.user = UserModel.objects.create_user(
+        self.user = User.objects.create_user(
             "BobBoberson", "bob@test.com", self.password
             "BobBoberson", "bob@test.com", self.password
         )
         )
 
 

+ 2 - 2
misago/users/tests/test_avatarserver_views.py

@@ -5,12 +5,12 @@ from django.urls import reverse
 from misago.conf import settings
 from misago.conf import settings
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class AvatarServerTests(TestCase):
 class AvatarServerTests(TestCase):
     def setUp(self):
     def setUp(self):
-        self.user = UserModel.objects.create_user("Bob", "bob@bob.com", "Pass123")
+        self.user = User.objects.create_user("Bob", "bob@bob.com", "Pass123")
 
 
         self.user.avatars = [
         self.user.avatars = [
             {"size": 200, "url": "/media/avatars/avatar-200.png"},
             {"size": 200, "url": "/media/avatars/avatar-200.png"},

+ 3 - 3
misago/users/tests/test_bans.py

@@ -17,7 +17,7 @@ from misago.users.bans import (
 from misago.users.constants import BANS_CACHE
 from misago.users.constants import BANS_CACHE
 from misago.users.models import Ban
 from misago.users.models import Ban
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 cache_versions = get_cache_versions()
 cache_versions = get_cache_versions()
 
 
@@ -126,7 +126,7 @@ class GetBanTests(TestCase):
 
 
 class UserBansTests(TestCase):
 class UserBansTests(TestCase):
     def setUp(self):
     def setUp(self):
-        self.user = UserModel.objects.create_user("Bob", "bob@boberson.com", "pass123")
+        self.user = User.objects.create_user("Bob", "bob@boberson.com", "pass123")
 
 
     def test_no_ban(self):
     def test_no_ban(self):
         """user is not caught by ban"""
         """user is not caught by ban"""
@@ -243,7 +243,7 @@ class RequestIPBansTests(TestCase):
 class BanUserTests(TestCase):
 class BanUserTests(TestCase):
     def test_ban_user(self):
     def test_ban_user(self):
         """ban_user utility bans user"""
         """ban_user utility bans user"""
-        user = UserModel.objects.create_user("Bob", "bob@boberson.com", "pass123")
+        user = User.objects.create_user("Bob", "bob@boberson.com", "pass123")
 
 
         ban = ban_user(user, "User reason", "Staff reason")
         ban = ban_user(user, "User reason", "Staff reason")
         self.assertEqual(ban.user_message, "User reason")
         self.assertEqual(ban.user_message, "User reason")

+ 1 - 1
misago/users/tests/test_bio_profilefield.py

@@ -4,7 +4,7 @@ from django.urls import reverse
 from misago.admin.testutils import AdminTestCase
 from misago.admin.testutils import AdminTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class BioProfileFieldTests(AdminTestCase):
 class BioProfileFieldTests(AdminTestCase):

+ 2 - 2
misago/users/tests/test_credentialchange.py

@@ -4,7 +4,7 @@ from django.test import TestCase
 from misago.users import credentialchange
 from misago.users import credentialchange
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class MockRequest(object):
 class MockRequest(object):
@@ -15,7 +15,7 @@ class MockRequest(object):
 
 
 class CredentialChangeTests(TestCase):
 class CredentialChangeTests(TestCase):
     def setUp(self):
     def setUp(self):
-        self.user = UserModel.objects.create_user("Bob", "bob@bob.com", "pass123")
+        self.user = User.objects.create_user("Bob", "bob@bob.com", "pass123")
 
 
     def test_valid_token_generation(self):
     def test_valid_token_generation(self):
         """credentialchange module allows for store and read of change token"""
         """credentialchange module allows for store and read of change token"""

+ 2 - 2
misago/users/tests/test_datadownloadsadmin_views.py

@@ -9,7 +9,7 @@ from misago.users.datadownloads import request_user_data_download
 from misago.users.models import DataDownload
 from misago.users.models import DataDownload
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 TESTFILES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "testfiles")
 TESTFILES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "testfiles")
 TEST_FILE_PATH = os.path.join(TESTFILES_DIR, "avatar.png")
 TEST_FILE_PATH = os.path.join(TESTFILES_DIR, "avatar.png")
@@ -87,7 +87,7 @@ class DataDownloadAdminViewsTests(AdminTestCase):
         response = self.client.get(reverse("misago:admin:users:data-downloads:request"))
         response = self.client.get(reverse("misago:admin:users:data-downloads:request"))
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.status_code, 200)
 
 
-        other_user = UserModel.objects.create_user("bob", "bob@boberson.com")
+        other_user = User.objects.create_user("bob", "bob@boberson.com")
 
 
         response = self.client.post(
         response = self.client.post(
             reverse("misago:admin:users:data-downloads:request"),
             reverse("misago:admin:users:data-downloads:request"),

+ 15 - 15
misago/users/tests/test_deleteinactiveusers.py

@@ -9,18 +9,18 @@ from django.utils import timezone
 from misago.users.management.commands import deleteinactiveusers
 from misago.users.management.commands import deleteinactiveusers
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class DeleteInactiveUsersTests(TestCase):
 class DeleteInactiveUsersTests(TestCase):
     def setUp(self):
     def setUp(self):
-        self.user = UserModel.objects.create_user("Bob", "bob@bob.com", "pass123")
+        self.user = User.objects.create_user("Bob", "bob@bob.com", "pass123")
 
 
     @override_settings(MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS=2)
     @override_settings(MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS=2)
     def test_delete_user_activation_user(self):
     def test_delete_user_activation_user(self):
         """deletes user that didn't activate their account within required time"""
         """deletes user that didn't activate their account within required time"""
         self.user.joined_on = timezone.now() - timedelta(days=2)
         self.user.joined_on = timezone.now() - timedelta(days=2)
-        self.user.requires_activation = UserModel.ACTIVATION_USER
+        self.user.requires_activation = User.ACTIVATION_USER
         self.user.save()
         self.user.save()
 
 
         out = StringIO()
         out = StringIO()
@@ -29,14 +29,14 @@ class DeleteInactiveUsersTests(TestCase):
 
 
         self.assertEqual(command_output, "Deleted users: 1")
         self.assertEqual(command_output, "Deleted users: 1")
 
 
-        with self.assertRaises(UserModel.DoesNotExist):
-            UserModel.objects.get(pk=self.user.pk)
+        with self.assertRaises(User.DoesNotExist):
+            User.objects.get(pk=self.user.pk)
 
 
     @override_settings(MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS=2)
     @override_settings(MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS=2)
     def test_delete_user_activation_admin(self):
     def test_delete_user_activation_admin(self):
         """deletes user that wasn't activated by admin within required time"""
         """deletes user that wasn't activated by admin within required time"""
         self.user.joined_on = timezone.now() - timedelta(days=2)
         self.user.joined_on = timezone.now() - timedelta(days=2)
-        self.user.requires_activation = UserModel.ACTIVATION_ADMIN
+        self.user.requires_activation = User.ACTIVATION_ADMIN
         self.user.save()
         self.user.save()
 
 
         out = StringIO()
         out = StringIO()
@@ -45,14 +45,14 @@ class DeleteInactiveUsersTests(TestCase):
 
 
         self.assertEqual(command_output, "Deleted users: 1")
         self.assertEqual(command_output, "Deleted users: 1")
 
 
-        with self.assertRaises(UserModel.DoesNotExist):
-            UserModel.objects.get(pk=self.user.pk)
+        with self.assertRaises(User.DoesNotExist):
+            User.objects.get(pk=self.user.pk)
 
 
     @override_settings(MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS=2)
     @override_settings(MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS=2)
     def test_skip_new_user_activation_user(self):
     def test_skip_new_user_activation_user(self):
         """skips inactive user that is too new"""
         """skips inactive user that is too new"""
         self.user.joined_on = timezone.now() - timedelta(days=1)
         self.user.joined_on = timezone.now() - timedelta(days=1)
-        self.user.requires_activation = UserModel.ACTIVATION_USER
+        self.user.requires_activation = User.ACTIVATION_USER
         self.user.save()
         self.user.save()
 
 
         out = StringIO()
         out = StringIO()
@@ -61,13 +61,13 @@ class DeleteInactiveUsersTests(TestCase):
 
 
         self.assertEqual(command_output, "Deleted users: 0")
         self.assertEqual(command_output, "Deleted users: 0")
 
 
-        UserModel.objects.get(pk=self.user.pk)
+        User.objects.get(pk=self.user.pk)
 
 
     @override_settings(MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS=2)
     @override_settings(MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS=2)
     def test_skip_new_user_activation_admin(self):
     def test_skip_new_user_activation_admin(self):
         """skips admin-activated user that is too new"""
         """skips admin-activated user that is too new"""
         self.user.joined_on = timezone.now() - timedelta(days=1)
         self.user.joined_on = timezone.now() - timedelta(days=1)
-        self.user.requires_activation = UserModel.ACTIVATION_ADMIN
+        self.user.requires_activation = User.ACTIVATION_ADMIN
         self.user.save()
         self.user.save()
 
 
         out = StringIO()
         out = StringIO()
@@ -76,7 +76,7 @@ class DeleteInactiveUsersTests(TestCase):
 
 
         self.assertEqual(command_output, "Deleted users: 0")
         self.assertEqual(command_output, "Deleted users: 0")
 
 
-        UserModel.objects.get(pk=self.user.pk)
+        User.objects.get(pk=self.user.pk)
 
 
     @override_settings(MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS=2)
     @override_settings(MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS=2)
     def test_skip_active_user(self):
     def test_skip_active_user(self):
@@ -90,13 +90,13 @@ class DeleteInactiveUsersTests(TestCase):
 
 
         self.assertEqual(command_output, "Deleted users: 0")
         self.assertEqual(command_output, "Deleted users: 0")
 
 
-        UserModel.objects.get(pk=self.user.pk)
+        User.objects.get(pk=self.user.pk)
 
 
     @override_settings(MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS=0)
     @override_settings(MISAGO_DELETE_NEW_INACTIVE_USERS_OLDER_THAN_DAYS=0)
     def test_delete_inactive_is_disabled(self):
     def test_delete_inactive_is_disabled(self):
         """skips active user"""
         """skips active user"""
         self.user.joined_on = timezone.now() - timedelta(days=1)
         self.user.joined_on = timezone.now() - timedelta(days=1)
-        self.user.requires_activation = UserModel.ACTIVATION_ADMIN
+        self.user.requires_activation = User.ACTIVATION_ADMIN
         self.user.save()
         self.user.save()
 
 
         out = StringIO()
         out = StringIO()
@@ -108,4 +108,4 @@ class DeleteInactiveUsersTests(TestCase):
             "Automatic deletion of inactive users is currently disabled.",
             "Automatic deletion of inactive users is currently disabled.",
         )
         )
 
 
-        UserModel.objects.get(pk=self.user.pk)
+        User.objects.get(pk=self.user.pk)

+ 9 - 9
misago/users/tests/test_deletemarkedusers.py

@@ -7,12 +7,12 @@ from django.test import TestCase, override_settings
 from misago.users.management.commands import deletemarkedusers
 from misago.users.management.commands import deletemarkedusers
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class DeleteMarkedUsersTests(TestCase):
 class DeleteMarkedUsersTests(TestCase):
     def setUp(self):
     def setUp(self):
-        self.user = UserModel.objects.create_user("Bob", "bob@bob.com", "pass123")
+        self.user = User.objects.create_user("Bob", "bob@bob.com", "pass123")
         self.user.mark_for_delete()
         self.user.mark_for_delete()
 
 
     def test_delete_marked_user(self):
     def test_delete_marked_user(self):
@@ -23,8 +23,8 @@ class DeleteMarkedUsersTests(TestCase):
 
 
         self.assertEqual(command_output, "Deleted users: 1")
         self.assertEqual(command_output, "Deleted users: 1")
 
 
-        with self.assertRaises(UserModel.DoesNotExist):
-            UserModel.objects.get(pk=self.user.pk)
+        with self.assertRaises(User.DoesNotExist):
+            User.objects.get(pk=self.user.pk)
 
 
     @override_settings(MISAGO_ENABLE_DELETE_OWN_ACCOUNT=False)
     @override_settings(MISAGO_ENABLE_DELETE_OWN_ACCOUNT=False)
     def test_delete_disabled(self):
     def test_delete_disabled(self):
@@ -35,8 +35,8 @@ class DeleteMarkedUsersTests(TestCase):
 
 
         self.assertEqual(command_output, "Deleted users: 1")
         self.assertEqual(command_output, "Deleted users: 1")
 
 
-        with self.assertRaises(UserModel.DoesNotExist):
-            UserModel.objects.get(pk=self.user.pk)
+        with self.assertRaises(User.DoesNotExist):
+            User.objects.get(pk=self.user.pk)
 
 
     def test_delete_not_marked(self):
     def test_delete_not_marked(self):
         """user has to be marked to be deletable"""
         """user has to be marked to be deletable"""
@@ -49,7 +49,7 @@ class DeleteMarkedUsersTests(TestCase):
 
 
         self.assertEqual(command_output, "Deleted users: 0")
         self.assertEqual(command_output, "Deleted users: 0")
 
 
-        UserModel.objects.get(pk=self.user.pk)
+        User.objects.get(pk=self.user.pk)
 
 
     def test_delete_is_staff(self):
     def test_delete_is_staff(self):
         """staff users are extempt from deletion"""
         """staff users are extempt from deletion"""
@@ -62,7 +62,7 @@ class DeleteMarkedUsersTests(TestCase):
 
 
         self.assertEqual(command_output, "Deleted users: 0")
         self.assertEqual(command_output, "Deleted users: 0")
 
 
-        UserModel.objects.get(pk=self.user.pk)
+        User.objects.get(pk=self.user.pk)
 
 
     def test_delete_superuser(self):
     def test_delete_superuser(self):
         """superusers are extempt from deletion"""
         """superusers are extempt from deletion"""
@@ -75,4 +75,4 @@ class DeleteMarkedUsersTests(TestCase):
 
 
         self.assertEqual(command_output, "Deleted users: 0")
         self.assertEqual(command_output, "Deleted users: 0")
 
 
-        UserModel.objects.get(pk=self.user.pk)
+        User.objects.get(pk=self.user.pk)

+ 3 - 3
misago/users/tests/test_deleteprofilefield.py

@@ -7,7 +7,7 @@ from django.test import TestCase
 from misago.users.management.commands import deleteprofilefield
 from misago.users.management.commands import deleteprofilefield
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class DeleteProfileFieldTests(TestCase):
 class DeleteProfileFieldTests(TestCase):
@@ -31,7 +31,7 @@ class DeleteProfileFieldTests(TestCase):
 
 
     def test_delete_fields(self):
     def test_delete_fields(self):
         """utility has no showstoppers when no fields are set"""
         """utility has no showstoppers when no fields are set"""
-        user = UserModel.objects.create_user("Bob", "bob@bob.com", "pass123")
+        user = User.objects.create_user("Bob", "bob@bob.com", "pass123")
         user.profile_fields = {"gender": "male", "bio": "Yup!"}
         user.profile_fields = {"gender": "male", "bio": "Yup!"}
         user.save()
         user.save()
 
 
@@ -43,5 +43,5 @@ class DeleteProfileFieldTests(TestCase):
             command_output, '"gender" profile field has been deleted from 1 users.'
             command_output, '"gender" profile field has been deleted from 1 users.'
         )
         )
 
 
-        user = UserModel.objects.get(pk=user.pk)
+        user = User.objects.get(pk=user.pk)
         self.assertEqual(user.profile_fields, {"bio": "Yup!"})
         self.assertEqual(user.profile_fields, {"bio": "Yup!"})

+ 6 - 6
misago/users/tests/test_forgottenpassword_views.py

@@ -7,7 +7,7 @@ from misago.users.testutils import UserTestCase
 from misago.users.tokens import make_password_change_token
 from misago.users.tokens import make_password_change_token
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class ForgottenPasswordViewsTests(UserTestCase):
 class ForgottenPasswordViewsTests(UserTestCase):
@@ -37,7 +37,7 @@ class ForgottenPasswordViewsTests(UserTestCase):
 
 
     def test_change_password_on_banned(self):
     def test_change_password_on_banned(self):
         """change banned user password errors"""
         """change banned user password errors"""
-        test_user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        test_user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         Ban.objects.create(
         Ban.objects.create(
             check_type=Ban.USERNAME, banned_value="bob", user_message="Nope!"
             check_type=Ban.USERNAME, banned_value="bob", user_message="Nope!"
@@ -55,7 +55,7 @@ class ForgottenPasswordViewsTests(UserTestCase):
 
 
     def test_change_password_on_other_user(self):
     def test_change_password_on_other_user(self):
         """change other user password errors"""
         """change other user password errors"""
-        test_user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        test_user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         password_token = make_password_change_token(test_user)
         password_token = make_password_change_token(test_user)
 
 
@@ -71,7 +71,7 @@ class ForgottenPasswordViewsTests(UserTestCase):
 
 
     def test_change_password_invalid_token(self):
     def test_change_password_invalid_token(self):
         """invalid form token errors"""
         """invalid form token errors"""
-        test_user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        test_user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         response = self.client.get(
         response = self.client.get(
             reverse(
             reverse(
@@ -83,7 +83,7 @@ class ForgottenPasswordViewsTests(UserTestCase):
 
 
     def test_change_password_form(self):
     def test_change_password_form(self):
         """change user password form displays for valid token"""
         """change user password form displays for valid token"""
-        test_user = UserModel.objects.create_user("Bob", "bob@test.com", "Pass.123")
+        test_user = User.objects.create_user("Bob", "bob@test.com", "Pass.123")
 
 
         password_token = make_password_change_token(test_user)
         password_token = make_password_change_token(test_user)
 
 
@@ -97,7 +97,7 @@ class ForgottenPasswordViewsTests(UserTestCase):
 
 
     def test_change_password_unusable_password_form(self):
     def test_change_password_unusable_password_form(self):
         """set user first password form displays for valid token"""
         """set user first password form displays for valid token"""
-        test_user = UserModel.objects.create_user("Bob", "bob@test.com")
+        test_user = User.objects.create_user("Bob", "bob@test.com")
 
 
         password_token = make_password_change_token(test_user)
         password_token = make_password_change_token(test_user)
 
 

+ 1 - 1
misago/users/tests/test_gender_profilefield.py

@@ -4,7 +4,7 @@ from django.urls import reverse
 from misago.admin.testutils import AdminTestCase
 from misago.admin.testutils import AdminTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class GenderProfileFieldTests(AdminTestCase):
 class GenderProfileFieldTests(AdminTestCase):

+ 3 - 3
misago/users/tests/test_invalidatebans.py

@@ -13,7 +13,7 @@ from misago.users.management.commands import invalidatebans
 from misago.users.models import Ban, BanCache
 from misago.users.models import Ban, BanCache
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class InvalidateBansTests(TestCase):
 class InvalidateBansTests(TestCase):
@@ -39,7 +39,7 @@ class InvalidateBansTests(TestCase):
 
 
     def test_bans_caches_updates(self):
     def test_bans_caches_updates(self):
         """ban caches are updated"""
         """ban caches are updated"""
-        user = UserModel.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
+        user = User.objects.create_user("Bob", "bob@boberson.com", "Pass.123")
 
 
         # ban user
         # ban user
         Ban.objects.create(banned_value="bob")
         Ban.objects.create(banned_value="bob")
@@ -72,5 +72,5 @@ class InvalidateBansTests(TestCase):
         self.assertEqual(Ban.objects.filter(is_checked=True).count(), 0)
         self.assertEqual(Ban.objects.filter(is_checked=True).count(), 0)
 
 
         # see if user is banned anymore
         # see if user is banned anymore
-        user = UserModel.objects.get(id=user.id)
+        user = User.objects.get(id=user.id)
         self.assertIsNone(bans.get_user_ban(user, get_cache_versions()))
         self.assertIsNone(bans.get_user_ban(user, get_cache_versions()))

+ 1 - 1
misago/users/tests/test_joinip_profilefield.py

@@ -5,7 +5,7 @@ from misago.acl.test import patch_user_acl
 from misago.admin.testutils import AdminTestCase
 from misago.admin.testutils import AdminTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class JoinIpProfileFieldTests(AdminTestCase):
 class JoinIpProfileFieldTests(AdminTestCase):

+ 5 - 5
misago/users/tests/test_listusedprofilefields.py

@@ -7,13 +7,13 @@ from django.test import TestCase
 from misago.users.management.commands import listusedprofilefields
 from misago.users.management.commands import listusedprofilefields
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class ListUsedProfileFieldsTests(TestCase):
 class ListUsedProfileFieldsTests(TestCase):
     def test_no_fields_set(self):
     def test_no_fields_set(self):
         """utility has no showstoppers when no fields are set"""
         """utility has no showstoppers when no fields are set"""
-        UserModel.objects.create_user("Bob", "bob@bob.com", "pass123")
+        User.objects.create_user("Bob", "bob@bob.com", "pass123")
 
 
         out = StringIO()
         out = StringIO()
         call_command(listusedprofilefields.Command(), stdout=out)
         call_command(listusedprofilefields.Command(), stdout=out)
@@ -23,15 +23,15 @@ class ListUsedProfileFieldsTests(TestCase):
 
 
     def test_fields_set(self):
     def test_fields_set(self):
         """utility lists number of users that have different fields set"""
         """utility lists number of users that have different fields set"""
-        user = UserModel.objects.create_user("Bob", "bob@bob.com", "pass123")
+        user = User.objects.create_user("Bob", "bob@bob.com", "pass123")
         user.profile_fields = {"gender": "male", "bio": "Yup!"}
         user.profile_fields = {"gender": "male", "bio": "Yup!"}
         user.save()
         user.save()
 
 
-        user = UserModel.objects.create_user("Bob2", "bob2@bob.com", "pass123")
+        user = User.objects.create_user("Bob2", "bob2@bob.com", "pass123")
         user.profile_fields = {"gender": "male"}
         user.profile_fields = {"gender": "male"}
         user.save()
         user.save()
 
 
-        user = UserModel.objects.create_user("Bob3", "bob3@bob.com", "pass123")
+        user = User.objects.create_user("Bob3", "bob3@bob.com", "pass123")
         user.profile_fields = {"location": ""}
         user.profile_fields = {"location": ""}
         user.save()
         user.save()
 
 

+ 2 - 2
misago/users/tests/test_misagoavatars_tags.py

@@ -3,13 +3,13 @@ from django.template import Context, Template
 from django.test import TestCase
 from django.test import TestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class TemplateTagsTests(TestCase):
 class TemplateTagsTests(TestCase):
     def test_user_avatar_filter(self):
     def test_user_avatar_filter(self):
         """avatar filter returns url to avatar image"""
         """avatar filter returns url to avatar image"""
-        user = UserModel.objects.create_user("Bob", "bob@test.com", "pass123")
+        user = User.objects.create_user("Bob", "bob@test.com", "pass123")
 
 
         user.avatars = [
         user.avatars = [
             {"size": 400, "url": "/avatar/400.png"},
             {"size": 400, "url": "/avatar/400.png"},

+ 2 - 2
misago/users/tests/test_populateonlinetracker.py

@@ -8,13 +8,13 @@ from misago.users.management.commands import populateonlinetracker
 from misago.users.models import Online
 from misago.users.models import Online
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class PopulateOnlineTrackerTests(TestCase):
 class PopulateOnlineTrackerTests(TestCase):
     def test_populate_user_online(self):
     def test_populate_user_online(self):
         """user account without online tracker gets one"""
         """user account without online tracker gets one"""
-        test_user = UserModel.objects.create_user("Bob", "bob@bob.com", "pass123")
+        test_user = User.objects.create_user("Bob", "bob@bob.com", "pass123")
 
 
         Online.objects.filter(user=test_user).delete()
         Online.objects.filter(user=test_user).delete()
         self.assertEqual(Online.objects.filter(user=test_user).count(), 0)
         self.assertEqual(Online.objects.filter(user=test_user).count(), 0)

+ 3 - 3
misago/users/tests/test_profile_views.py

@@ -8,7 +8,7 @@ from misago.users.models import Ban
 from misago.users.testutils import AuthenticatedUserTestCase, create_test_user
 from misago.users.testutils import AuthenticatedUserTestCase, create_test_user
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class UserProfileViewsTests(AuthenticatedUserTestCase):
 class UserProfileViewsTests(AuthenticatedUserTestCase):
@@ -105,7 +105,7 @@ class UserProfileViewsTests(AuthenticatedUserTestCase):
         followers = []
         followers = []
         for i in range(10):
         for i in range(10):
             user_data = ("Follower%s" % i, "foll%s@test.com" % i, "Pass.123")
             user_data = ("Follower%s" % i, "foll%s@test.com" % i, "Pass.123")
-            followers.append(UserModel.objects.create_user(*user_data))
+            followers.append(User.objects.create_user(*user_data))
             self.user.followed_by.add(followers[-1])
             self.user.followed_by.add(followers[-1])
 
 
         response = self.client.get(
         response = self.client.get(
@@ -127,7 +127,7 @@ class UserProfileViewsTests(AuthenticatedUserTestCase):
         followers = []
         followers = []
         for i in range(10):
         for i in range(10):
             user_data = ("Follower%s" % i, "foll%s@test.com" % i, "Pass.123")
             user_data = ("Follower%s" % i, "foll%s@test.com" % i, "Pass.123")
-            followers.append(UserModel.objects.create_user(*user_data))
+            followers.append(User.objects.create_user(*user_data))
             followers[-1].followed_by.add(self.user)
             followers[-1].followed_by.add(self.user)
 
 
         response = self.client.get(
         response = self.client.get(

+ 1 - 1
misago/users/tests/test_profilefields.py

@@ -4,7 +4,7 @@ from django.test import TestCase
 from misago.users.profilefields import ProfileFields
 from misago.users.profilefields import ProfileFields
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class ProfileFieldsLoadTests(TestCase):
 class ProfileFieldsLoadTests(TestCase):

+ 7 - 13
misago/users/tests/test_removeoldips.py

@@ -9,7 +9,7 @@ from django.utils import timezone
 from misago.users.management.commands import removeoldips
 from misago.users.management.commands import removeoldips
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 USER_IP = "31.41.51.65"
 USER_IP = "31.41.51.65"
 
 
@@ -17,37 +17,31 @@ USER_IP = "31.41.51.65"
 class RemoveOldIpsTests(TestCase):
 class RemoveOldIpsTests(TestCase):
     def test_removeoldips_recent_user(self):
     def test_removeoldips_recent_user(self):
         """command is not removing user's IP if its recent"""
         """command is not removing user's IP if its recent"""
-        user = UserModel.objects.create_user(
-            "Bob", "bob@bob.com", joined_from_ip=USER_IP
-        )
+        user = User.objects.create_user("Bob", "bob@bob.com", joined_from_ip=USER_IP)
 
 
         out = StringIO()
         out = StringIO()
         call_command(removeoldips.Command(), stdout=out)
         call_command(removeoldips.Command(), stdout=out)
 
 
-        user_joined_from_ip = UserModel.objects.get(pk=user.pk).joined_from_ip
+        user_joined_from_ip = User.objects.get(pk=user.pk).joined_from_ip
         self.assertEqual(user_joined_from_ip, USER_IP)
         self.assertEqual(user_joined_from_ip, USER_IP)
 
 
     def test_removeoldips_old_user(self):
     def test_removeoldips_old_user(self):
         """command removes user's IP if its old"""
         """command removes user's IP if its old"""
         joined_on_past = timezone.now() - timedelta(days=50)
         joined_on_past = timezone.now() - timedelta(days=50)
-        user = UserModel.objects.create_user(
-            "Bob1", "bob1@bob.com", joined_from_ip=USER_IP
-        )
+        user = User.objects.create_user("Bob1", "bob1@bob.com", joined_from_ip=USER_IP)
         user.joined_on = joined_on_past
         user.joined_on = joined_on_past
         user.save()
         user.save()
 
 
         out = StringIO()
         out = StringIO()
         call_command(removeoldips.Command(), stdout=out)
         call_command(removeoldips.Command(), stdout=out)
 
 
-        user_joined_from_ip = UserModel.objects.get(pk=user.pk).joined_from_ip
+        user_joined_from_ip = User.objects.get(pk=user.pk).joined_from_ip
         self.assertIsNone(user_joined_from_ip)
         self.assertIsNone(user_joined_from_ip)
 
 
     @override_settings(MISAGO_IP_STORE_TIME=None)
     @override_settings(MISAGO_IP_STORE_TIME=None)
     def test_not_removing_user_ip(self):
     def test_not_removing_user_ip(self):
         """command is not removing user's IP if removing is disabled"""
         """command is not removing user's IP if removing is disabled"""
-        user = UserModel.objects.create_user(
-            "Bob1", "bob1@bob.com", joined_from_ip=USER_IP
-        )
+        user = User.objects.create_user("Bob1", "bob1@bob.com", joined_from_ip=USER_IP)
 
 
         out = StringIO()
         out = StringIO()
         call_command(removeoldips.Command(), stdout=out)
         call_command(removeoldips.Command(), stdout=out)
@@ -55,5 +49,5 @@ class RemoveOldIpsTests(TestCase):
 
 
         self.assertEqual(command_output, "Old IP removal is disabled.")
         self.assertEqual(command_output, "Old IP removal is disabled.")
 
 
-        user_joined_from_ip = UserModel.objects.get(pk=user.pk).joined_from_ip
+        user_joined_from_ip = User.objects.get(pk=user.pk).joined_from_ip
         self.assertEqual(user_joined_from_ip, USER_IP)
         self.assertEqual(user_joined_from_ip, USER_IP)

+ 2 - 2
misago/users/tests/test_search.py

@@ -5,7 +5,7 @@ from misago.acl.test import patch_user_acl
 from misago.users.testutils import AuthenticatedUserTestCase
 from misago.users.testutils import AuthenticatedUserTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class SearchApiTests(AuthenticatedUserTestCase):
 class SearchApiTests(AuthenticatedUserTestCase):
@@ -101,7 +101,7 @@ class SearchApiTests(AuthenticatedUserTestCase):
 
 
     def test_search_disabled(self):
     def test_search_disabled(self):
         """api respects disabled users visibility"""
         """api respects disabled users visibility"""
-        disabled_user = UserModel.objects.create_user(
+        disabled_user = User.objects.create_user(
             "DisabledUser", "visible@te.com", "Pass.123", is_active=False
             "DisabledUser", "visible@te.com", "Pass.123", is_active=False
         )
         )
 
 

+ 20 - 24
misago/users/tests/test_social_pipeline.py

@@ -27,7 +27,7 @@ from misago.users.social.pipeline import (
 from misago.users.testutils import UserTestCase
 from misago.users.testutils import UserTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 def create_request(user_ip="0.0.0.0", data=None):
 def create_request(user_ip="0.0.0.0", data=None):
@@ -78,20 +78,16 @@ class PipelineTestCase(UserTestCase):
             self.assertEqual(new_user.username, form_data["username"])
             self.assertEqual(new_user.username, form_data["username"])
 
 
         if activation == "none":
         if activation == "none":
-            self.assertEqual(new_user.requires_activation, UserModel.ACTIVATION_NONE)
+            self.assertEqual(new_user.requires_activation, User.ACTIVATION_NONE)
 
 
         if activation == "user":
         if activation == "user":
             if email_verified:
             if email_verified:
-                self.assertEqual(
-                    new_user.requires_activation, UserModel.ACTIVATION_NONE
-                )
+                self.assertEqual(new_user.requires_activation, User.ACTIVATION_NONE)
             else:
             else:
-                self.assertEqual(
-                    new_user.requires_activation, UserModel.ACTIVATION_USER
-                )
+                self.assertEqual(new_user.requires_activation, User.ACTIVATION_USER)
 
 
         if activation == "admin":
         if activation == "admin":
-            self.assertEqual(new_user.requires_activation, UserModel.ACTIVATION_ADMIN)
+            self.assertEqual(new_user.requires_activation, User.ACTIVATION_ADMIN)
 
 
         self.assertEqual(new_user.audittrail_set.count(), 1)
         self.assertEqual(new_user.audittrail_set.count(), 1)
 
 
@@ -136,7 +132,7 @@ class AssociateByEmailTests(PipelineTestCase):
 
 
     def test_raise_if_user_needs_admin_activation(self):
     def test_raise_if_user_needs_admin_activation(self):
         """pipeline raises if user needs admin activation"""
         """pipeline raises if user needs admin activation"""
-        self.user.requires_activation = UserModel.ACTIVATION_ADMIN
+        self.user.requires_activation = User.ACTIVATION_ADMIN
         self.user.save()
         self.user.save()
 
 
         try:
         try:
@@ -158,7 +154,7 @@ class AssociateByEmailTests(PipelineTestCase):
 
 
     def test_return_user_email_inactive(self):
     def test_return_user_email_inactive(self):
         """pipeline returns user even if they didn't activate their account manually"""
         """pipeline returns user even if they didn't activate their account manually"""
-        self.user.requires_activation = UserModel.ACTIVATION_USER
+        self.user.requires_activation = User.ACTIVATION_USER
         self.user.save()
         self.user.save()
 
 
         result = associate_by_email(None, {"email": self.user.email}, GithubOAuth2)
         result = associate_by_email(None, {"email": self.user.email}, GithubOAuth2)
@@ -204,7 +200,7 @@ class CreateUser(PipelineTestCase):
             GithubOAuth2(),
             GithubOAuth2(),
             clean_username="NewUser",
             clean_username="NewUser",
         )
         )
-        new_user = UserModel.objects.get(email="new@example.com")
+        new_user = User.objects.get(email="new@example.com")
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(new_user.username, "NewUser")
         self.assertEqual(new_user.username, "NewUser")
         self.assertNewUserIsCorrect(new_user, email_verified=True, activation="none")
         self.assertNewUserIsCorrect(new_user, email_verified=True, activation="none")
@@ -218,7 +214,7 @@ class CreateUser(PipelineTestCase):
             GithubOAuth2(),
             GithubOAuth2(),
             clean_username="NewUser",
             clean_username="NewUser",
         )
         )
-        new_user = UserModel.objects.get(email="new@example.com")
+        new_user = User.objects.get(email="new@example.com")
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(new_user.username, "NewUser")
         self.assertEqual(new_user.username, "NewUser")
         self.assertNewUserIsCorrect(new_user, email_verified=True, activation="user")
         self.assertNewUserIsCorrect(new_user, email_verified=True, activation="user")
@@ -232,7 +228,7 @@ class CreateUser(PipelineTestCase):
             GithubOAuth2(),
             GithubOAuth2(),
             clean_username="NewUser",
             clean_username="NewUser",
         )
         )
-        new_user = UserModel.objects.get(email="new@example.com")
+        new_user = User.objects.get(email="new@example.com")
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(new_user.username, "NewUser")
         self.assertEqual(new_user.username, "NewUser")
         self.assertNewUserIsCorrect(new_user, email_verified=True, activation="admin")
         self.assertNewUserIsCorrect(new_user, email_verified=True, activation="admin")
@@ -329,7 +325,7 @@ class CreateUserWithFormTests(PipelineTestCase):
             pipeline_index=1,
             pipeline_index=1,
         )
         )
 
 
-        new_user = UserModel.objects.get(email="social@auth.com")
+        new_user = User.objects.get(email="social@auth.com")
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(result, {"user": new_user, "is_new": True})
 
 
         self.assertNewUserIsCorrect(
         self.assertNewUserIsCorrect(
@@ -352,7 +348,7 @@ class CreateUserWithFormTests(PipelineTestCase):
             pipeline_index=1,
             pipeline_index=1,
         )
         )
 
 
-        new_user = UserModel.objects.get(email="social@auth.com")
+        new_user = User.objects.get(email="social@auth.com")
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(result, {"user": new_user, "is_new": True})
 
 
         self.assertNewUserIsCorrect(
         self.assertNewUserIsCorrect(
@@ -375,7 +371,7 @@ class CreateUserWithFormTests(PipelineTestCase):
             pipeline_index=1,
             pipeline_index=1,
         )
         )
 
 
-        new_user = UserModel.objects.get(email="social@auth.com")
+        new_user = User.objects.get(email="social@auth.com")
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(result, {"user": new_user, "is_new": True})
 
 
         self.assertNewUserIsCorrect(
         self.assertNewUserIsCorrect(
@@ -398,7 +394,7 @@ class CreateUserWithFormTests(PipelineTestCase):
             pipeline_index=1,
             pipeline_index=1,
         )
         )
 
 
-        new_user = UserModel.objects.get(email="social@auth.com")
+        new_user = User.objects.get(email="social@auth.com")
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(result, {"user": new_user, "is_new": True})
 
 
         self.assertNewUserIsCorrect(
         self.assertNewUserIsCorrect(
@@ -421,7 +417,7 @@ class CreateUserWithFormTests(PipelineTestCase):
             pipeline_index=1,
             pipeline_index=1,
         )
         )
 
 
-        new_user = UserModel.objects.get(email="social@auth.com")
+        new_user = User.objects.get(email="social@auth.com")
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(result, {"user": new_user, "is_new": True})
 
 
         self.assertNewUserIsCorrect(
         self.assertNewUserIsCorrect(
@@ -444,7 +440,7 @@ class CreateUserWithFormTests(PipelineTestCase):
             pipeline_index=1,
             pipeline_index=1,
         )
         )
 
 
-        new_user = UserModel.objects.get(email="social@auth.com")
+        new_user = User.objects.get(email="social@auth.com")
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(result, {"user": new_user, "is_new": True})
 
 
         self.assertNewUserIsCorrect(
         self.assertNewUserIsCorrect(
@@ -516,7 +512,7 @@ class CreateUserWithFormTests(PipelineTestCase):
             pipeline_index=1,
             pipeline_index=1,
         )
         )
 
 
-        new_user = UserModel.objects.get(email="social@auth.com")
+        new_user = User.objects.get(email="social@auth.com")
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(result, {"user": new_user, "is_new": True})
 
 
         self.assertEqual(new_user.agreements, [agreement.id])
         self.assertEqual(new_user.agreements, [agreement.id])
@@ -545,7 +541,7 @@ class CreateUserWithFormTests(PipelineTestCase):
             pipeline_index=1,
             pipeline_index=1,
         )
         )
 
 
-        new_user = UserModel.objects.get(email="social@auth.com")
+        new_user = User.objects.get(email="social@auth.com")
         self.assertEqual(result, {"user": new_user, "is_new": True})
         self.assertEqual(result, {"user": new_user, "is_new": True})
 
 
         self.assertEqual(new_user.agreements, [])
         self.assertEqual(new_user.agreements, [])
@@ -626,7 +622,7 @@ class RequireActivationTests(PipelineTestCase):
     def setUp(self):
     def setUp(self):
         super().setUp()
         super().setUp()
 
 
-        self.user.requires_activation = UserModel.ACTIVATION_ADMIN
+        self.user.requires_activation = User.ACTIVATION_ADMIN
         self.user.save()
         self.user.save()
 
 
     def test_skip_if_user_not_set(self):
     def test_skip_if_user_not_set(self):
@@ -653,7 +649,7 @@ class RequireActivationTests(PipelineTestCase):
 
 
     def test_skip_if_user_is_active(self):
     def test_skip_if_user_is_active(self):
         """pipeline step is skipped if user is active"""
         """pipeline step is skipped if user is active"""
-        self.user.requires_activation = UserModel.ACTIVATION_NONE
+        self.user.requires_activation = User.ACTIVATION_NONE
         self.user.save()
         self.user.save()
 
 
         self.assertFalse(self.user.requires_activation)
         self.assertFalse(self.user.requires_activation)

+ 3 - 3
misago/users/tests/test_tokens.py

@@ -4,14 +4,14 @@ from django.test import TestCase
 from misago.users import tokens
 from misago.users import tokens
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class TokensTests(TestCase):
 class TokensTests(TestCase):
     def test_tokens(self):
     def test_tokens(self):
         """misago.users.tokens implementation works"""
         """misago.users.tokens implementation works"""
-        user_a = UserModel.objects.create_user("Bob", "bob@test.com", "pass123")
-        user_b = UserModel.objects.create_user("Weebl", "weebl@test.com", "pass123")
+        user_a = User.objects.create_user("Bob", "bob@test.com", "pass123")
+        user_b = User.objects.create_user("Weebl", "weebl@test.com", "pass123")
 
 
         token_a = tokens.make(user_a, "test")
         token_a = tokens.make(user_a, "test")
         token_b = tokens.make(user_b, "test")
         token_b = tokens.make(user_b, "test")

+ 1 - 1
misago/users/tests/test_twitter_profilefield.py

@@ -4,7 +4,7 @@ from django.urls import reverse
 from misago.admin.testutils import AdminTestCase
 from misago.admin.testutils import AdminTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class TwitterProfileFieldTests(AdminTestCase):
 class TwitterProfileFieldTests(AdminTestCase):

+ 2 - 2
misago/users/tests/test_user_changeemail_api.py

@@ -5,7 +5,7 @@ from django.urls import reverse
 from misago.users.testutils import AuthenticatedUserTestCase
 from misago.users.testutils import AuthenticatedUserTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class UserChangeEmailTests(AuthenticatedUserTestCase):
 class UserChangeEmailTests(AuthenticatedUserTestCase):
@@ -65,7 +65,7 @@ class UserChangeEmailTests(AuthenticatedUserTestCase):
 
 
     def test_email_taken(self):
     def test_email_taken(self):
         """api validates email usage"""
         """api validates email usage"""
-        UserModel.objects.create_user("BobBoberson", "new@email.com", "Pass.123")
+        User.objects.create_user("BobBoberson", "new@email.com", "Pass.123")
 
 
         response = self.client.post(
         response = self.client.post(
             self.link,
             self.link,

+ 2 - 4
misago/users/tests/test_user_details_api.py

@@ -5,7 +5,7 @@ from misago.acl.test import patch_user_acl
 from misago.users.testutils import AuthenticatedUserTestCase
 from misago.users.testutils import AuthenticatedUserTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class UserDetailsApiTests(AuthenticatedUserTestCase):
 class UserDetailsApiTests(AuthenticatedUserTestCase):
@@ -35,9 +35,7 @@ class UserDetailsApiTests(AuthenticatedUserTestCase):
 
 
     def test_other_user(self):
     def test_other_user(self):
         """api handles scenario when its other user looking at profile"""
         """api handles scenario when its other user looking at profile"""
-        test_user = UserModel.objects.create_user(
-            "BobBoberson", "bob@test.com", "bob123456"
-        )
+        test_user = User.objects.create_user("BobBoberson", "bob@test.com", "bob123456")
 
 
         api_link = reverse("misago:api:user-details", kwargs={"pk": test_user.pk})
         api_link = reverse("misago:api:user-details", kwargs={"pk": test_user.pk})
 
 

+ 3 - 5
misago/users/tests/test_user_editdetails_api.py

@@ -5,7 +5,7 @@ from misago.acl.test import patch_user_acl
 from misago.users.testutils import AuthenticatedUserTestCase
 from misago.users.testutils import AuthenticatedUserTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class UserEditDetailsApiTests(AuthenticatedUserTestCase):
 class UserEditDetailsApiTests(AuthenticatedUserTestCase):
@@ -17,7 +17,7 @@ class UserEditDetailsApiTests(AuthenticatedUserTestCase):
         )
         )
 
 
     def get_profile_fields(self):
     def get_profile_fields(self):
-        return UserModel.objects.get(pk=self.user.pk).profile_fields
+        return User.objects.get(pk=self.user.pk).profile_fields
 
 
     def test_api_has_no_showstoppers(self):
     def test_api_has_no_showstoppers(self):
         """api outputs response for freshly created user"""
         """api outputs response for freshly created user"""
@@ -31,9 +31,7 @@ class UserEditDetailsApiTests(AuthenticatedUserTestCase):
 
 
     def test_other_user(self):
     def test_other_user(self):
         """api handles scenario when its other user looking at profile"""
         """api handles scenario when its other user looking at profile"""
-        test_user = UserModel.objects.create_user(
-            "BobBoberson", "bob@test.com", "bob123456"
-        )
+        test_user = User.objects.create_user("BobBoberson", "bob@test.com", "bob123456")
 
 
         api_link = reverse("misago:api:user-edit-details", kwargs={"pk": test_user.pk})
         api_link = reverse("misago:api:user-edit-details", kwargs={"pk": test_user.pk})
 
 

+ 1 - 1
misago/users/tests/test_user_model.py

@@ -9,7 +9,7 @@ from misago.users.avatars import dynamic
 from misago.users.models import Avatar, User
 from misago.users.models import Avatar, User
 
 
 
 
-class UserModelTests(TestCase):
+class UserTests(TestCase):
     def test_anonymize_data(self):
     def test_anonymize_data(self):
         """anonymize_data sets username and slug to one defined in settings"""
         """anonymize_data sets username and slug to one defined in settings"""
         user = User.objects.create_user("Bob", "bob@example.com", "Pass.123")
         user = User.objects.create_user("Bob", "bob@example.com", "Pass.123")

+ 3 - 3
misago/users/tests/test_user_username_api.py

@@ -7,7 +7,7 @@ from misago.conf.test import override_dynamic_settings
 from misago.users.testutils import AuthenticatedUserTestCase
 from misago.users.testutils import AuthenticatedUserTestCase
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class UserUsernameTests(AuthenticatedUserTestCase):
 class UserUsernameTests(AuthenticatedUserTestCase):
@@ -100,7 +100,7 @@ class UserUsernameModerationTests(AuthenticatedUserTestCase):
     def setUp(self):
     def setUp(self):
         super().setUp()
         super().setUp()
 
 
-        self.other_user = UserModel.objects.create_user(
+        self.other_user = User.objects.create_user(
             "OtherUser", "other@user.com", "pass123"
             "OtherUser", "other@user.com", "pass123"
         )
         )
 
 
@@ -159,7 +159,7 @@ class UserUsernameModerationTests(AuthenticatedUserTestCase):
 
 
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.status_code, 200)
 
 
-        other_user = UserModel.objects.get(pk=self.other_user.pk)
+        other_user = User.objects.get(pk=self.other_user.pk)
 
 
         self.assertEqual("BobBoberson", other_user.username)
         self.assertEqual("BobBoberson", other_user.username)
         self.assertEqual("bobboberson", other_user.slug)
         self.assertEqual("bobboberson", other_user.slug)

+ 3 - 3
misago/users/tests/test_validators.py

@@ -18,12 +18,12 @@ from misago.users.validators import (
 )
 )
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class ValidateEmailAvailableTests(TestCase):
 class ValidateEmailAvailableTests(TestCase):
     def setUp(self):
     def setUp(self):
-        self.test_user = UserModel.objects.create_user(
+        self.test_user = User.objects.create_user(
             "EricTheFish", "eric@test.com", "pass123"
             "EricTheFish", "eric@test.com", "pass123"
         )
         )
 
 
@@ -71,7 +71,7 @@ class ValidateUsernameTests(TestCase):
 
 
 class ValidateUsernameAvailableTests(TestCase):
 class ValidateUsernameAvailableTests(TestCase):
     def setUp(self):
     def setUp(self):
-        self.test_user = UserModel.objects.create_user("EricTheFish", "eric@test.com")
+        self.test_user = User.objects.create_user("EricTheFish", "eric@test.com")
 
 
     def test_valid_name(self):
     def test_valid_name(self):
         """validate_username_available allows available names"""
         """validate_username_available allows available names"""

+ 5 - 5
misago/users/validators.py

@@ -18,7 +18,7 @@ from .bans import get_email_ban, get_username_ban
 
 
 USERNAME_RE = re.compile(r"^[0-9a-z]+$", re.IGNORECASE)
 USERNAME_RE = re.compile(r"^[0-9a-z]+$", re.IGNORECASE)
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 # E-mail validators
 # E-mail validators
@@ -33,10 +33,10 @@ def validate_email(value, exclude=None):
 
 
 def validate_email_available(value, exclude=None):
 def validate_email_available(value, exclude=None):
     try:
     try:
-        user = UserModel.objects.get_by_email(value)
+        user = User.objects.get_by_email(value)
         if not exclude or user.pk != exclude.pk:
         if not exclude or user.pk != exclude.pk:
             raise ValidationError(_("This e-mail address is not available."))
             raise ValidationError(_("This e-mail address is not available."))
-    except UserModel.DoesNotExist:
+    except User.DoesNotExist:
         pass
         pass
 
 
 
 
@@ -61,10 +61,10 @@ def validate_username(settings, value, exclude=None):
 
 
 def validate_username_available(value, exclude=None):
 def validate_username_available(value, exclude=None):
     try:
     try:
-        user = UserModel.objects.get_by_username(value)
+        user = User.objects.get_by_username(value)
         if not exclude or user.pk != exclude.pk:
         if not exclude or user.pk != exclude.pk:
             raise ValidationError(_("This username is not available."))
             raise ValidationError(_("This username is not available."))
-    except UserModel.DoesNotExist:
+    except User.DoesNotExist:
         pass
         pass
 
 
 
 

+ 3 - 3
misago/users/views/activation.py

@@ -9,7 +9,7 @@ from misago.users.decorators import deny_authenticated, deny_banned_ips
 from misago.users.tokens import is_activation_token_valid
 from misago.users.tokens import is_activation_token_valid
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 def activation_view(f):
 def activation_view(f):
@@ -39,7 +39,7 @@ class ActivationError(Exception):
 
 
 @activation_view
 @activation_view
 def activate_by_token(request, pk, token):
 def activate_by_token(request, pk, token):
-    inactive_user = get_object_or_404(UserModel, pk=pk, is_active=True)
+    inactive_user = get_object_or_404(User, pk=pk, is_active=True)
 
 
     try:
     try:
         if not inactive_user.requires_activation:
         if not inactive_user.requires_activation:
@@ -63,7 +63,7 @@ def activate_by_token(request, pk, token):
             request, "misago/activation/error.html", {"message": e.args[0]}, status=400
             request, "misago/activation/error.html", {"message": e.args[0]}, status=400
         )
         )
 
 
-    inactive_user.requires_activation = UserModel.ACTIVATION_NONE
+    inactive_user.requires_activation = User.ACTIVATION_NONE
     inactive_user.save(update_fields=["requires_activation"])
     inactive_user.save(update_fields=["requires_activation"])
 
 
     message = _("%(user)s, your account has been activated!")
     message = _("%(user)s, your account has been activated!")

+ 3 - 3
misago/users/views/avatarserver.py

@@ -5,15 +5,15 @@ from django.shortcuts import redirect
 from misago.conf import settings
 from misago.conf import settings
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 def user_avatar(request, pk, size):
 def user_avatar(request, pk, size):
     size = int(size)
     size = int(size)
 
 
     try:
     try:
-        user = UserModel.objects.get(pk=pk)
-    except UserModel.DoesNotExist:
+        user = User.objects.get(pk=pk)
+    except User.DoesNotExist:
         return blank_avatar(request)
         return blank_avatar(request)
 
 
     found_avatar = user.avatars[0]
     found_avatar = user.avatars[0]

+ 2 - 4
misago/users/views/profile.py

@@ -17,7 +17,7 @@ from misago.users.serializers import (
 from misago.users.viewmodels import Followers, Follows, UserPosts, UserThreads
 from misago.users.viewmodels import Followers, Follows, UserPosts, UserThreads
 
 
 
 
-UserModel = get_user_model()
+User = get_user_model()
 
 
 
 
 class ProfileView(View):
 class ProfileView(View):
@@ -40,9 +40,7 @@ class ProfileView(View):
         return render(request, self.template_name, context_data)
         return render(request, self.template_name, context_data)
 
 
     def get_profile(self, request, pk, slug):
     def get_profile(self, request, pk, slug):
-        queryset = UserModel.objects.select_related(
-            "rank", "online_tracker", "ban_cache"
-        )
+        queryset = User.objects.select_related("rank", "online_tracker", "ban_cache")
 
 
         profile = get_object_or_404(queryset, pk=pk)
         profile = get_object_or_404(queryset, pk=pk)