#NEWLINE# def post( self , request ) : #NEWLINE# #INDENT# 'Create a new authentication key\n        ' #NEWLINE# model = self . model #NEWLINE# if ( ( not model . form ) or ( not self . get_user ) ) : #NEWLINE# #INDENT# raise MethodNotAllowed #NEWLINE# #UNINDENT# ( data , _ ) = request . data_and_files ( ) #NEWLINE# form = model . form ( request , data = data ) #NEWLINE# if form . is_valid ( ) : #NEWLINE# #INDENT# expiry = form . cleaned_data . get ( 'expiry' ) #NEWLINE# if ( not expiry ) : #NEWLINE# #INDENT# days = request . config [ 'ACCOUNT_ACTIVATION_DAYS' ] #NEWLINE# expiry = ( datetime . now ( ) + timedelta ( days = days ) ) #NEWLINE# #UNINDENT# user = self . get_user ( request ) #NEWLINE# if isinstance ( user , tuple ) : #NEWLINE# #INDENT# user = user [ 0 ] #NEWLINE# #UNINDENT# backend = request . cache . auth_backend #NEWLINE# auth_key = backend . create_auth_key ( request , user , expiry = expiry ) #NEWLINE# data = { #NEWLINE# #INDENT# 'registration_key' : auth_key , #NEWLINE# #UNINDENT# } #NEWLINE# request . response . status_code = 201 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# data = form . tojson ( ) #NEWLINE# #UNINDENT# return Json ( data ) . http_response ( expiry )