Browse Source

New maintenance command and little cleanup in other one

Ralfp 12 years ago
parent
commit
4e39f2535d

+ 2 - 3
misago/users/management/commands/adduser.py

@@ -3,7 +3,7 @@ from django.core.management.base import BaseCommand, CommandError
 from django.utils import timezone
 from django.utils import timezone
 from optparse import make_option
 from optparse import make_option
 from misago.roles.models import Role
 from misago.roles.models import Role
-from misago.users.models import UserManager
+from misago.users.models import User
 
 
 class Command(BaseCommand):
 class Command(BaseCommand):
     args = 'username email password'
     args = 'username email password'
@@ -22,8 +22,7 @@ class Command(BaseCommand):
                 
                 
         # Set user
         # Set user
         try:
         try:
-            manager = UserManager()
-            new_user = manager.create_user(args[0], args[1], args[2])
+            new_user = User.objects.create_user(args[0], args[1], args[2])
         except ValidationError as e:
         except ValidationError as e:
             raise CommandError("New user cannot be created because of following errors:\n\n%s" % '\n'.join(e.messages))
             raise CommandError("New user cannot be created because of following errors:\n\n%s" % '\n'.join(e.messages))
                 
                 

+ 12 - 0
misago/users/management/commands/syncusermonitor.py

@@ -0,0 +1,12 @@
+from django.core.management.base import BaseCommand
+from django.utils import timezone
+from optparse import make_option
+from misago.monitor.monitor import Monitor
+from misago.users.models import User
+
+class Command(BaseCommand):
+    help = 'Updates forum monitor to contain to date user information'
+
+    def handle(self, *args, **options):
+        User.objects.resync_monitor(Monitor())
+        self.stdout.write('\n\nForum monitor has been updated to contain to date user information.\n')