mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-07-14 02:55:54 +00:00
feat(profile): add user profile update serializer and update profile URL to use UserprofileAPIView ✨
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 5m21s
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 5m21s
This commit is contained in:
@ -1,9 +1,12 @@
|
|||||||
from knox.models import AuthToken
|
from knox.models import AuthToken
|
||||||
from django.contrib.auth import authenticate
|
from django.contrib.auth import authenticate
|
||||||
from api.models import User, Atoll, Island, TemporaryUser
|
from api.models import Atoll, Island, TemporaryUser
|
||||||
from django.contrib.auth.models import Permission
|
from django.contrib.auth.models import Permission
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
|
User = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
class IslandSerializer(serializers.ModelSerializer):
|
class IslandSerializer(serializers.ModelSerializer):
|
||||||
@ -21,6 +24,15 @@ class AtollSerializer(serializers.ModelSerializer):
|
|||||||
depth = 2
|
depth = 2
|
||||||
|
|
||||||
|
|
||||||
|
class UserProfileUpdateSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta: # type: ignore
|
||||||
|
model = User
|
||||||
|
fields = (
|
||||||
|
"email",
|
||||||
|
"mobile",
|
||||||
|
) # Only allow these fields
|
||||||
|
|
||||||
|
|
||||||
class CustomUserSerializer(serializers.ModelSerializer):
|
class CustomUserSerializer(serializers.ModelSerializer):
|
||||||
"""serializer for the user object"""
|
"""serializer for the user object"""
|
||||||
|
|
||||||
@ -80,6 +92,7 @@ class CustomReadOnlyUserSerializer(serializers.ModelSerializer):
|
|||||||
"username",
|
"username",
|
||||||
"mobile",
|
"mobile",
|
||||||
"address",
|
"address",
|
||||||
|
"acc_no",
|
||||||
"id_card",
|
"id_card",
|
||||||
)
|
)
|
||||||
depth = 1
|
depth = 1
|
||||||
|
@ -5,7 +5,7 @@ from knox import views as knox_views
|
|||||||
from .views import (
|
from .views import (
|
||||||
LoginView,
|
LoginView,
|
||||||
CreateTemporaryUserView,
|
CreateTemporaryUserView,
|
||||||
ManageUserView,
|
UserprofileAPIView,
|
||||||
KnoxTokenListApiView,
|
KnoxTokenListApiView,
|
||||||
ListUserView,
|
ListUserView,
|
||||||
UserDetailAPIView,
|
UserDetailAPIView,
|
||||||
@ -27,7 +27,7 @@ from .views import (
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("register/", CreateTemporaryUserView.as_view(), name="register"),
|
path("register/", CreateTemporaryUserView.as_view(), name="register"),
|
||||||
path("register/verify/", VerifyOTPView.as_view(), name="verify-otp"),
|
path("register/verify/", VerifyOTPView.as_view(), name="verify-otp"),
|
||||||
path("profile/", ManageUserView.as_view(), name="profile"),
|
path("profile/", UserprofileAPIView.as_view(), name="profile"),
|
||||||
path("login/", LoginView.as_view(), name="knox_login"),
|
path("login/", LoginView.as_view(), name="knox_login"),
|
||||||
path("logout/", knox_views.LogoutView.as_view(), name="knox_logout"),
|
path("logout/", knox_views.LogoutView.as_view(), name="knox_logout"),
|
||||||
path("logoutall/", knox_views.LogoutAllView.as_view(), name="knox_logoutall"),
|
path("logoutall/", knox_views.LogoutAllView.as_view(), name="knox_logoutall"),
|
||||||
|
Reference in New Issue
Block a user