#NEWLINE# def get_email_addresses_for_group( group , review_request_id = None ) : #NEWLINE# #INDENT# 'Build a list of e-mail addresses for the group.\n\n    Args:\n        group (reviewboard.reviews.models.Group):\n            The review group to build the e-mail addresses for.\n\n    Returns:\n        list: A list of properly formatted e-mail addresses for all users in\n        the review group.\n    ' #NEWLINE# addresses = [ ] #NEWLINE# if group . mailing_list : #NEWLINE# #INDENT# if ( ',' not in group . mailing_list ) : #NEWLINE# #INDENT# addresses = [ build_email_address ( group . display_name , group . mailing_list ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# addresses = group . mailing_list . split ( ',' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not ( group . mailing_list and group . email_list_only ) ) : #NEWLINE# #INDENT# users_q = Q ( is_active = True ) #NEWLINE# local_site = group . local_site #NEWLINE# if local_site : #NEWLINE# #INDENT# users_q = ( users_q & ( Q ( local_site = local_site ) | Q ( local_site_admins = local_site ) ) ) #NEWLINE# #UNINDENT# users = group . users . filter ( users_q ) . select_related ( 'profile' ) #NEWLINE# if review_request_id : #NEWLINE# #INDENT# users = users . extra ( select = { #NEWLINE# #INDENT# 'visibility' : ( '\n                    SELECT accounts_reviewrequestvisit.visibility\n                      FROM accounts_reviewrequestvisit\n                     WHERE accounts_reviewrequestvisit.review_request_id =\n                           %s\n                       AND accounts_reviewrequestvisit.user_id =\n                           reviews_group_users.user_id\n                ' % review_request_id ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# addresses . extend ( [ get_email_address_for_user ( u ) for u in users if ( u . should_send_email ( ) and ( ( not review_request_id ) or ( u . visibility != ReviewRequestVisit . MUTED ) ) ) ] ) #NEWLINE# #UNINDENT# return addresses