Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Send JSON response instead of plain text #2739

Merged
merged 3 commits into from
Sep 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions api/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.contrib.sites.shortcuts import get_current_site
from django.db.models import Q, QuerySet
from django.http import Http404, HttpResponse
from django.http import Http404, JsonResponse
from django.shortcuts import get_object_or_404, redirect
from django.utils.decorators import method_decorator
from django.views import View
Expand Down Expand Up @@ -58,7 +58,7 @@ def handle_no_permission(self):
def form_valid(self, form):
form.create_admin()
form.update_site()
return HttpResponse("INSTALLATION CONFIGURED SUCCESSFULLY")
return JsonResponse({"message": "INSTALLATION CONFIGURED SUCCESSFULLY"})


class AdminInitView(View):
Expand All @@ -70,10 +70,15 @@ def get(self, request):
is_active=True,
)
admin.save()
return HttpResponse("ADMIN USER CREATED")
return JsonResponse(
{"adminUserCreated": True}, status=status.HTTP_201_CREATED
)
else:
return HttpResponse(
"FAILED TO INIT ADMIN USER. USER(S) ALREADY EXIST IN SYSTEM."
return JsonResponse(
{
"message": "FAILED TO INIT ADMIN USER. USER(S) ALREADY EXIST IN SYSTEM."
},
status=status.HTTP_400_BAD_REQUEST,
)


Expand Down