def compose_email_solution_centric(owner): if project.verbose: print('COMPOSING: ', owner['Account Email']) # start an email template email = EmailTemplate() email.greeting(owner['Account Owner']) email.paragraph(project.task['email']['introduction']) # loop through solutions rows = [] for solution in owner['Solutions']: email.header('Your %d Biggest %s Impact Opportunities This Week' % (project.task['offers'], solution['Solution']['name'])) # create offer matrix for each solution email.table(OFFER_SCHEMA, [( offer['Variant'], '%d%%' % int(offer['Score'] * 100), compose_link( solution['Solution']['link'], { 'solution':solution['Solution']['name'], 'requester':owner['Account Email'], 'name':offer['Variant'], 'dbm':'%s:%s' % (offer['Account_ID'], offer['Variant_ID']) if solution['Solution']['key'] == 'DBM Partner ID' else '', # comma seperated list 'dcm':'%s:%s' % (offer['Account_ID'], offer['Variant_ID']) if solution['Solution']['key'] == 'DCM Network ID' else '', # comma seperated list 'ds':'%s:%s' % (offer['Account_ID'], offer['Variant_ID']) if solution['Solution']['key'] == 'DS Account ID' else '', # comma seperated list 'sa':'%s:%s' % (offer['Account_ID'], offer['Variant_ID']) if solution['Solution']['key'] == 'Studio Account ID' else '', # comma seperated list } ) ) for offer in solution['Offers']]) email.paragraph("Click the request link to schedule a solution for that client. This does not deploy a solution to the client, it only contacts a specialist indicating you'd like to evaluate this solution for this client.") email.header('About ' + solution['Solution']['name']) email.image(solution['Solution']['image'], solution['Solution']['sample']) email.paragraph(solution['Solution']['description']) email.paragraph('Product Gap') email.paragraph(solution['Solution']['gap']) # solution pitch email.paragraph('Benefits') email.list(solution['Solution']['pitches']) # solution impact email.table(IMPACT_SCHEMA, [(i[0], '%d%%' % i[1]) for i in solution['Solution']['impacts'].items()]) email.button('Learn More', project.task['link'], big=True) #print(email.get_html()) send_email( 'user', owner['Account Email'], project.task['email']['from'], project.task['email']['cc'], project.task['email']['subject'], email.get_text(), email.get_html() )
def floodlight_email(day, alerts): for email, table in alerts.items(): # build email template t = EmailTemplate() # when floodlight alerts exist if table: subject = '%d Floodlight Alerts For %s' % (len(table), day) t.header(subject) t.paragraph( 'For the following floodlights, there are suspiciously low impressions. Please check their configurations.' ) t.table([ { "name": "Date", "type": "STRING" }, { "name": "Floodlight", "type": "STRING" }, { "name": "Activity Id", "type": "STRING" }, { "name": "Activity", "type": "STRING" }, { "name": "Impressions", "type": "INTEGER" }, ], table) # when everything is OK else: subject = 'All Floodlights Normal For %s' % day t.header(subject) t.paragraph( 'Impressions all look within statistically expected range.') # either way link to the configuration sheet t.button('Floodlight Monitoring Sheet', project.task['sheet']['url'], big=True) if project.verbose: print "FLOODLIGHT MONITOR EMAIL ALERTS", email, len(table) # send email template send_email(project.task['auth'], email, None, None, subject, t.get_text(), t.get_html())
def floodlight_email(day, alerts): for email, table in alerts.items(): # build email template t = EmailTemplate() t.align('center') t.section(True) # when floodlight alerts exist issues = sum(1 for row in table if row[5] != 'NORMAL') if issues > 0: subject = '%d Floodlight Alerts For %s' % (issues, day) else: subject = 'All Floodlights Normal For %s' % day t.header(subject) t.paragraph( 'The following floodlights are being monitored. A status of LOW or HIGH inidcates impressions have changed significantly for the day. A status of NORMAL means impressions are close to the average for the past 7 days.' ) t.table([ { "name": "Date", "type": "STRING" }, { "name": "Floodlight", "type": "STRING" }, { "name": "Activity Id", "type": "STRING" }, { "name": "Activity", "type": "STRING" }, { "name": "Impressions", "type": "INTEGER" }, { "name": "Status", "type": "STRING" }, ], table) t.paragraph( 'Your monitored floodlights and recipients are listed in the sheet below.' ) # either way link to the configuration sheet t.button('Floodlight Monitoring Sheet', sheets_url(project.task['auth'], project.task['sheet']['sheet']), big=True) t.section(False) if project.verbose: print("FLOODLIGHT MONITOR EMAIL ALERTS", email, len(table)) # send email template send_email(project.task['auth'], email, None, None, subject, t.get_text(), t.get_html())
def floodlight_email( day: str, alerts: dict[str, list[str, str, str, str, int, str]]) -> None: """ Send an email to each alert group with status of all activities. The email template will contain all activities for each email address specified in the input sheet. Args: day - the latest day that was present in all combined reports, used for title of email. alerts - Each email in the sheet with a list of activities and statuses. Returns: Nothing. """ for email, table in alerts.items(): # build email template t = EmailTemplate() t.align('center') t.section(True) # when floodlight alerts exist issues = sum(1 for row in table if row[5] != 'NORMAL') if issues > 0: subject = '%d Floodlight Alerts For %s' % (issues, day) else: subject = 'All Floodlights Normal For %s' % day t.header(subject) t.paragraph( 'The following floodlights are being monitored. A status of LOW or HIGH inidcates impressions have changed significantly for the day. A status of NORMAL means impressions are close to the average for the past 7 days.' ) t.table([ { 'name': 'Date', 'type': 'STRING' }, { 'name': 'Floodlight', 'type': 'STRING' }, { 'name': 'Activity Id', 'type': 'STRING' }, { 'name': 'Activity', 'type': 'STRING' }, { 'name': 'Impressions', 'type': 'INTEGER' }, { 'name': 'Status', 'type': 'STRING' }, ], table) t.paragraph( 'Your monitored floodlights and recipients are listed in the sheet below.' ) # either way link to the configuration sheet t.button('Floodlight Monitoring Sheet', sheets_url(project.task['auth'], project.task['sheet']['sheet']), big=True) t.section(False) if project.verbose: print('FLOODLIGHT MONITOR EMAIL ALERTS', email, len(table)) # send email template send_email(project.task['auth'], email, None, None, subject, t.get_text(), t.get_html())