| 75 | |
| 76 | class AdminInitView(View): |
| 77 | def get(self, request): # type: ignore[no-untyped-def] |
| 78 | if should_skip_create_initial_superuser(): |
| 79 | return JsonResponse( |
| 80 | { |
| 81 | "adminUserCreated": False, |
| 82 | "message": "FAILED TO INIT ADMIN USER. USER(S) ALREADY EXIST IN SYSTEM.", |
| 83 | }, |
| 84 | status=status.HTTP_400_BAD_REQUEST, |
| 85 | ) |
| 86 | response = create_initial_superuser() |
| 87 | return JsonResponse( |
| 88 | { |
| 89 | "adminUserCreated": True, |
| 90 | "passwordResetUrl": response.password_reset_url, |
| 91 | }, |
| 92 | status=status.HTTP_201_CREATED, |
| 93 | ) |
| 94 | |
| 95 | |
| 96 | class FFAdminUserViewSet(mixins.ListModelMixin, viewsets.GenericViewSet): # type: ignore[type-arg] |