def new_feedback(email, feedback): to_email = settings.PERSONAL_CONTACT_EMAIL from_email = settings.SERVER_EMAIL subject = "New Feedback" body = f"New feedback from {email}: {feedback}" if not should_suppress_notification_email(to_email, 'admin'): send_mail( from_email, to_email, subject, body, from_name="No Reply from Gitcoin.co", categories=['admin', func_name()], )
def gdpr_reconsent(email): to_email = email from_email = settings.PERSONAL_CONTACT_EMAIL subject = "Would you still like to receive email from Gitcoin?" html, text = render_gdpr_reconsent(to_email) send_mail( from_email, to_email, subject, text, html, from_name="Kevin Owocki (Gitcoin.co)", categories=['marketing', func_name()], )
def share_bounty(emails, msg, profile, invite_url=None, kudos_invite=False): for email in emails: to_email = email from_email = settings.CONTACT_EMAIL subject = f"@{profile.handle} invited you to to work on a bounty." html, text = render_share_bounty(to_email, msg, profile, invite_url, kudos_invite) send_mail( from_email, to_email, subject, text, html, from_name=f"@{profile.handle}", categories=['transactional', func_name()], )
def share_bounty(emails, msg, profile, invite_url=None, kudos_invite=False): for email in emails: to_email = email from_email = profile.email subject = "You have been invited to work on a bounty." html, text = render_share_bounty(to_email, msg, profile, invite_url, kudos_invite) send_mail( from_email, to_email, subject, text, html, from_name=f"@{profile.handle}", categories=['transactional', func_name()], )
def new_reserved_issue(from_email, user, bounty): to_email = user.email cur_language = translation.get_language() try: setup_lang(to_email) html, text, subject = render_reserved_issue(to_email, user, bounty) if not should_suppress_notification_email(to_email, 'bounty'): send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) finally: translation.activate(cur_language)
def no_applicant_reminder(to_email, bounty): from_email = settings.SERVER_EMAIL subject = "Get more applicants on your bounty" html, text = render_no_applicant_reminder(bounty=bounty) try: send_mail( from_email, to_email, subject, text, html, from_name="No Reply from Gitcoin.co", categories=['marketing', func_name()], ) except Exception as e: logger.warning(e) return False return True
def featured_funded_bounty(from_email, bounty): to_email = bounty.bounty_owner_email cur_language = translation.get_language() try: setup_lang(to_email) html, text, subject = render_featured_funded_bounty(bounty) if not should_suppress_notification_email(to_email, 'featured_funded_bounty'): send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) finally: translation.activate(cur_language)
def start_work_approved(interest, bounty): from_email = settings.CONTACT_EMAIL to_email = interest.profile.email cur_language = translation.get_language() try: setup_lang(to_email) html, text, subject = render_start_work_approved(interest, bounty) if not should_suppress_notification_email(to_email, 'bounty'): send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) finally: translation.activate(cur_language)
def reject_faucet_request(fr): from_email = settings.SERVER_EMAIL subject = _("Faucet Request Rejected") to_email = fr.email cur_language = translation.get_language() try: setup_lang(to_email) html, text = render_faucet_rejected(fr) if not should_suppress_notification_email(to_email, 'faucet'): send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) finally: translation.activate(cur_language)
def bounty_uninterested(to_email, bounty, interest): from_email = settings.CONTACT_EMAIL cur_language = translation.get_language() try: setup_lang(to_email) html, text = render_bounty_unintersted(to_email, bounty, interest) subject = "Funder has removed you from the task: '{}' ? ".format( bounty.title_or_desc) if not should_suppress_notification_email(to_email, 'bounty'): send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) finally: translation.activate(cur_language)
def new_supporter(grant, subscription): from_email = settings.CONTACT_EMAIL to_email = grant.admin_profile.email cur_language = translation.get_language() try: setup_lang(to_email) html, text, subject = render_new_supporter_email(grant, subscription) if not should_suppress_notification_email(to_email, 'new_supporter'): send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) finally: translation.activate(cur_language)
def change_grant_owner_reject(grant, profile): from_email = settings.CONTACT_EMAIL to_email = profile.email cur_language = translation.get_language() try: setup_lang(to_email) html, text, subject = render_change_grant_owner_reject(grant) if not should_suppress_notification_email(to_email, 'change_owner'): send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) finally: translation.activate(cur_language)
def warn_subscription_failed(subscription): to_email = settings.PERSONAL_CONTACT_EMAIL from_email = settings.SERVER_EMAIL cur_language = translation.get_language() try: setup_lang(to_email) subject = str(subscription.pk) + str(_(" subscription failed")) body = f"{settings.BASE_URL}{subscription.admin_url }\n{subscription.contributor_profile.email}, {subscription.contributor_profile.user.email}<pre>\n\n{subscription.subminer_comments}</pre>" if not should_suppress_notification_email(to_email, 'admin'): send_mail( from_email, to_email, subject, body, from_name=_("No Reply from Gitcoin.co"), categories=['admin', func_name()], ) finally: translation.activate(cur_language)
def new_token_request(obj): to_email = '*****@*****.**' from_email = obj.email cur_language = translation.get_language() try: setup_lang(to_email) subject = _("New Token Request") body_str = _("A new token request was completed. You may fund the token request here") body = f"{body_str}: https://gitcoin.co/{obj.admin_url} \n\n {obj.email}" if not should_suppress_notification_email(to_email, 'faucet'): send_mail( from_email, to_email, subject, body, from_name=_("No Reply from Gitcoin.co"), categories=['admin', func_name()], ) finally: translation.activate(cur_language)
def new_faucet_request(fr): to_email = settings.PERSONAL_CONTACT_EMAIL from_email = settings.SERVER_EMAIL cur_language = translation.get_language() try: setup_lang(to_email) subject = _("New Faucet Request") body_str = _("A new faucet request was completed. You may fund the request here") body = f"{body_str}: https://gitcoin.co/_administration/process_faucet_request/{fr.pk}" if not should_suppress_notification_email(to_email, 'faucet'): send_mail( from_email, to_email, subject, body, from_name=_("No Reply from Gitcoin.co"), categories=['admin', func_name()], ) finally: translation.activate(cur_language)
def send_personal_token_created(profile, ptoken): from_email = settings.CONTACT_EMAIL to_email = profile.email cur_language = translation.get_language() try: setup_lang(to_email) html, text, subject = render_ptoken_created(ptoken) if not should_suppress_notification_email(to_email, 'personal_token_created'): send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) finally: translation.activate(cur_language)
def new_quest_request(quest): to_email = settings.PERSONAL_CONTACT_EMAIL from_email = settings.SERVER_EMAIL cur_language = translation.get_language() try: setup_lang(to_email) subject = _("New Quest Request") body_str = _("A new quest request was completed. You may respond to the request here") body = f"{body_str}: {settings.BASE_URL}{quest.admin_url}" if not should_suppress_notification_email(to_email, 'quest'): send_mail( from_email, to_email, subject, body, from_name=_("No Reply from Gitcoin.co"), categories=['admin', func_name()], ) finally: translation.activate(cur_language)
def warn_subscription_failed(subscription, txid, status, error): to_email = settings.SERVER_EMAIL from_email = settings.SERVER_EMAIL cur_language = translation.get_language() try: setup_lang(to_email) subject = str(subscription.pk) + str(_(" subscription failed")) body_str = _("is down to ") body = f"{subscription.pk } {txid} {status} {error}" if not should_suppress_notification_email(to_email, 'admin'): send_mail( from_email, to_email, subject, body, from_name=_("No Reply from Gitcoin.co"), categories=['admin', func_name()], ) finally: translation.activate(cur_language)
def new_external_bounty(): """Send a new external bounty email notification.""" to_email = settings.PERSONAL_CONTACT_EMAIL from_email = settings.SERVER_EMAIL cur_language = translation.get_language() try: setup_lang(to_email) subject = _("New External Bounty") body = f"https://gitcoin.co/_administrationexternal_bounties/externalbounty" if not should_suppress_notification_email(to_email, 'admin'): send_mail( from_email, to_email, subject, body, from_name=_("No Reply from Gitcoin.co"), categories=['admin', func_name()], ) finally: translation.activate(cur_language)
def warn_account_out_of_eth(account, balance, denomination): to_email = settings.PERSONAL_CONTACT_EMAIL from_email = settings.SERVER_EMAIL cur_language = translation.get_language() try: setup_lang(to_email) subject = account + str(_(" is out of gas")) body_str = _("is down to ") body = f"{account } {body_str} {balance} {denomination}" if not should_suppress_notification_email(to_email, 'admin'): send_mail( from_email, to_email, subject, body, from_name=_("No Reply from Gitcoin.co"), categories=['admin', func_name()], ) finally: translation.activate(cur_language)
def new_quest_approved(quest): to_email = quest.creator.email from_email = settings.PERSONAL_CONTACT_EMAIL cur_language = translation.get_language() try: setup_lang(to_email) subject = _("Your Quest is live on Gitcoin.co/quests") body_str = _("Your quest has been approved and is now live at") body = f"{body_str}: {settings.BASE_URL}{quest.url}" if not should_suppress_notification_email(to_email, 'quest'): send_mail( from_email, to_email, subject, body, from_name=_("No Reply from Gitcoin.co"), categories=['admin', func_name()], ) finally: translation.activate(cur_language)
def funder_stale(to_email, github_username, days=30, time_as_str='about a month'): from_email = settings.PERSONAL_CONTACT_EMAIL cur_language = translation.get_language() try: setup_lang(to_email) subject = "hey from gitcoin.co" if not github_username else f"hey @{github_username}" __, text = render_funder_stale(github_username, days, time_as_str) cc_emails = [from_email, '*****@*****.**', '*****@*****.**', '*****@*****.**'] if not should_suppress_notification_email(to_email, 'admin_contact_funder'): send_mail( from_email, to_email, subject, text, cc_emails=cc_emails, from_name=from_email, categories=['transactional', func_name()], ) finally: translation.activate(cur_language)
def successful_contribution(grant, subscription, contribution): from_email = settings.CONTACT_EMAIL to_email = subscription.contributor_profile.email cur_language = translation.get_language() try: setup_lang(to_email) html, text, subject = render_successful_contribution_email( grant, subscription, contribution) if not should_suppress_notification_email(to_email, 'successful_contribution'): send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) finally: translation.activate(cur_language)
def funder_payout_reminder(to_email, bounty, github_username, live): from_email = settings.PERSONAL_CONTACT_EMAIL subject = "Payout reminder" html, text = render_funder_payout_reminder(to_email=to_email, bounty=bounty, github_username=github_username) if (live): try: send_mail( from_email, to_email, subject, text, html, from_name="Kevin Owocki (Gitcoin.co)", categories=['marketing', func_name()], ) except Exception as e: logger.warning(e) return False return True else: return html
def admin_contact_funder(bounty, text, from_user): from_email = from_user.email to_email = bounty.bounty_owner_email cur_language = translation.get_language() try: setup_lang(to_email) subject = bounty.url __, text = render_admin_contact_funder(bounty, text, from_user) cc_emails = [from_email] if not should_suppress_notification_email(to_email, 'admin_contact_funder'): send_mail( from_email, to_email, subject, text, cc_emails=cc_emails, from_name=from_email, categories=['transactional', func_name()], ) finally: translation.activate(cur_language)
def bounty_feedback(bounty, persona='fulfiller', previous_bounties=None): from_email = '*****@*****.**' to_email = None cur_language = translation.get_language() if previous_bounties is None: previous_bounties = [] try: setup_lang(to_email) if persona == 'fulfiller': accepted_fulfillments = bounty.fulfillments.filter(accepted=True) to_email = accepted_fulfillments.first( ).fulfiller_email if accepted_fulfillments.exists() else "" elif persona == 'funder': to_email = bounty.bounty_owner_email if not to_email: if bounty.bounty_owner_profile: to_email = bounty.bounty_owner_profile.email if not to_email: if bounty.bounty_owner_profile and bounty.bounty_owner_profile.user: to_email = bounty.bounty_owner_profile.user.email if not to_email: return subject = bounty.github_url __, text = render_bounty_feedback(bounty, persona, previous_bounties) cc_emails = [from_email, '*****@*****.**'] if not should_suppress_notification_email(to_email, 'bounty_feedback'): send_mail( from_email, to_email, subject, text, cc_emails=cc_emails, from_name="Alisa March (Gitcoin.co)", categories=['transactional', func_name()], ) finally: translation.activate(cur_language)
def new_match(to_emails, bounty, github_username): subject = gettext("⚡️ {} Meet {}: {}! ").format(github_username.title(), bounty.org_name.title(), bounty.title) to_email = to_emails[0] cur_language = translation.get_language() try: setup_lang(to_email) from_email = settings.CONTACT_EMAIL html, text = render_match_email(bounty, github_username) if not should_suppress_notification_email(to_email, 'bounty_match'): send_mail( from_email, to_email, subject, text, html, cc_emails=to_emails, categories=['transactional', func_name()], ) finally: translation.activate(cur_language)
def gdpr_update(to_emails=None): if to_emails is None: to_emails = [] for to_email in to_emails: cur_language = translation.get_language() try: setup_lang(to_email) html, text, subject = render_gdpr_update(to_email) from_email = settings.PERSONAL_CONTACT_EMAIL if not should_suppress_notification_email(to_email, 'roundup'): send_mail( from_email, to_email, subject, text, html, from_name="Kevin Owocki (Gitcoin.co)", categories=['marketing', func_name()], ) finally: translation.activate(cur_language)
def bounty_startwork_expired(to_email, bounty, interest, time_delta_days): if not bounty or not bounty.value_in_usdt_now: return cur_language = translation.get_language() try: setup_lang(to_email) from_email = settings.CONTACT_EMAIL html, text = render_bounty_startwork_expire_warning( to_email, bounty, interest, time_delta_days) subject = gettext("We've removed you from the task: '{}' ? ").format( bounty.title_or_desc) if not should_suppress_notification_email(to_email, 'bounty_expiration'): send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) finally: translation.activate(cur_language)
def bounty_expire_warning(bounty, to_emails=None): if not bounty or not bounty.value_in_usdt_now: return if to_emails is None: to_emails = [] for to_email in to_emails: cur_language = translation.get_language() try: setup_lang(to_email) unit = _('day') num = int(round((bounty.expires_date - timezone.now()).days, 0)) if num == 0: unit = _('hour') num = int( round((bounty.expires_date - timezone.now()).seconds / 3600 / 24, 0)) unit = unit + ("s" if num != 1 else "") subject = gettext( "😕 Your Funded Issue ({}) Expires In {} {} ... 😕").format( bounty.title_or_desc, num, unit) from_email = settings.CONTACT_EMAIL html, text = render_bounty_expire_warning(to_email, bounty) if not should_suppress_notification_email(to_email, 'bounty_expiration'): send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) finally: translation.activate(cur_language)