current avatar url
This commit is contained in:
parent
afad73717f
commit
565f7a298f
3 changed files with 18 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
|||
from django.urls import path
|
||||
from django.contrib.auth.views import LogoutView
|
||||
from .views import UserListView, UserDetailView, AccountView, RequestOTPView, ChangePasswordView, \
|
||||
OTPLoginView, ProfileDetailView, ProfileUpdateView, RequestOTTView
|
||||
OTPLoginView, ProfileDetailView, ProfileUpdateView, RequestOTTView, UserCurrentAvatarUrlView
|
||||
|
||||
app_name = "users"
|
||||
|
||||
|
|
@ -13,6 +13,7 @@ urlpatterns = [
|
|||
path('api/account/', AccountView.as_view(), name='account_api'),
|
||||
path('api/users/', UserListView.as_view(), name='user_list_api'),
|
||||
path('api/users/<uuid>/', UserDetailView.as_view(), name='user_detail_api'),
|
||||
path('api/users/<uuid>/avatar', UserCurrentAvatarUrlView.as_view(), name='user_avatar_api'),
|
||||
path('api/request_otp/', RequestOTPView.as_view(), name='request_otp_api'),
|
||||
path('api/request_ott/', RequestOTTView.as_view(), name='request_ott_api'),
|
||||
path('api/change_password/', ChangePasswordView.as_view(), name='change_password_api'),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.views import LoginView
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import render, redirect
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.decorators import method_decorator
|
||||
|
|
@ -39,6 +39,20 @@ class UserDetailView(generics.RetrieveAPIView):
|
|||
"GET": [["accounts.profile:retrieve"]],
|
||||
}
|
||||
|
||||
class UserCurrentAvatarUrlView(generics.RetrieveAPIView):
|
||||
permission_classes = [IsAuthenticatedOrTokenMatchesOASRequirements]
|
||||
queryset = User.objects.all()
|
||||
# serializer_class = PublicUserSerializer
|
||||
lookup_field = 'uuid'
|
||||
required_alternate_scopes = {
|
||||
"GET": [["accounts.profile:retrieve"]],
|
||||
}
|
||||
|
||||
def retrieve(self, request, *args, **kwargs):
|
||||
user: User = self.get_object()
|
||||
return redirect(user.avatar.url)
|
||||
# Response(serializer.data)
|
||||
|
||||
|
||||
class AccountView(generics.RetrieveUpdateAPIView):
|
||||
serializer_class = AccountSerializer
|
||||
|
|
|
|||
|
|
@ -200,3 +200,4 @@ print(client.get_wallet_balance())
|
|||
# ott = client.get_application_token()[1]['ott']
|
||||
# print(client.ott_login(ott))
|
||||
# print(ott)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue