#NEWLINE# def get_recipients_for_notice( self , notice_type , users ) : #NEWLINE# #INDENT# if isinstance ( notice_type , basestring ) : #NEWLINE# #INDENT# notice_type = ALERT_TYPES [ notice_type ] #NEWLINE# #UNINDENT# if ( not users ) : #NEWLINE# #INDENT# return ( ) #NEWLINE# #UNINDENT# if isinstance ( alert_prefs , QuerySet ) : #NEWLINE# #INDENT# user_ids = list ( users . values_list ( 'id' , flat = True ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# user_ids = [ u . id for u in users ] #NEWLINE# #UNINDENT# alert_prefs = self . get_queryset_compat ( ) . filter ( alert_type = notice_type . id ) . filter ( user__in = user_ids ) #NEWLINE# prefs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for pref in alert_prefs : #NEWLINE# #INDENT# prefs [ ( pref . user_id , pref . backend ) ] = pref . preference #NEWLINE# #UNINDENT# user_cache = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for user in users : #NEWLINE# #INDENT# user_cache [ user . id ] = user #NEWLINE# for backend in ALERT_BACKENDS . values ( ) : #NEWLINE# #INDENT# if ( ( user . id , backend . id ) not in prefs ) : #NEWLINE# #INDENT# prefs [ ( user . id , backend . id ) ] = notice_type . get_default ( backend . id ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ( ( user_cache [ user_id ] , ALERT_BACKENDS [ backend_id ] ) for ( ( user_id , backend_id ) , pref ) in prefs . items ( ) if pref )