def new_feedback(email, feedback): to_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 weekly_roundup(to_emails=[]): subject = "Gitcoin.co + CodeSponsor.io = 🔥" for to_email in to_emails: html, text = render_new_bounty_roundup(to_email) from_email = settings.PERSONAL_CONTACT_EMAIL if not should_suppress_notification_email(to_email): send_mail(from_email, to_email, subject, text, html, from_name="Kevin Owocki (Gitcoin.co)")
def weekly_roundup(to_emails=[]): subject = "⚡️ Refer a Friend get ETH (bonus: Pilot Projects update)" for to_email in to_emails: html, text = render_new_bounty_roundup(to_email) from_email = settings.PERSONAL_CONTACT_EMAIL if not should_suppress_notification_email(to_email): send_mail(from_email, to_email, subject, text, html, from_name="Kevin Owocki (Gitcoin.co)")
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 weekly_roundup(to_emails=[]): subject = "Gitcoin Weekly | Gitcoin Now Easily Integrates w. Github - Chrome Extension Enters Beta" for to_email in to_emails: html, text = render_new_bounty_roundup(to_email) from_email = settings.PERSONAL_CONTACT_EMAIL if not should_suppress_notification_email(to_email): send_mail(from_email, to_email, subject, text, html, from_name="Kevin Owocki (Gitcoin.co)")
def new_bounty(bounty, to_emails=None): if not bounty or not bounty.value_in_usdt: return if to_emails is None: to_emails = [] subject = "⚡️ New Funded Issue Match worth ${} ({})".format(bounty.value_in_usdt, bounty.keywords) for to_email in to_emails: from_email = settings.CONTACT_EMAIL html, text = render_new_bounty(to_email, bounty) if not should_suppress_notification_email(to_email): send_mail(from_email, to_email, subject, text, html)
def new_supporter(grant, subscription): from_email = settings.CONTACT_EMAIL to_email = grant.admin_profile.email if not to_email: to_email = grant.admin_profile.user.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 new_bounty_rejection(bounty, to_emails=None): if not bounty or not bounty.value_in_usdt: return if to_emails is None: to_emails = [] subject = "😕 Fulfillment Rejected for {} 😕".format(bounty.title_or_desc) for to_email in to_emails: from_email = settings.CONTACT_EMAIL html, text = render_new_bounty_rejection(to_email, bounty) if not should_suppress_notification_email(to_email): send_mail(from_email, to_email, subject, text, html)
def new_work_submission(bounty, to_emails=None): if not bounty or not bounty.value_in_usdt: return if to_emails is None: to_emails = [] subject = "✉️ New Work Submission Inside for {} ✉️".format(bounty.title_or_desc) for to_email in to_emails: from_email = settings.CONTACT_EMAIL html, text = render_new_work_submission(to_email, bounty) if not should_suppress_notification_email(to_email): send_mail(from_email, to_email, subject, text, html)
def new_bounty_acceptance(bounty, to_emails=None): if not bounty or not bounty.value_in_usdt: return if to_emails is None: to_emails = [] subject = "🌈 Funds Paid for {} 🌈".format(bounty.title_or_desc) for to_email in to_emails: from_email = settings.CONTACT_EMAIL html, text = render_new_bounty_acceptance(to_email, bounty) if not should_suppress_notification_email(to_email): send_mail(from_email, to_email, subject, text, html)
def thank_you_for_supporting(grant, subscription): from_email = settings.CONTACT_EMAIL to_email = subscription.contributor_profile.email if not to_email: to_email = subscription.contributor_profile.user.email cur_language = translation.get_language() try: setup_lang(to_email) html, text, subject = render_thank_you_for_supporting_email(grant, subscription) if not should_suppress_notification_email(to_email, 'thank_you_for_supporting'): send_mail(from_email, to_email, subject, text, html, 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)") finally: translation.activate(cur_language)
def weekly_roundup(to_emails=None): if to_emails is None: to_emails = [] subject = "Gitcoin + Standard Bounties = 🔥" for to_email in to_emails: html, text = render_new_bounty_roundup(to_email) from_email = settings.PERSONAL_CONTACT_EMAIL if not should_suppress_notification_email(to_email): send_mail(from_email, to_email, subject, text, html, from_name="Kevin Owocki (Gitcoin.co)")
def weekly_roundup(to_emails=None): if to_emails is None: to_emails = [] subject = "Gitcoin Weekly | Product Designer Alisa March Joins the Team" for to_email in to_emails: html, text = render_new_bounty_roundup(to_email) from_email = settings.PERSONAL_CONTACT_EMAIL if not should_suppress_notification_email(to_email): send_mail(from_email, to_email, subject, text, html, from_name="Kevin Owocki (Gitcoin.co)")
def new_bounty(bounty, to_emails=None): if not bounty or not bounty.value_in_usdt: return if to_emails is None: to_emails = [] subject = f"⚡️ New Funded Issue Match worth {bounty.value_in_usdt} USD @ " \ f"${convert_token_to_usdt(bounty.token_name)}/{bounty.token_name} {bounty.keywords})" for to_email in to_emails: from_email = settings.CONTACT_EMAIL html, text = render_new_bounty(to_email, bounty) if not should_suppress_notification_email(to_email): send_mail(from_email, to_email, subject, text, html)
def new_bounty_rejection(bounty, to_emails=None): if not bounty or not bounty.value_in_usdt_now: return subject = gettext("😕 Work Submission Rejected for {} 😕").format( bounty.title_or_desc) if to_emails is None: to_emails = [] for to_email in to_emails: from_email = settings.CONTACT_EMAIL html, text = render_new_bounty_rejection(to_email, bounty) if not should_suppress_notification_email(to_email): send_mail(from_email, to_email, subject, text, html)
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")) 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")) finally: translation.activate(cur_language)
def bounty_startwork_expire_warning(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("Are you still working on '{}' ? ").format( bounty.title_or_desc) if not should_suppress_notification_email(to_email, 'transactional'): send_mail(from_email, to_email, subject, text, html) finally: translation.activate(cur_language)
def start_work_rejected(interest, bounty): from_email = settings.CONTACT_EMAIL to_email = interest.profile.email if not to_email: if interest.profile and interest.profile.user: to_email = interest.profile.user.email if not to_email: return cur_language = translation.get_language() try: setup_lang(to_email) html, text, subject = render_start_work_rejected(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 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 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_new_applicant(interest, bounty): from_email = settings.CONTACT_EMAIL to_email = bounty.bounty_owner_email cur_language = translation.get_language() try: setup_lang(to_email) html, text, subject = render_start_work_new_applicant(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 change_grant_owner_reject(grant, profile): from_email = settings.CONTACT_EMAIL to_email = profile.email if not to_email: if profile and profile.user: to_email = profile.user.email if not to_email: return 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 bounty_expire_warning(bounty, to_emails=[]): if not bounty or not bounty.value_in_usdt: return for to_email in to_emails: 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 = "😕 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): send_mail(from_email, to_email, subject, text, html)
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 new_token_request(obj): to_email = settings.PERSONAL_CONTACT_EMAIL from_email = settings.SERVER_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")) 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 bounty_feedback(bounty, persona='fulfiller', previous_bounties=[]): from_email = settings.PERSONAL_CONTACT_EMAIL to_email = None cur_language = translation.get_language() 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 subject = bounty.github_url html, 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="Kevin Owocki (Gitcoin.co)") 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)