#NEWLINE# def complex_get( param_dict , limit , language , format , attachments ) : #NEWLINE# #INDENT# voidQ = Q ( voided = False ) #NEWLINE# reffilter = False #NEWLINE# sinceQ = Q ( ) #NEWLINE# if ( 'since' in param_dict ) : #NEWLINE# #INDENT# sinceQ = Q ( stored__gt = convert_to_datetime_object ( param_dict [ 'since' ] ) ) #NEWLINE# #UNINDENT# untilQ = Q ( ) #NEWLINE# if ( 'until' in param_dict ) : #NEWLINE# #INDENT# untilQ = Q ( stored__lte = convert_to_datetime_object ( param_dict [ 'until' ] ) ) #NEWLINE# #UNINDENT# authQ = Q ( ) #NEWLINE# if ( ( 'auth' in param_dict ) and ( param_dict [ 'auth' ] and ( 'statements_mine_only' in param_dict [ 'auth' ] ) ) ) : #NEWLINE# #INDENT# q_auth = param_dict [ 'auth' ] [ 'agent' ] #NEWLINE# if q_auth . oauth_identifier : #NEWLINE# #INDENT# authQ = ( Q ( authority = q_auth ) | Q ( authority = q_auth . get_user_from_oauth_group ( ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# oauth_clients = Agent . objects . filter ( member__in = [ a ] ) #NEWLINE# authQ = Q ( authority = q_auth ) #NEWLINE# for client in oauth_clients : #NEWLINE# #INDENT# authQ = ( authQ | Q ( authority = client . get_user_from_oauth_group ( ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# agentQ = Q ( ) #NEWLINE# if ( 'agent' in param_dict ) : #NEWLINE# #INDENT# reffilter = True #NEWLINE# agent = None #NEWLINE# data = param_dict [ 'agent' ] #NEWLINE# related = ( ( 'related_agents' in param_dict ) and param_dict [ 'related_agents' ] ) #NEWLINE# agent = Agent . objects . retrieve ( ** data ) #NEWLINE# if agent : #NEWLINE# #INDENT# if ( agent . objectType == 'Group' ) : #NEWLINE# #INDENT# groups = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# groups = agent . member . all ( ) #NEWLINE# #UNINDENT# agentQ = Q ( actor = agent ) #NEWLINE# for g in groups : #NEWLINE# #INDENT# agentQ = ( agentQ | Q ( actor = g ) ) #NEWLINE# #UNINDENT# if related : #NEWLINE# #INDENT# me = chain ( [ agent ] , groups ) #NEWLINE# for a in me : #NEWLINE# #INDENT# agentQ = ( ( ( ( ( ( ( ( agentQ | Q ( object_agent = a ) ) | Q ( authority = a ) ) | Q ( context_instructor = a ) ) | Q ( context_team = a ) ) | Q ( object_substatement__actor = a ) ) | Q ( object_substatement__object_agent = a ) ) | Q ( object_substatement__context_instructor = a ) ) | Q ( object_substatement__context_team = a ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# verbQ = Q ( ) #NEWLINE# if ( 'verb' in param_dict ) : #NEWLINE# #INDENT# reffilter = True #NEWLINE# verbQ = Q ( verb__verb_id = param_dict [ 'verb' ] ) #NEWLINE# #UNINDENT# activityQ = Q ( ) #NEWLINE# if ( 'activity' in param_dict ) : #NEWLINE# #INDENT# reffilter = True #NEWLINE# activityQ = Q ( object_activity__activity_id = param_dict [ 'activity' ] ) #NEWLINE# if ( ( 'related_activities' in param_dict ) and param_dict [ 'related_activities' ] ) : #NEWLINE# #INDENT# activityQ = ( ( ( ( ( ( ( ( ( activityQ | Q ( context_ca_parent__activity_id = param_dict [ 'activity' ] ) ) | Q ( context_ca_grouping__activity_id = param_dict [ 'activity' ] ) ) | Q ( context_ca_category__activity_id = param_dict [ 'activity' ] ) ) | Q ( context_ca_other__activity_id = param_dict [ 'activity' ] ) ) | Q ( object_substatement__object_activity__activity_id = param_dict [ 'activity' ] ) ) | Q ( object_substatement__context_ca_parent__activity_id = param_dict [ 'activity' ] ) ) | Q ( object_substatement__context_ca_grouping__activity_id = param_dict [ 'activity' ] ) ) | Q ( object_substatement__context_ca_category__activity_id = param_dict [ 'activity' ] ) ) | Q ( object_substatement__context_ca_other__activity_id = param_dict [ 'activity' ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# registrationQ = Q ( ) #NEWLINE# if ( 'registration' in param_dict ) : #NEWLINE# #INDENT# reffilter = True #NEWLINE# registrationQ = Q ( context_registration = param_dict [ 'registration' ] ) #NEWLINE# #UNINDENT# stored_param = '-stored' #NEWLINE# if ( ( 'ascending' in param_dict ) and param_dict [ 'ascending' ] ) : #NEWLINE# #INDENT# stored_param = 'stored' #NEWLINE# #UNINDENT# stmtset = Statement . objects . select_related ( 'actor' , 'verb' , 'context_team' , 'context_instructor' , 'authority' , 'object_agent' , 'object_activity' , 'object_substatement' ) . prefetch_related ( 'context_ca_parent' , 'context_ca_grouping' , 'context_ca_category' , 'context_ca_other' ) . filter ( ( ( ( ( ( ( untilQ & sinceQ ) & authQ ) & agentQ ) & verbQ ) & activityQ ) & registrationQ ) ) . distinct ( ) #NEWLINE# st_ids = stmtset . values_list ( 'statement_id' ) #NEWLINE# stmtset = [ st_id [ 0 ] for st_id in st_ids ] #NEWLINE# if reffilter : #NEWLINE# #INDENT# stmtset = ( stmtset + stmt_ref_search ( stmtset , untilQ , sinceQ ) ) #NEWLINE# #UNINDENT# return_limit = set_limit ( limit ) #NEWLINE# actual_length = Statement . objects . filter ( ( Q ( statement_id__in = stmtset ) & voidQ ) ) . distinct ( ) . count ( ) #NEWLINE# if ( actual_length > return_limit ) : #NEWLINE# #INDENT# return create_over_limit_stmt_result ( stmtset , stored_param , return_limit , language , format , attachments ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return create_under_limit_stmt_result ( stmtset , stored_param , language , format )