Esempio n. 1
0
def send_admin_review_email(job, sender=None):
    """Sends a notification to the admin to review the new/updated job listing.

    :param job: A `Job` instance.
    :param sender: The A string (of length 10) to attach to the email sender.

    """
    recipient = settings.MAIL_ADMIN_RECIPIENT

    probable_update = job.created + timedelta(minutes=5) < now()
    new_or_update = 'newly updated' if probable_update else 'brand new'

    # Some copy-paste convenience in the email...
    script_path = os.path.join(settings.ROOT, 'scripts', 'management')

    context = {
        'job': job,
        'html2text': html2text,
        'new_or_update': new_or_update,
        'script_path': script_path
    }

    if sender is None:
        sender = DEFAULT_SENDER

    logger.info(u"Sending admin review email for job listing ({}).".format(job.id))
    send_email_template('review', context, [recipient], sender=sender)
Esempio n. 2
0
def send_admin_review_email(job, sender=None):
    """Sends a notification to the admin to review the new/updated job listing.

    :param job: A `Job` instance.
    :param sender: The A string (of length 10) to attach to the email sender.

    """
    recipient = settings.MAIL_ADMIN_RECIPIENT

    probable_update = job.created + timedelta(minutes=5) < now()
    new_or_update = 'newly updated' if probable_update else 'brand new'

    # Some copy-paste convenience in the email...
    script_path = os.path.join(settings.ROOT, 'scripts', 'management')

    context = {
        'job': job,
        'html2text': html2text,
        'new_or_update': new_or_update,
        'script_path': script_path
    }

    if sender is None:
        sender = DEFAULT_SENDER

    logger.info(u"Sending admin review email for job listing ({}).".format(
        job.id))
    send_email_template('review', context, [recipient], sender=sender)
Esempio n. 3
0
def test_send_email_template(app, template, monkeypatch):
    mock = MagicMock()
    monkeypatch.setattr('jobber.core.email.send_email', mock)

    name = template(['subject', 'text'])
    recipients = ['*****@*****.**']

    send_email_template(name, {'var': 'foo'}, recipients)
    mock.assert_called_with('test foo', 'test foo', None,
                            recipients, sender=DEFAULT_SENDER)
Esempio n. 4
0
def send_instructory_email(job):
    """Sends an email to the recruiter with instruction on how to do things.

    :param job: A `Job` instance.

    """
    recipient = job.recruiter_email
    context = {'job': job, 'default_sender': DEFAULT_SENDER}
    logger.info(u"Sending instructory email to '{}' "
                "for job listing ({}).".format(recipient, job.id))
    send_email_template('instructory', context, [recipient])
Esempio n. 5
0
def send_confirmation_email(job):
    """Sends an email to the recruiter, confirming that the job has been reviewed,
    accepted and published.

    :param job: A `Job` instance.

    """
    recipient = job.recruiter_email
    context = {'job': job, 'default_sender': DEFAULT_SENDER}
    logger.info(u"Sending confirmation email to '{}' "
                "for job listing ({}).".format(recipient, job.id))
    send_email_template('confirmation', context, [recipient])
Esempio n. 6
0
def test_send_email_template(app, template, monkeypatch):
    mock = MagicMock()
    monkeypatch.setattr('jobber.core.email.send_email', mock)

    name = template(['subject', 'text'])
    recipients = ['*****@*****.**']

    send_email_template(name, {'var': 'foo'}, recipients)
    mock.assert_called_with('test foo',
                            'test foo',
                            None,
                            recipients,
                            sender=DEFAULT_SENDER)
Esempio n. 7
0
def send_instructory_email(job):
    """Sends an email to the recruiter with instruction on how to do things.

    :param job: A `Job` instance.

    """
    recipient = job.recruiter_email
    context = {
        'job': job,
        'default_sender': DEFAULT_SENDER
    }
    logger.info(u"Sending instructory email to '{}' "
                    "for job listing ({}).".format(recipient, job.id))
    send_email_template('instructory', context, [recipient])
Esempio n. 8
0
def send_confirmation_email(job):
    """Sends an email to the recruiter, confirming that the job has been reviewed,
    accepted and published.

    :param job: A `Job` instance.

    """
    recipient = job.recruiter_email
    context = {
        'job': job,
        'default_sender': DEFAULT_SENDER
    }
    logger.info(u"Sending confirmation email to '{}' "
                "for job listing ({}).".format(recipient, job.id))
    send_email_template('confirmation', context, [recipient])