Exemplo n.º 1
0
def send_submit_email_notification(request, compliance, is_test=False):
    from mooringlicensing.components.emails.utils import make_url_for_internal

    email = ComplianceSubmitSendNotificationEmail()
    url = request.build_absolute_uri(
        reverse('internal-compliance-detail',
                kwargs={'compliance_pk': compliance.id}))
    url = make_url_for_internal(url)

    context = {
        'compliance': compliance,
        'url': make_http_https(url),
        'public_url': get_public_url(request),
    }

    msg = email.send(compliance.proposal.assessor_recipients, context=context)
    if is_test:
        return

    sender = request.user if request else settings.DEFAULT_FROM_EMAIL
    _log_compliance_email(msg, compliance, sender=sender)
    if compliance.proposal.org_applicant:
        _log_org_email(msg,
                       compliance.proposal.org_applicant,
                       compliance.submitter,
                       sender=sender)
    else:
        _log_user_email(msg,
                        compliance.proposal.submitter,
                        compliance.submitter,
                        sender=sender)
Exemplo n.º 2
0
def send_internal_reminder_email_notification(compliance, is_test=False):
    from mooringlicensing.components.emails.utils import make_url_for_internal
    email = ComplianceInternalReminderNotificationEmail()
    url = settings.SITE_URL
    url += reverse('internal-compliance-detail',
                   kwargs={'compliance_pk': compliance.id})
    url = make_url_for_internal(url)

    context = {
        'compliance': compliance,
        'url': make_http_https(url),
        'public_url': get_public_url(),
    }

    msg = email.send(compliance.proposal.assessor_recipients, context=context)
    if is_test:
        return

    sender = settings.DEFAULT_FROM_EMAIL
    try:
        sender_user = EmailUser.objects.get(email__icontains=sender)
    except:
        sender_user = EmailUser.objects.create(email=sender, password='')
    _log_compliance_email(msg, compliance, sender=sender_user)
    if compliance.proposal.org_applicant:
        _log_org_email(msg,
                       compliance.proposal.org_applicant,
                       compliance.submitter,
                       sender=sender_user)
    else:
        _log_user_email(msg,
                        compliance.proposal.submitter,
                        compliance.submitter,
                        sender=sender)
Exemplo n.º 3
0
def send_organisation_request_link_email_notification(org_request, request,
                                                      contact):
    email = OrganisationRequestLinkNotificationEmail()

    url = request.build_absolute_uri(
        '/external/organisations/manage/{}'.format(org_request.id))

    context = {
        'request': org_request,
        'url': make_http_https(url),
    }

    msg = email.send(contact, context=context)
    sender = request.user if request else settings.DEFAULT_FROM_EMAIL
    _log_org_email(msg, org_request, request.user, sender=sender)
Exemplo n.º 4
0
def send_approval_expire_email_notification(approval):
    # if approval.is_lawful_authority:
    #     email = FilmingLawfulAuthorityApprovalExpireNotificationEmail()
    # if approval.is_filming_licence:
    #     email = FilmingLicenceApprovalExpireNotificationEmail()
    # else:
    #     email = ApprovalExpireNotificationEmail()
    email = ApprovalExpireNotificationEmail(approval)
    proposal = approval.current_proposal

    url = settings.SITE_URL if settings.SITE_URL else ''
    url += reverse('external')

    if "-internal" in url:
        # remove '-internal'. This email is for external submitters
        url = ''.join(url.split('-internal'))

    context = {
        'recipient': approval.submitter,
        'public_url': get_public_url(),
        'approval': approval,
        'proposal': proposal,
        'url': make_http_https(url),
    }
    all_ccs = []
    if proposal.org_applicant and proposal.org_applicant.email:
        cc_list = proposal.org_applicant.email
        if cc_list:
            all_ccs = [cc_list]
    msg = email.send(proposal.submitter.email, cc=all_ccs, context=context)
    sender = settings.DEFAULT_FROM_EMAIL
    try:
        sender_user = EmailUser.objects.get(email__icontains=sender)
    except:
        EmailUser.objects.create(email=sender, password='')
        sender_user = EmailUser.objects.get(email__icontains=sender)

    _log_approval_email(msg, approval, sender=sender_user)
    #_log_org_email(msg, approval.applicant, proposal.submitter, sender=sender_user)
    if approval.org_applicant:
        _log_org_email(msg, approval.org_applicant, proposal.submitter, sender=sender_user)
    else:
        _log_user_email(msg, approval.submitter, proposal.submitter, sender=sender_user)
