'Send approval or readiness mails, as appropriate.
If a given user is watching the Ready event and the revision
is in fact ready, say so. Otherwise, just send the Approval
email.'

def _mails(self, users_and_watches):

    revision = self._revision
    document = revision.document
    is_ready = revision.is_ready_for_localization
    log.debug(('Sending    approved/ready    notifications    for    revision    (id=%s)' % revision.id))
    @email_utils.safe_translation
    def _make_mail(locale, user, watches):
        if (is_ready and (ReadyRevisionEvent.event_type in (w.event_type for w in watches))):
            c = context_dict(revision, ready_for_l10n=True)
            c['watch'] = watches[0]
            url = reverse('wiki.translate', args=[document.slug], locale=locale)
            c['l10n_url'] = add_utm(url, 'wiki-ready-l10n')
            subject = _(u'{title}    has    a    revision    ready    for    localization')
            text_template = 'wiki/email/ready_for_l10n.ltxt'
            html_template = 'wiki/email/ready_for_l10n.html'
        else:
            c = context_dict(revision, revision_approved=True)
            approved_url = reverse('wiki.document', locale=document.locale, args=[document.slug])
            c['document_url'] = add_utm(approved_url, 'wiki-approved')
            c['watch'] = watches[0]
            c['reviewer'] = revision.reviewer
            subject = _(u'{title}    ({locale})    has    a    new    approved    revision    ({reviewer})')
            text_template = 'wiki/email/approved.ltxt'
            html_template = 'wiki/email/approved.html'
        subject = subject.format(title=document.title, reviewer=revision.reviewer.username, locale=document.locale)
        mail = email_utils.make_mail(subject=subject, text_template=text_template, html_template=html_template, context_vars=c, from_email=settings.TIDINGS_FROM_ADDRESS, to_email=user.email)
        return mail
    for (user, watches) in users_and_watches:
        if hasattr(user, 'profile'):
            locale = user.profile.locale
        else:
            locale = document.locale
        (yield _make_mail(locale, user, watches))
