@property<EOL><INDENT>def notification_needed(self):<DEDENT>
MAIL_ON_EVERY_FAILURE = getattr(settings, '<STR_LIT>', False)<EOL>MAIL_ON_RECOVERY = getattr(settings, '<STR_LIT>', True)<EOL>CONSECUTIVE_FAILURES = getattr(settings, '<STR_LIT>', <NUM_LIT:1>)<EOL>results = self.get_previous_results(CONSECUTIVE_FAILURES)<EOL>results = [self.succeeded] + [result.succeeded for result in results]<EOL>result_list = results[:CONSECUTIVE_FAILURES]<EOL>if True in result_list or len(result_list) < CONSECUTIVE_FAILURES:<EOL><INDENT>result_failed = False<EOL><DEDENT>elif len:<EOL><INDENT>result_failed = True<EOL><DEDENT>prev_results = results[<NUM_LIT:1>:]<EOL>if True in prev_results or len(prev_results) < CONSECUTIVE_FAILURES:<EOL><INDENT>prev_result_failed = False<EOL><DEDENT>else:<EOL><INDENT>prev_result_failed = True<EOL><DEDENT>if result_failed:<EOL><INDENT>if not MAIL_ON_EVERY_FAILURE and prev_result_failed:<EOL><INDENT>return False<EOL><DEDENT>return True<EOL><DEDENT>else:<EOL><INDENT>if MAIL_ON_RECOVERY:<EOL><INDENT>if prev_result_failed:<EOL><INDENT>return True<EOL><DEDENT><DEDENT><DEDENT>return False<EOL>
Checks whether result needs to be mailed to admins.
The procedure is as follows
(taking into account min number of consecutive failures):
1. Find out whether current test failed
2. Find out whether previous test failed
3. If MAIL_ON_EVERY_FAILURE is set to False don't send new notification
   if previous test also failed
4. If test succeeds and MAIL_ON_RECOVERY is set,
   send recovery notification if previous test failed