#NEWLINE# def my_requests( self , status = None , user = None ) : #NEWLINE# #INDENT# members = self . session . query ( label ( 'type' , literal ( 1 ) ) , label ( 'id' , Group . id ) , label ( 'name' , Group . groupname ) ) . union ( self . session . query ( label ( 'type' , literal ( 0 ) ) , label ( 'id' , User . id ) , label ( 'name' , User . username ) ) ) . subquery ( ) #NEWLINE# requests = self . session . query ( Request . id , Request . requested_at , GroupEdge . expiration , label ( 'role' , GroupEdge . _role ) , Request . status , label ( 'requester' , User . username ) , label ( 'type' , members . c . type ) , label ( 'requesting' , members . c . name ) , label ( 'reason' , Comment . comment ) ) . filter ( ( Request . on_behalf_obj_pk == members . c . id ) , ( Request . on_behalf_obj_type == members . c . type ) , ( Request . requesting_id == self . id ) , ( Request . requester_id == User . id ) , ( Request . id == RequestStatusChange . request_id ) , ( RequestStatusChange . from_status == None ) , ( GroupEdge . id == Request . edge_id ) , ( Comment . obj_type == 3 ) , ( Comment . obj_pk == RequestStatusChange . id ) ) #NEWLINE# if status : #NEWLINE# #INDENT# requests = requests . filter ( ( Request . status == status ) ) #NEWLINE# #UNINDENT# if user : #NEWLINE# #INDENT# requests = requests . filter ( ( Request . on_behalf_obj_pk == user . id ) , ( Request . on_behalf_obj_type == 0 ) ) #NEWLINE# #UNINDENT# return requests