def show_discrepancies(self): conflict_found_lst = filter(lambda x: x.__dict__.has_key("data_conflicts"), self.person_lst) cnt = 0 for p in conflict_found_lst: msgt(p) for d in p.data_conflicts: cnt += 1 d.show_discrepancy(cnt) print "people with phone discrepancies: %s" % len(conflict_found_lst)
def check_discrepancies(self): """If a discrepancy is found, add a 'discrepancies' attribute to the HarvardPersonInfo object. The 'discrepancies' attribute is a [] containing 1 or more DiscrepancyLineItem objects""" # for each person, check disprepancies for hpi in self.person_lst: msg(hpi.id) msgt("checking person: %s %s" % (hpi.id, hpi)) self.check_phone_number(hpi) self.check_email_address(hpi) self.check_office_address(hpi) # in progress
def send_privacy_report(): # contruct an email msgt("(3) Preparing email with results") admin_emails = get_admin_email_addresses() from_email = admin_emails[0] to_addresses = admin_emails if len(no_info) == 0: subject = "Personnel Privacy Data: Looks Good!" mail_msg = """Every person has a privacy record. (%s)""" % get_datetime_now() else: subject = "Personnel Privacy Data: %s people do not have info" % len(no_info) person_lst = "\n\n".join( map( lambda x: "- %s - %s" % (x, "https://webapps.sciences.fas.harvard.edu/mcb/mcb-control-panel/person/person/%s/" % x.id), no_info, ) ) mail_msg = """The following people lack privacy records: %s (time %s)""" % ( person_lst, get_datetime_now(), ) msg("from: %s" % from_email) msg("to_addresses: %s" % to_addresses) msg("mail_msg: %s" % mail_msg) msgt("(4) Sending email with results") send_message( from_email, to_addresses, subject=subject, text_content=mail_msg, html_content=mail_msg.replace("\n", "<br />") ) msg("Email sent!") msgt("Done")