@@ -193,21 +193,15 @@ def post(self, request, *args, **kwargs):
193193 destination : str = serializer .validated_data [
194194 "destination"
195195 ] # destination is a required field
196- destination_property : str = serializer .validated_data .get (
197- "prop"
198- ) # can be email or mobile
196+ destination_property : str = serializer .validated_data .get ("prop" ) # can be email or mobile
199197 user : User = serializer .validated_data .get ("user" )
200198 email : Optional [str ] = serializer .validated_data .get ("email" )
201199 is_login : bool = serializer .validated_data .get ("is_login" )
202200
203201 if "verify_otp" in request .data .keys ():
204- if validate_otp (
205- destination = destination , otp_val = request .data ["verify_otp" ]
206- ):
202+ if validate_otp (destination = destination , otp_val = request .data ["verify_otp" ]):
207203 if is_login :
208- return Response (
209- login_user (user , self .request ), status = status .HTTP_202_ACCEPTED
210- )
204+ return Response (login_user (user , self .request ), status = status .HTTP_202_ACCEPTED )
211205 else :
212206 return Response (
213207 data = {"OTP" : _ ("OTP Validated successfully!" )},
@@ -257,9 +251,7 @@ def get_object(self):
257251 def update (self , request , * args , ** kwargs ):
258252 """Updates user's password"""
259253
260- response = super (RetrieveUpdateUserAccountView , self ).update (
261- request , * args , ** kwargs
262- )
254+ response = super (RetrieveUpdateUserAccountView , self ).update (request , * args , ** kwargs )
263255 # we need to set_password after save the user otherwise it'll save the raw_password in db. # noqa
264256 if "password" in request .data .keys ():
265257 self .request .user .set_password (request .data ["password" ])
@@ -311,17 +303,11 @@ def post(self, request, *args, **kwargs):
311303 )
312304 user .is_active = True
313305 user .save (update_fields = ["is_active" ])
314- return Response (
315- login_user (user , self .request ), status = status .HTTP_202_ACCEPTED
316- )
306+ return Response (login_user (user , self .request ), status = status .HTTP_202_ACCEPTED )
317307
318- otp_obj : OTPValidation = generate_otp (
319- destination_property = EMAIL , destination = email
320- )
308+ otp_obj : OTPValidation = generate_otp (destination_property = EMAIL , destination = email )
321309 # Send OTP to Email & Mobile
322- sent_otp_resp : dict = send_otp (
323- otp_obj = otp_obj , recip_email = email , recip_mobile = mobile
324- )
310+ sent_otp_resp : dict = send_otp (otp_obj = otp_obj , recip_email = email , recip_mobile = mobile )
325311
326312 if not sent_otp_resp ["success" ]:
327313 raise serializers .ValidationError (
@@ -394,9 +380,7 @@ def post(self, request, *args, **kwargs):
394380 image_serializer .update (
395381 instance = request .user , validated_data = image_serializer .validated_data
396382 )
397- return Response (
398- {"detail" : "Profile Image Uploaded." }, status = status .HTTP_201_CREATED
399- )
383+ return Response ({"detail" : "Profile Image Uploaded." }, status = status .HTTP_201_CREATED )
400384
401385
402386class CustomTokenRefreshView (TokenRefreshView ):
@@ -419,13 +403,9 @@ def post(self, request, *args, **kwargs):
419403
420404 token = serializer .validated_data .get ("access" )
421405
422- auth_transaction = AuthTransaction .objects .get (
423- refresh_token = request .data ["refresh" ]
424- )
406+ auth_transaction = AuthTransaction .objects .get (refresh_token = request .data ["refresh" ])
425407 auth_transaction .token = token
426- auth_transaction .expires_at = (
427- timezone .now () + api_settings .ACCESS_TOKEN_LIFETIME
428- )
408+ auth_transaction .expires_at = timezone .now () + api_settings .ACCESS_TOKEN_LIFETIME
429409 auth_transaction .save (update_fields = ["token" , "expires_at" ])
430410
431411 return Response ({"token" : str (token )}, status = status .HTTP_200_OK )
0 commit comments