def send_report(self): ''' From an instance of the Monthly model, send out an e-mail saying that this months monthly report is ready. This gets pinged from a server task every month through Heroku. In theory. ''' if self.email_list is None: subj = 'Inspection Interations Monthly Status Report' current_app.logger.info( 'NO-EMAIL-ADDRESS | Subject: {}'.format(subj)) else: subj = 'Inspection Interations Monthly Status Report - {}' from_email = current_app.config.get('ADMIN_EMAIL') last_month = arrow.utcnow().replace(months=-1) date_start, date_end = last_month.span('month') date_header = date_start.format('MMMM, YYYY') year = last_month.format('YYYY') month = last_month.format('MM') report = url_for( 'reports.overview', _external=True, year=year, month=month) send_email( subj.format(date_header), from_email, self.email_list, render_template('email/monthly_notification.txt', date_header=date_header, report=report), render_template('email/monthly_notification.html', date_header=date_header, report=report))
def follow_up(models): ''' Inputs a bunch of survey models, go through each of them, figuring out if they require follow-ups and then e-mail the appropriate directors. Returns ..? ''' subj = 'Miami-Dade County Inspectors Survey' from_email = '*****@*****.**' for survey in models: if survey.follow_up and survey.permit_type is not None: stakeholder = Stakeholder.query.get(survey.permit_type) if stakeholder is None or stakeholder.email_list is None: current_app.logger.info( 'NOSTAKEHOLDER | Type: {}\nSurvey Submitted Date: {}\nSubject: {}' .format(survey.permit_type_en, survey.date_submitted, subj)) else: send_email( subj, from_email, stakeholder.email_list, render_template('email/followup_notification.txt', survey=survey), render_template('email/followup_notification.html', survey=survey))
def follow_up(models): ''' Inputs a bunch of survey models, go through each of them, figuring out if they require follow-ups and then e-mail the appropriate directors. Returns ..? ''' subj = 'A new survey has been submitted for your section!' from_email = current_app.config.get('ADMIN_EMAIL') for survey in models: if survey.follow_up and survey.route is not None: stakeholder = Stakeholder.query.get(survey.route) if stakeholder is None or stakeholder.email_list is None: current_app.logger.info( 'NOSTAKEHOLDER | Route: {}\nSurvey Submitted Date: {}\nSubject: {}' .format(survey.route_en, survey.date_submitted, subj)) else: send_email( subj, from_email, stakeholder.email_list, render_template('email/followup_notification.txt', survey=survey), render_template('email/followup_notification.html', survey=survey))
def follow_up(models): ''' Inputs a bunch of survey models, go through each of them, figuring out if they require follow-ups and then e-mail the appropriate directors. Returns ..? ''' subj = 'Miami-Dade County Inspectors Survey' from_email = '*****@*****.**' for survey in models: if survey.follow_up and survey.permit_type is not None: stakeholder = Stakeholder.query.get(survey.permit_type) if stakeholder is None or stakeholder.email_list is None: current_app.logger.info( 'NOSTAKEHOLDER | Type: {}\nSurvey Submitted Date: {}\nSubject: {}'.format( survey.permit_type_en, survey.date_submitted, subj ) ) else: send_email( subj, from_email, stakeholder.email_list, render_template( 'email/followup_notification.txt', survey=survey ), render_template( 'email/followup_notification.html', survey=survey ))
def follow_up(models): ''' Inputs a bunch of survey models, go through each of them, figuring out if they require follow-ups and then e-mail the appropriate directors. Returns ..? ''' subj = 'A new survey has been submitted for your section!' from_email = current_app.config.get('ADMIN_EMAIL') for survey in models: if survey.follow_up and survey.route is not None: stakeholder = Stakeholder.query.get(survey.route) if stakeholder is None or stakeholder.email_list is None: current_app.logger.info( 'NOSTAKEHOLDER | Route: {}\nSurvey Submitted Date: {}\nSubject: {}'.format( survey.route_en, survey.date_submitted, subj ) ) else: send_email( subj, from_email, stakeholder.email_list, render_template( 'email/followup_notification.txt', survey=survey ), render_template( 'email/followup_notification.html', survey=survey ))