def topup_requested_email(email, user, topup): from enterprise.libs.email import send_mail from django.conf import settings subject_template_name = 'home/email/topup_requested.txt' html_email_template_name = 'home/email/topup_requested.html' email_template_name = html_email_template_name profile = user.get_profile() show_bank_account = False if profile.approved_at and profile.type == 2: show_bank_account = True context = { 'name': user.full_name, 'amount': topup.get_formatted_amount(), 'show_bank_account': show_bank_account, 'link': '%saccount/wallet/topup/?inv=%s' % (settings.BASE_URL, topup.invoice.number) } send_mail(subject_template_name, email_template_name, html_email_template_name, context, email)
def funding_sent_email(request, email, user): # from enterprise.libs.email import send_mail from django.conf import settings from enterprise.libs.email import send_mail subject_template_name = 'home/email/funding_sent.txt' html_email_template_name = 'home/email/funding_sent.html' email_template_name = html_email_template_name # pdf = PA_pdf(request, user) context = { 'name': user.full_name, } filename = "{date}-{name}-pa.pdf".format( date=date.today(), name=user.full_name, ) # send_mail_with_attachment( # subject_template_name, # email_template_name, # html_email_template_name, # context, # email, # pdf, # filename # ) send_mail(subject_template_name, email_template_name, html_email_template_name, context, email)
def application_submit_email(email, user): from enterprise.libs.email import send_mail from django.conf import settings subject_template_name = 'home/email/application_submit.txt' html_email_template_name = 'home/email/application_submit.html' email_template_name = html_email_template_name context = {'name': user.full_name} send_mail(subject_template_name, email_template_name, html_email_template_name, context, email)
def account_submission_complete_email(email, user): from enterprise.libs.email import send_mail from django.conf import settings subject_template_name = 'home/email/account_submission_complete.txt' html_email_template_name = 'home/email/account_submission_complete.html' email_template_name = html_email_template_name context = {'name': user.full_name} send_mail(subject_template_name, email_template_name, html_email_template_name, context, email)
def account_rejected_email(email, user, reason): from enterprise.libs.email import send_mail from django.conf import settings subject_template_name = 'home/email/account_rejected.txt' html_email_template_name = 'home/email/account_rejected.html' email_template_name = html_email_template_name context = {'name': user.full_name, 'reason': reason} send_mail(subject_template_name, email_template_name, html_email_template_name, context, email)
def application_approved_email(request, project): from enterprise.libs.email import send_mail from django.conf import settings subject_template_name = 'home/email/application_approved.txt' html_email_template_name = 'home/email/application_approved.html' email_template_name = html_email_template_name email = project.owned_by.email context = {'name': project.owned_by.full_name} send_mail(subject_template_name, email_template_name, html_email_template_name, context, email) offer_letter_email(request, project)
def withdraw_rejected_email(email, user, withdraw): from enterprise.libs.email import send_mail from django.conf import settings subject_template_name = 'home/email/withdraw_rejected.txt' html_email_template_name = 'home/email/withdraw_rejected.html' email_template_name = html_email_template_name context = { 'name': user.full_name, 'amount': withdraw.get_formatted_amount(), } send_mail(subject_template_name, email_template_name, html_email_template_name, context, email)
def topup_approved_email(email, user, topup): from enterprise.libs.email import send_mail from django.conf import settings subject_template_name = 'home/email/topup_approved.txt' html_email_template_name = 'home/email/topup_approved.html' email_template_name = html_email_template_name context = { 'name': user.full_name, 'amount': topup.get_formatted_amount(), } send_mail(subject_template_name, email_template_name, html_email_template_name, context, email)
def application_disbursed_email(email, cc, project): from enterprise.libs.email import send_mail from django.conf import settings subject_template_name = 'home/email/application_disburse.txt' html_email_template_name = 'home/email/application_disburse.html' email_template_name = html_email_template_name context = {'project': project} send_mail(subject_template_name, email_template_name, html_email_template_name, context, email, cc=cc)
def repayment_email(email, cc, payment): from enterprise.libs.email import send_mail from django.conf import settings subject_template_name = 'home/email/repayment.txt' html_email_template_name = 'home/email/repayment.html' email_template_name = html_email_template_name context = { 'payment': payment, 'project': payment.project, } send_mail(subject_template_name, email_template_name, html_email_template_name, context, email, cc=cc)
def send_email_verification(self, user, subject_template_name, html_email_template_name, custom_context): email_template_name = html_email_template_name code = generate_otp_code(OTP_CODE_LENGTH) code_hash = str(uuid.uuid4()) base_url = getattr(settings, "BASE_URL") frontend_base_url = (getattr(settings, "FRONTEND_BASE_URL") if hasattr( settings, "FRONTEND_BASE_URL") else base_url) # remove unverified record EmailVerification.objects.filter(user=user, is_verified=False).delete() if not code: code = str(uuid) email_verif = EmailVerification.objects.create(code=code, code_hash=code_hash, user=user, is_verified=False) # sending email here email = email_verif.user.email context = { "code": code, "code_hash": code_hash, "name": user.full_name, "base_url": base_url, "frontend_base_url": frontend_base_url, **custom_context, } send_mail( subject_template_name, email_template_name, html_email_template_name, context, email, cc=getattr(settings, "MAIL_NOTIFICATION_CC", []), ) return email_verif, {"code": code, "code_hash": code_hash}
def send_verification_email(email, user, length=6, base_url=None, *args, **kwargs): from enterprise.libs.email import send_mail from django.conf import settings subject_template_name = "email/email_verify.txt" html_email_template_name = "email/email_verify.html" email_template_name = html_email_template_name code = str(randint(10**(length - 1), (10**(length) - 1))) if not base_url: base_url = getattr(settings, 'BASE_URL') url = code if kwargs: params = ''.join(['&%s=%s' % (k, v) for k, v in kwargs.items()]) url += params context = {"url": url, "name": user.full_name} send_mail(subject_template_name, email_template_name, html_email_template_name, context, email, cc=getattr(settings, "MAIL_NOTIFICATION_CC", [])) ev, created = EmailVerification.objects.get_or_create(email=email) ev.code = code ev.is_verified = False ev.save() return ev