| 
3 | 3 | from django.contrib.auth import logout  | 
4 | 4 | from django.contrib.auth.decorators import login_required  | 
5 | 5 | from django.contrib.auth.models import User  | 
 | 6 | +from django.contrib.auth import get_user_model  | 
6 | 7 | from django.core.files.storage import FileSystemStorage  | 
7 | 8 | from django.db.models import Q  | 
8 |  | -from django.http import HttpResponse, HttpResponseRedirect  | 
 | 9 | +from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound  | 
9 | 10 | from django.shortcuts import get_object_or_404, redirect, render  | 
 | 11 | +from django.conf import settings  | 
10 | 12 | from django.utils import timezone  | 
11 | 13 | from PIL import Image  | 
12 | 14 | 
 
  | 
@@ -34,6 +36,20 @@ def index(request):  | 
34 | 36 |     else:  | 
35 | 37 |         return render(request, "globals/index1.html", context)  | 
36 | 38 | 
 
  | 
 | 39 | +# Reset all passwords to 'user@123' in DEV environment  | 
 | 40 | +def reset_all_pass(request):  | 
 | 41 | +    if settings.ALLOW_PASS_RESET:  | 
 | 42 | +        UserMod = get_user_model()  | 
 | 43 | +        arr = UserMod.objects.all()  | 
 | 44 | +        for e in arr:  | 
 | 45 | +            print(e.username)  | 
 | 46 | +            u = User.objects.get(username=e.username)  | 
 | 47 | +            u.set_password('user@123')  | 
 | 48 | +            u.save()  | 
 | 49 | +        context = {"done": len(arr)}  | 
 | 50 | +        return HttpResponse(json.dumps(context), "application/json")  | 
 | 51 | +    else:  | 
 | 52 | +        return HttpResponseNotFound("Not allowed")  | 
37 | 53 | 
 
  | 
38 | 54 | 
 
  | 
39 | 55 | @login_required(login_url=LOGIN_URL)  | 
 | 
0 commit comments