Exemplo n.º 5
0
def send_amendment_email_notification(amendment_request,
                                      request,
                                      compliance,
                                      is_test=False):
    email = ComplianceAmendmentRequestSendNotificationEmail()
    #reason = amendment_request.get_reason_display()
    reason = amendment_request.reason.reason
    url = request.build_absolute_uri(
        reverse('external-compliance-detail',
                kwargs={'compliance_pk': compliance.id}))
    url = ''.join(url.split('-internal'))
    login_url = request.build_absolute_uri(reverse('external'))
    login_url = ''.join(login_url.split('-internal'))
    context = {
        'compliance': compliance,
        'reason': reason,
        'amendment_request_text': amendment_request.text,
        'url': make_http_https(url),
        'public_url': get_public_url(request),
    }

    submitter = compliance.submitter.email if compliance.submitter and compliance.submitter.email else compliance.proposal.submitter.email
    all_ccs = []
    if compliance.proposal.org_applicant and compliance.proposal.org_applicant.email:
        cc_list = compliance.proposal.org_applicant.email
        if cc_list:
            all_ccs = [cc_list]
    msg = email.send(submitter, cc=all_ccs, context=context)
    if is_test:
        return

    sender = request.user if request else settings.DEFAULT_FROM_EMAIL
    _log_compliance_email(msg, compliance, sender=sender)
    if compliance.proposal.org_applicant:
        _log_org_email(msg,
                       compliance.proposal.org_applicant,
                       compliance.submitter,
                       sender=sender)
    else:
        _log_user_email(msg,
                        compliance.proposal.submitter,
                        compliance.submitter,
                        sender=sender)
Exemplo n.º 6
0
def send_due_email_notification(compliance, is_test=False):
    email = ComplianceDueNotificationEmail()
    url = settings.SITE_URL
    url += reverse('external-compliance-detail',
                   kwargs={'compliance_pk': compliance.id})

    submitter = compliance.submitter if compliance.submitter and compliance.submitter.email else compliance.proposal.submitter

    context = {
        'recipient': submitter,
        'compliance': compliance,
        'due_date': compliance.due_date.strftime('%d/%m/%Y'),
        'external_compliance_url': make_http_https(url),
        'public_url': get_public_url(),
    }

    all_ccs = []
    if compliance.proposal.org_applicant and compliance.proposal.org_applicant.email:
        cc_list = compliance.proposal.org_applicant.email
        if cc_list:
            all_ccs = [cc_list]
    msg = email.send(submitter.email, cc=all_ccs, context=context)
    if is_test:
        return

    sender = settings.DEFAULT_FROM_EMAIL
    try:
        sender_user = EmailUser.objects.get(email__icontains=sender)
    except:
        sender_user = EmailUser.objects.create(email=sender,
                                               password='',
                                               is_staff=True)
    _log_compliance_email(msg, compliance, sender=sender_user)
    if compliance.proposal.org_applicant:
        _log_org_email(msg,
                       compliance.proposal.org_applicant,
                       compliance.submitter,
                       sender=sender_user)
    else:
        _log_user_email(msg,
                        compliance.proposal.submitter,
                        compliance.submitter,
                        sender=sender)
Exemplo n.º 7
0
def send_reminder_email_notification(compliance, is_test=False):
    """ Used by the management command, therefore have no request object - therefore explicitly defining base_url """
    email = ComplianceReminderNotificationEmail()
    url = settings.SITE_URL if settings.SITE_URL else ''
    url += reverse('external-compliance-detail',
                   kwargs={'compliance_pk': compliance.id})
    login_url = settings.SITE_URL if settings.SITE_URL else ''
    login_url += reverse('external')
    context = {
        'compliance': compliance,
        'url': make_http_https(url),
        'login_url': login_url,
        'public_url': get_public_url(),
    }

    submitter = compliance.submitter.email if compliance.submitter and compliance.submitter.email else compliance.proposal.submitter.email
    all_ccs = []
    if compliance.proposal.org_applicant and compliance.proposal.org_applicant.email:
        cc_list = compliance.proposal.org_applicant.email
        if cc_list:
            all_ccs = [cc_list]
    msg = email.send(submitter, cc=all_ccs, context=context)
    if is_test:
        return

    sender = settings.DEFAULT_FROM_EMAIL
    try:
        sender_user = EmailUser.objects.get(email__icontains=sender)
    except:
        sender_user = EmailUser.objects.create(email=sender,
                                               password='',
                                               is_staff=True)
    _log_compliance_email(msg, compliance, sender=sender_user)
    if compliance.proposal.org_applicant:
        _log_org_email(msg,
                       compliance.proposal.org_applicant,
                       compliance.submitter,
                       sender=sender_user)
    else:
        _log_user_email(msg,
                        compliance.proposal.submitter,
                        compliance.submitter,
                        sender=sender)
