def check_email_address(self, hpi): """Check if the UIS email address one of the MCB email addresses""" msg("checking email address") if hpi is None: return conflict_found = False # print 'hpi.phone: %s' % hpi.phone # print 'hpi.person.phone: %s' % hpi.person.phone # print 'hpi.person.second_phone: %s' % hpi.person.second_phone if hpi.email: # the UIS directory has an email address if hpi.person.email == hpi.email or hpi.person.second_email == hpi.email: pass # no conflicts else: # emails don't match conflict_found = True else: # email in MCB directory, but not in the main directory if hpi.person.email or hpi.person.second_email: conflict_found = True # create a DiscrepancyLineItem object and add it to the list of "discrepancies" if conflict_found: msg("conflict found") if not hpi.__dict__.has_key("data_conflicts"): hpi.data_conflicts = [] hpi.data_conflicts.append(DiscrepancyLineItem.create_email_discrepancy_item(hpi))
def check_phone_number(self, hpi): """Check if the UIS phone number matches one of the MCB phone numbers""" msg("checking phone number") if hpi is None: return conflict_found = False # print 'hpi.phone: %s' % hpi.phone # print 'hpi.person.phone: %s' % hpi.person.phone # print 'hpi.person.second_phone: %s' % hpi.person.second_phone if hpi.phone: # the UIS directory has a phone number if hpi.person.phone == hpi.phone or hpi.person.second_phone == hpi.phone: pass # no conflicts else: # phone numbers don't match conflict_found = True else: # phone number in MCB directory, but not in the main directory if hpi.person.phone or hpi.person.second_phone: conflict_found = True # create a DiscrepancyLineItem object and add it to the list of "discrepancies" if conflict_found: msg("conflict found") if not hpi.__dict__.has_key("data_conflicts"): hpi.data_conflicts = [] hpi.data_conflicts.append(DiscrepancyLineItem.create_phone_discrepancy_item(hpi))
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 check_office_address(self, hpi): """Compare the office address of the MCB directory and UIS. Note, UIS has a different format, concatenated into one string that is delimted by '$' UIS address example: FNAME M LNAME$Harvard, FAS Molecular & Cell Biology$Northwest Lab Building Rm 190.01$52 Oxford Street$Cambridge MA 02138 UIS also has separate zipcode and and state fields """ msg("checking office address") conflict_found = False print "hpi.postal_address: %s" % hpi.postal_address print "hpi.person.room: %s" % hpi.person.room print "hpi.person.building: %s" % hpi.person.building
def show_discrepancy(self, cnt=None): # msg('%s - >%s' % (self.harvard_person_info, self.discrepancy_type)) if cnt: msg("-->(%s) %s" % (cnt, self.discrepancy_type)) else: msg("-->%s" % (self.discrepancy_type)) msg("uis: %s" % ", ".join(self.uis_vals)) msg("mcb: %s" % ", ".join(self.mcb_vals))
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")