mirror of
				https://gitlab.crans.org/bde/nk20-scripts
				synced 2025-10-30 22:59:52 +01:00 
			
		
		
		
	add command to enable active/staff
This commit is contained in:
		
							
								
								
									
										23
									
								
								management/commands/make_su.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								management/commands/make_su.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| #!/usr/bin/env python3 | ||||
|  | ||||
|  | ||||
| from django.core.management.base import BaseCommand | ||||
|  | ||||
| from django.contrib.auth.models import User | ||||
|  | ||||
|  | ||||
|  | ||||
| class Command(BaseCommand): | ||||
|     def add_arguments(self,parser): | ||||
|         parser.add_argument('username',nargs='+',type=str) | ||||
|         parser.add_argument('-S',"--SUPER",action='store_true',help='make superuser') | ||||
|          | ||||
|  | ||||
|     def handle(self,*args,**kwargs): | ||||
|         for uname in kwargs["username"]: | ||||
|             user = User.objects.get(username=uname) | ||||
|             user.is_active = True | ||||
|             if kwargs['SUPER']: | ||||
|                 user.is_staff = True | ||||
|             user.save() | ||||
|                  | ||||
		Reference in New Issue
	
	Block a user