#NEWLINE# def serialize_draft_registration( draft , json_safe = True ) : #NEWLINE# #INDENT# if ( draft . branched_from is not None ) : #NEWLINE# #INDENT# url = furl ( OSF_DOMAIN ) #NEWLINE# url . path . add ( draft . branched_from . url ) #NEWLINE# node_url = url . url #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# node_url = None #NEWLINE# #UNINDENT# registration_choice = draft . approval . meta . get ( 'registration_choice' , None ) #NEWLINE# if ( registration_choice == EMBARGO ) : #NEWLINE# #INDENT# time = parser . parse ( draft . approval . meta [ 'embargo_end_date' ] ) #NEWLINE# embargo = ( iso8601format ( time ) if json_safe else time ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# embargo = IMMEDIATE #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'pk' : draft . _id , #NEWLINE# 'initiator' : serialize_user ( draft . initiator ) , #NEWLINE# 'registration_metadata' : draft . registration_metadata , #NEWLINE# 'registration_schema' : serialize_meta_schema ( draft . registration_schema ) , #NEWLINE# 'initiated' : ( iso8601format ( draft . datetime_initiated ) if json_safe else draft . datetime_initiated ) , #NEWLINE# 'updated' : ( iso8601format ( draft . datetime_updated ) if json_safe else draft . datetime_updated ) , #NEWLINE# 'submitted' : ( iso8601format ( draft . approval . initiation_date ) if json_safe else draft . approval . initiation_date ) , #NEWLINE# 'requires_approval' : draft . requires_approval , #NEWLINE# 'is_pending_approval' : draft . is_pending_review , #NEWLINE# 'is_approved' : draft . is_approved , #NEWLINE# 'is_rejected' : draft . is_rejected , #NEWLINE# 'notes' : draft . notes , #NEWLINE# 'proof_of_publication' : draft . flags . get ( 'proof_of_publication' ) , #NEWLINE# 'payment_sent' : draft . flags . get ( 'payment_sent' ) , #NEWLINE# 'assignee' : draft . flags . get ( 'assignee' ) , #NEWLINE# 'title' : draft . registration_metadata [ 'q1' ] [ 'value' ] , #NEWLINE# 'embargo' : embargo , #NEWLINE# 'registered_node' : node_url , #NEWLINE# #UNINDENT# }