def send_reminder_email(email_template, volunteer_relation): project = volunteer_relation.project volunteer = volunteer_relation.volunteer context = { 'first_name': volunteer.first_name, 'project_name': project.project_name, 'project_end_date': datetime_to_string( datetime_field_to_datetime(volunteer_relation.projected_end_date), DateTimeFormats.DATE_LOCALIZED), 'volunteer_start_date': datetime_to_string( datetime_field_to_datetime(volunteer_relation.application_date), DateTimeFormats.DATE_LOCALIZED) } email_msg = EmailMessage( subject="You're making a difference at " + project.project_name, from_email=_get_account_from_email(settings.EMAIL_VOLUNTEER_ACCT), to=[volunteer.email], ) email_msg = email_template.render(email_msg, context) send_email(email_msg, settings.EMAIL_VOLUNTEER_ACCT)
def send_volunteer_application_email(volunteer_relation, is_reminder=False): project = volunteer_relation.project user = volunteer_relation.volunteer role_details = Tag.from_field(volunteer_relation.role) role_text = "{subcategory}: {name}".format(subcategory=role_details.subcategory, name=role_details.display_name) project_profile_url = settings.PROTOCOL_DOMAIN + '/index/?section=AboutProject&id=' + str(project.id) approve_url = settings.PROTOCOL_DOMAIN + '/volunteer/approve/' + str(volunteer_relation.id) + '/' email_subject = '{is_reminder}{firstname} {lastname} would like to volunteer with {project} as {role}'.format( is_reminder='REMINDER: ' if is_reminder else '', firstname=user.first_name, lastname=user.last_name, project=project.project_name, role=role_text) email_template = HtmlEmailTemplate()\ .subheader("Opportunity Information:")\ .text_line("Title: {role}".format(role=role_details.display_name))\ .text_line("Organization: {projectname}".format(projectname=project.project_name))\ .text_line("Date: {currentdate}".format(currentdate=datetime_to_string(timezone.now(), DateTimeFormats.MONTH_DD_YYYY)))\ .subheader("Volunteer Information:")\ .text_line("Name: {firstname} {lastname}".format( firstname=user.first_name, lastname=user.last_name))\ .text_line("Email: " + Html.a(href='mailto:' + user.email, text=user.email)) if user.postal_code: email_template = email_template.text_line("Zip: {zip}".format(zip=user.postal_code)) email_template = email_template.header_left("You Have a New Volunteer!")\ .paragraph('\"{message}\" -{firstname} {lastname}'.format( message=volunteer_relation.application_text, firstname=user.first_name, lastname=user.last_name))\ .paragraph('To contact this volunteer directly, you can reply to this email. To review their profile or approve their application, use the buttons below.')\ .button(url=project_profile_url, text='REVIEW VOLUNTEER')\ .button(url=approve_url, text='APPROVE VOLUNTEER') send_to_project_owners(project=project, sender=user, subject=email_subject, template=email_template)
def get_repo_endpoint_from_owner_repo_name(owner_repo_name, start_date=None): if len(owner_repo_name) > 1: url_base = '{github}/repos/{owner}/{repo}/commits'.format(github=github_api_endpoint, owner=owner_repo_name[0], repo=owner_repo_name[1]) if start_date is not None: return url_base + '?since=' + datetime_to_string(start_date, DateTimeFormats.UTC_DATETIME) else: return url_base
def get_repo_endpoint_from_owner_repo_name(owner_repo_name, start_date=None, branch=None): if len(owner_repo_name) > 1: url_base = '{github}/repos/{owner}/{repo}/commits'.format( github=github_api_endpoint, owner=owner_repo_name[0], repo=owner_repo_name[1]) params = {} if branch is not None: params['sha'] = branch if start_date is not None: params['since'] = datetime_to_string(start_date, DateTimeFormats.UTC_DATETIME) if params: url_base += '?' + urlparse.urlencode(params) return url_base
def notify_project_owners_volunteer_renewed_email(volunteer_relation, comments): email_template = notify_volunteer_renewed_email_with_comments if comments else notify_volunteer_renewed_email_no_comment project_name = volunteer_relation.project.project_name projected_end_date = datetime_to_string(datetime_field_to_datetime(volunteer_relation.projected_end_date), DateTimeFormats.DATE_LOCALIZED) volunteer_name = volunteer_relation.volunteer.full_name() context = { 'volunteer_name': volunteer_name, 'project_name': project_name, 'projected_end_date': projected_end_date, 'comments': comments } email_msg = EmailMessage( subject=volunteer_name + " has renewed their volunteer commitment with " + project_name, from_email=_get_account_from_email(settings.EMAIL_VOLUNTEER_ACCT), to=_get_co_owner_emails(volunteer_relation.project) ) email_msg = email_template.render(email_msg, context) send_email(email_msg, settings.EMAIL_VOLUNTEER_ACCT)