added user account delete feature

This commit is contained in:
Mohamed Nouffer
2023-01-06 16:09:41 +05:30
parent b1894afecd
commit 631058468c
2 changed files with 16 additions and 2 deletions

View File

@ -1,7 +1,7 @@
from sys import prefix
from rest_framework import urlpatterns
from rest_framework.routers import DefaultRouter
from .views import LocationViewSet, Location_lineViewSet, Location_polygonViewSet, Jpn_Main_PerfViewSet, Jpn_PerfViewSet, LocationsInPerf, SubInPerf, ExtentForSubPerf, SubPerfInMainPerf, ExtentForMainPerf, LocationsInSubPerf, CatView, RegistrationAPI, LoginAPI, UserAPI, UserActionViewset, UserMakeActionViewset, UserDestinations, UpdateOrder, LocationInBound, DeleteDestination, CustomAreaLocations, GetAllGifuAreas, CustomAreaNames, userDetials, UserTracksViewSet, CatByCity, ChangePasswordView, GoalImageViewSet, CheckinImageViewSet, ExtentForLocations
from .views import LocationViewSet, Location_lineViewSet, Location_polygonViewSet, Jpn_Main_PerfViewSet, Jpn_PerfViewSet, LocationsInPerf, SubInPerf, ExtentForSubPerf, SubPerfInMainPerf, ExtentForMainPerf, LocationsInSubPerf, CatView, RegistrationAPI, LoginAPI, UserAPI, UserActionViewset, UserMakeActionViewset, UserDestinations, UpdateOrder, LocationInBound, DeleteDestination, CustomAreaLocations, GetAllGifuAreas, CustomAreaNames, userDetials, UserTracksViewSet, CatByCity, ChangePasswordView, GoalImageViewSet, CheckinImageViewSet, ExtentForLocations, DeleteAccount
from django.urls import path, include
from knox import views as knox_views
@ -45,6 +45,7 @@ urlpatterns += [
path('delete_destination/', DeleteDestination, name='delete_detination'),
path('customareanames/', CustomAreaNames, name='custom_area_name'),
path('userdetials/', userDetials, name='user_detials'),
path('change-password/', ChangePasswordView.as_view(), name='change-password')
path('change-password/', ChangePasswordView.as_view(), name='change-password'),
path('delete-account/', DeleteAccount, name="delete-account"),
# path('goal-image/', GoalImageViewSet.as_view(), name='goal-image')
]

View File

@ -27,6 +27,7 @@ from rest_framework.decorators import api_view
from rest_framework.decorators import api_view, permission_classes
from rest_framework.parsers import JSONParser, MultiPartParser
from django.views.decorators.csrf import csrf_exempt
import uuid
@ -346,6 +347,18 @@ def userDetials(request):
serializer = RogUserSerializer(rogUser, many=True)
return JsonResponse(serializer.data, safe=False)
@api_view(['GET'])
@permission_classes((IsAuthenticated, ))
def DeleteAccount(request):
usr = request.user;
#print("user is" + usr)
if(usr):
#usr.delete()
usr.email = usr.email + "_res" + str(uuid.uuid4())
usr.save();
AuthToken.objects.filter(user=usr).delete()
return Response({"result":"user deleted"})
return Response({"result":"user not found"})
def UserActionViewset(request):