#NEWLINE# def post( self , request , format = None ) : #NEWLINE# #INDENT# ser = serializers . LoginSerializer ( data = request . data ) #NEWLINE# if ser . is_valid ( ) : #NEWLINE# #INDENT# anonymous_basket = operations . get_anonymous_basket ( request ) #NEWLINE# user = ser . instance #NEWLINE# if request . user . is_authenticated ( ) : #NEWLINE# #INDENT# return Response ( { #NEWLINE# #INDENT# 'detail' : 'Session is in use, log out first' , #NEWLINE# #UNINDENT# } , status = status . HTTP_405_METHOD_NOT_ALLOWED ) #NEWLINE# #UNINDENT# request . user = user #NEWLINE# login_and_upgrade_session ( request . _request , user ) #NEWLINE# basket = operations . get_user_basket ( user ) #NEWLINE# if ( anonymous_basket is not None ) : #NEWLINE# #INDENT# self . merge_baskets ( anonymous_basket , basket ) #NEWLINE# #UNINDENT# operations . store_basket_in_session ( format , request . session ) #NEWLINE# return Response ( ) #NEWLINE# #UNINDENT# return Response ( ser . errors , status = status . HTTP_401_UNAUTHORIZED )