Exemplo n.º 8
0
def send_org_access_group_request_accept_email_notification(
        org_request, request, recipient_list):
    email = OrganisationAccessGroupRequestAcceptNotificationEmail()

    url = request.build_absolute_uri(
        '/internal/organisations/access/{}'.format(org_request.id))
    if "-internal" not in url:
        url = '-internal.{}'.format(settings.SITE_DOMAIN).join(
            url.split('.' + settings.SITE_DOMAIN))

    context = {
        'name': request.data.get('name'),
        'abn': request.data.get('abn'),
        'url': make_http_https(url),
    }

    msg = email.send(recipient_list, context=context)
    sender = request.user if request else settings.DEFAULT_FROM_EMAIL
    _log_org_request_email(msg, org_request, sender=sender)
Exemplo n.º 9
0
def send_organisation_request_email_notification(org_request, request,
                                                 contact):
    email = OrganisationRequestNotificationEmail()

    url = request.build_absolute_uri(
        '/internal/organisations/access/{}'.format(org_request.id))
    if "-internal" not in url:
        url = "{0}://{1}{2}.{3}{4}".format(request.scheme,
                                           settings.SITE_PREFIX, '-internal',
                                           settings.SITE_DOMAIN,
                                           url.split(request.get_host())[1])

    context = {
        'request': request.data,
        'url': make_http_https(url),
    }
    msg = email.send(contact, context=context)
    sender = request.user if request else settings.DEFAULT_FROM_EMAIL
    _log_org_request_email(msg, org_request, sender=sender)
Exemplo n.º 10
0
def send_vessel_nomination_reminder_mail(approval, request=None):
    # 10
    email = TemplateEmailBase(
        subject='First and Final Reminder: Vessel Requirements for {} - Rottnest Island Authority'.format(approval.description),
        html_template='mooringlicensing/emails_2/email_10.html',
        txt_template='mooringlicensing/emails_2/email_10.txt',
    )
    url = settings.SITE_URL if settings.SITE_URL else ''
    url = url + reverse('external')

    proposal = approval.current_proposal

    context = {
        'recipient': approval.submitter,
        'public_url': get_public_url(request),
        'approval': approval,
        'date_to_nominate_new_vessel': approval.current_proposal.vessel_ownership.end_date + relativedelta(months=+6),
        'dashboard_external_url': make_http_https(url),
    }

    sender = settings.DEFAULT_FROM_EMAIL
    try:
        sender_user = EmailUser.objects.get(email__icontains=sender)
    except:
        EmailUser.objects.create(email=sender, password='')
        sender_user = EmailUser.objects.get(email__icontains=sender)

    to_address = approval.submitter.email
    all_ccs = []
    bcc = []

    msg = email.send(to_address, context=context, attachments=[], cc=all_ccs, bcc=bcc,)

    _log_approval_email(msg, approval, sender=sender_user)
    if approval.org_applicant:
        _log_org_email(msg, approval.org_applicant, proposal.submitter, sender=sender_user)
    else:
        _log_user_email(msg, approval.submitter, proposal.submitter, sender=sender_user)

    return msg
Exemplo n.º 11
0
def send_external_submit_email_notification(request,
                                            compliance,
                                            is_test=False):
    email = ComplianceExternalSubmitSendNotificationEmail()
    url = request.build_absolute_uri(
        reverse('external-compliance-detail',
                kwargs={'compliance_pk': compliance.id}))
    url = ''.join(url.split('-internal'))
    submitter = compliance.submitter if compliance.submitter and compliance.submitter.email else compliance.proposal.submitter

    context = {
        'compliance': compliance,
        'recipient': submitter,
        'url': make_http_https(url),
        'due_date': compliance.due_date.strftime('%d/%m/%Y'),
        'public_url': get_public_url(request),
    }
    all_ccs = []
    if compliance.proposal.org_applicant and compliance.proposal.org_applicant.email:
        cc_list = compliance.proposal.org_applicant.email
        if cc_list:
            all_ccs = [cc_list]
    msg = email.send(submitter.email, cc=all_ccs, context=context)
    if is_test:
        return

    sender = request.user if request else settings.DEFAULT_FROM_EMAIL
    _log_compliance_email(msg, compliance, sender=sender)
    if compliance.proposal.org_applicant:
        _log_org_email(msg,
                       compliance.proposal.org_applicant,
                       compliance.submitter,
                       sender=sender)
    else:
        _log_user_email(msg,
                        compliance.proposal.submitter,
                        compliance.submitter,
                        sender=sender)