Esempio n. 1
0
def send_invite_notification(sender, email, link):
    message_text = _(
        ("Hey %(email)s,%(sender)s has invited you to connect on Fidus "
         "Writer. "
         "\nAccept or reject the invite through this link: %(link)s")) % {
             "sender": sender,
             "email": email,
             "link": link,
         }
    body_html_intro = _(("<p>Hey %(email)s,<br> %(sender)s has "
                         "invited you to connect on Fidus Writer.</p>")) % {
                             "sender": sender,
                             "email": email,
                             "link": link,
                         }

    body_html = ("<h1>%(invite)s</h1>"
                 "%(body_html_intro)s"
                 '<div class="actions"><a class="button" href="%(link)s">'
                 "%(Accept)s"
                 "</a></div>") % {
                     "invite": _("Invite for Fidus Writer"),
                     "body_html_intro": body_html_intro,
                     "link": link,
                     "Accept":
                     _("Sign up/log in and accept/reject the invite"),
                 }
    send_mail(
        _("Fidus Writer contact invite"),
        message_text,
        settings.DEFAULT_FROM_EMAIL,
        [email],
        fail_silently=True,
        html_message=html_email(body_html),
    )
Esempio n. 2
0
def send_accept_notification(recipient_name, recipient_email, sender_name,
                             link):
    message_text = _(
        ("Hey %(recipient_name)s, %(sender_name)s has accepted your invite to "
         "connect on Fidus Writer. "
         "\nSee your list of contacts here: %(link)s")) % {
             "recipient_name": recipient_name,
             "sender_name": sender_name,
             "link": link,
         }
    body_html_intro = _(
        ("<p>Hey %(recipient_name)s,<br> %(sender_name)s has "
         "accepted your invite to connect on Fidus Writer.</p>")) % {
             "recipient_name": recipient_name,
             "sender_name": sender_name,
         }

    body_html = ("<h1>%(invite)s</h1>"
                 "%(body_html_intro)s"
                 '<div class="actions"><a class="button" href="%(link)s">'
                 "%(LinkText)s"
                 "</a></div>") % {
                     "invite": _("Invite for Fidus Writer accepted"),
                     "body_html_intro": body_html_intro,
                     "link": link,
                     "LinkText": _("See your list of contacts"),
                 }
    send_mail(
        _("Fidus Writer invite accepted"),
        message_text,
        settings.DEFAULT_FROM_EMAIL,
        [recipient_email],
        fail_silently=True,
        html_message=html_email(body_html),
    )
Esempio n. 3
0
def send_share_notification(
    document_title,
    owner,
    link,
    collaborator_name,
    collaborator_email,
    rights,
    change,
):

    if len(document_title) == 0:
        document_title = _("Untitled")
    if change:
        message_text = _(
            ("Hey %(collaborator_name)s,\n%(owner)s has changed your access "
             "rights to %(rights)s on the document '%(document_title)s'. "
             "\nOpen the document: %(link)s")) % {
                 "owner": owner,
                 "rights": rights,
                 "collaborator_name": collaborator_name,
                 "link": link,
                 "document_title": document_title,
             }
        body_html_intro = _(
            ("<p>Hey %(collaborator_name)s,<br>%(owner)s has changed your "
             "access rights to %(rights)s on the document "
             "'%(document_title)s'.</p>")) % {
                 "owner": owner,
                 "rights": rights,
                 "collaborator_name": collaborator_name,
                 "document_title": document_title,
             }
    else:
        message_text = _(
            ("Hey %(collaborator_name)s,\n%(owner)s has shared the document "
             "'%(document_title)s' with you and given you %(rights)s access "
             "rights. "
             "\nOpen document: %(link)s")) % {
                 "owner": owner,
                 "rights": rights,
                 "collaborator_name": collaborator_name,
                 "link": link,
                 "document_title": document_title,
             }
        body_html_intro = _(
            ("<p>Hey %(collaborator_name)s,<br>%(owner)s has shared the "
             "document '%(document_title)s' with you and given you "
             "%(rights)s access rights.</p>")) % {
                 "owner": owner,
                 "rights": rights,
                 "collaborator_name": collaborator_name,
                 "document_title": document_title,
             }

    body_html = ("<h1>%(document_title)s %(shared)s</h1>"
                 "%(body_html_intro)s"
                 "<table>"
                 "<tr><td>"
                 "%(Document)s"
                 "</td><td>"
                 "<b>%(document_title)s</b>"
                 "</td></tr>"
                 "<tr><td>"
                 "%(Author)s"
                 "</td><td>"
                 "%(owner)s"
                 "</td></tr>"
                 "<tr><td>"
                 "%(AccessRights)s"
                 "</td><td>"
                 "%(rights)s"
                 "</td></tr>"
                 "</table>"
                 '<div class="actions"><a class="button" href="%(link)s">'
                 "%(AccessTheDocument)s"
                 "</a></div>") % {
                     "shared": _("shared"),
                     "body_html_intro": body_html_intro,
                     "Document": _("Document"),
                     "document_title": document_title,
                     "Author": _("Author"),
                     "owner": owner,
                     "AccessRights": _("Access Rights"),
                     "rights": rights,
                     "link": link,
                     "AccessTheDocument": _("Access the document"),
                 }
    send_mail(
        _("Document shared: %(document_title)s") %
        {"document_title": document_title},
        message_text,
        settings.DEFAULT_FROM_EMAIL,
        [collaborator_email],
        fail_silently=True,
        html_message=html_email(body_html),
    )
Esempio n. 4
0
def send_comment_notification(
    notification_type,
    commentator,
    collaborator_name,
    collaborator_email,
    link,
    document_title,
    comment_text,
    comment_html,
):
    if notification_type == "mention":

        message_text = _(
            ("Hey %(collaborator_name)s,\n%(commentator)s has mentioned you "
             "in a comment in the document '%(document)s':"
             "\n\n%(comment_text)s"
             "\n\nGo to the document here: %(link)s")) % {
                 "commentator": commentator,
                 "collaborator_name": collaborator_name,
                 "link": link,
                 "document": document_title,
                 "comment_text": comment_text,
             }

        body_html_title = _(
            ("Hey %(collaborator_name)s,<br>%(commentator)s has mentioned "
             "you in a comment in the document '%(document_title)s'.")) % {
                 "commentator": commentator,
                 "collaborator_name": collaborator_name,
                 "document_title": document_title,
             }
        message_title = _("Comment on : %(document_title)s") % {
            "document_title": document_title
        }
    else:
        message_text = _(
            ("Hey %(collaborator_name)s,\n%(commentator)s has assigned you to "
             "a comment in the document '%(document)s':\n\n%(comment_text)s"
             "\n\nGo to the document here: %(link)s")) % {
                 "commentator": commentator,
                 "collaborator_name": collaborator_name,
                 "link": link,
                 "document": document_title,
                 "comment_text": comment_text,
             }
        body_html_title = _(
            ("Hey %(collaborator_name)s,<br>%(commentator)s has assigned you "
             "to a comment in the document '%(document_title)s'.")) % {
                 "commentator": commentator,
                 "collaborator_name": collaborator_name,
                 "document_title": document_title,
             }
        message_title = _("Comment assignment on : %(document_title)s") % {
            "document_title": document_title
        }

    body_html = _(
        ("<p>Hey %(collaborator_name)s,<br>%(commentator)s has assigned "
         "you to a comment in the document '%(document)s':</p>"
         "%(comment_html)s"
         '<p>Go to the document <a href="%(link)s">here</a>.</p>')) % {
             "commentator": commentator,
             "collaborator_name": collaborator_name,
             "link": link,
             "document": document_title,
             "comment_html": comment_html,
         }

    body_html = ("<h1>%(body_html_title)s</h1>"
                 "<table>"
                 "<tr><td>"
                 "%(Document)s"
                 "</td><td>"
                 "<b>%(document_title)s</b>"
                 "</td></tr>"
                 "<tr><td>"
                 "%(Author)s"
                 "</td><td>"
                 "%(commentator)s"
                 "</td></tr>"
                 "<tr><td>"
                 "%(Comment)s"
                 "</td><td>"
                 "%(comment_html)s"
                 "</td></tr>"
                 "</table>"
                 '<div class="actions"><a class="button" href="%(link)s">'
                 "%(AccessTheDocument)s"
                 "</a></div>") % {
                     "body_html_title": body_html_title,
                     "Document": _("Document"),
                     "document_title": document_title,
                     "Author": _("Author"),
                     "commentator": commentator,
                     "Comment": _("Comment"),
                     "comment_html": comment_html,
                     "link": link,
                     "AccessTheDocument": _("Access the document"),
                 }
    send_mail(
        message_title,
        message_text,
        settings.DEFAULT_FROM_EMAIL,
        [collaborator_email],
        fail_silently=True,
        html_message=html_email(body_html),
    )
Esempio n. 5
0
def comment_notify(request):
    response = {}
    if not request.is_ajax() or request.method != 'POST':
        return JsonResponse(response, status=405)
    doc_id = request.POST['doc_id']
    collaborator_id = request.POST['collaborator_id']
    comment_text = request.POST['comment_text']
    comment_html = bleach.clean(request.POST['comment_html'], strip=True)
    notification_type = request.POST['type']
    collaborator = User.objects.filter(pk=collaborator_id).first()
    document = Document.objects.filter(pk=doc_id).first()
    if (not document or not collaborator or not comment_text
            or not comment_html or not has_doc_access(document, request.user)
            or not notification_type):
        return JsonResponse(response, status=403)
    if (not has_doc_access(document, collaborator)):
        # Tagged user has no access to document and will therefore not be
        # notified
        return JsonResponse(response, status=200)
    commentator = request.user.readable_name
    collaborator_name = collaborator.readable_name
    collaborator_email = collaborator.email
    document_title = document.title
    if len(document_title) == 0:
        document_title = _('Untitled')
    link = HttpRequest.build_absolute_uri(request, document.get_absolute_url())

    if notification_type == 'mention':

        message_text = _(
            ('Hey %(collaborator_name)s,\n%(commentator)s has mentioned you '
             'in a comment in the document \'%(document)s\':'
             '\n\n%(comment_text)s'
             '\n\nGo to the document here: %(link)s')) % {
                 'commentator': commentator,
                 'collaborator_name': collaborator_name,
                 'link': link,
                 'document': document_title,
                 'comment_text': comment_text
             }

        body_html_title = _(
            ('Hey %(collaborator_name)s,<br>%(commentator)s has mentioned '
             'you in a comment in the document \'%(document_title)s\'.')) % {
                 'commentator': commentator,
                 'collaborator_name': collaborator_name,
                 'document_title': document_title
             }
        message_title = _('Comment on :') + ' ' + document_title
    else:
        message_text = _(
            ('Hey %(collaborator_name)s,\n%(commentator)s has assigned you to '
             'a comment in the document \'%(document)s\':\n\n%(comment_text)s'
             '\n\nGo to the document here: %(link)s')) % {
                 'commentator': commentator,
                 'collaborator_name': collaborator_name,
                 'link': link,
                 'document': document_title,
                 'comment_text': comment_text
             }
        body_html_title = _(
            ('Hey %(collaborator_name)s,<br>%(commentator)s has assigned you '
             'to a comment in the document \'%(document_title)s\'.')) % {
                 'commentator': commentator,
                 'collaborator_name': collaborator_name,
                 'document_title': document_title
             }
        message_title = _('Comment assignment on :') + ' ' + document_title

    body_html = _(
        ('<p>Hey %(collaborator_name)s,<br>%(commentator)s has assigned '
         'you to a comment in the document \'%(document)s\':</p>'
         '%(comment_html)s'
         '<p>Go to the document <a href="%(link)s">here</a>.</p>')) % {
             'commentator': commentator,
             'collaborator_name': collaborator_name,
             'link': link,
             'document': document_title,
             'comment_html': comment_html
         }

    body_html = ('<h1>%(body_html_title)s</h1>'
                 '<table>'
                 '<tr><td>'
                 '%(Document)s'
                 '</td><td>'
                 '<b>%(document_title)s</b>'
                 '</td></tr>'
                 '<tr><td>'
                 '%(Author)s'
                 '</td><td>'
                 '%(commentator)s'
                 '</td></tr>'
                 '<tr><td>'
                 '%(Comment)s'
                 '</td><td>'
                 '%(comment_html)s'
                 '</td></tr>'
                 '</table>'
                 '<div class="actions"><a class="button" href="%(link)s">'
                 '%(AccessTheDocument)s'
                 '</a></div>') % {
                     'body_html_title': body_html_title,
                     'Document': _('Document'),
                     'document_title': document_title,
                     'Author': _('Author'),
                     'commentator': commentator,
                     'Comment': _('Comment'),
                     'comment_html': comment_html,
                     'link': link,
                     'AccessTheDocument': _('Access the document')
                 }

    send_mail(message_title,
              message_text,
              settings.DEFAULT_FROM_EMAIL, [collaborator_email],
              fail_silently=True,
              html_message=html_email(body_html))
    return JsonResponse(response, status=200)
Esempio n. 6
0
def send_invite_notification(request, doc_id, email, rights, invite, change):
    owner = request.user.readable_name
    document = Document.objects.get(id=doc_id)
    document_title = document.title
    if len(document_title) == 0:
        document_title = _('Untitled')
    link = HttpRequest.build_absolute_uri(request, invite.get_absolute_url())
    if change:
        message_text = _(
            ('Hey %(email)s,\nas we told you previously, %(owner)s has '
             'invited you to join Fidus Writer and shared the document '
             '\'%(document_title)s\' with you. '
             '\n%(owner)s has now changed your access rights to %(rights)s.'
             '\nAccess the document through this link: %(link)s')) % {
                 'owner': owner,
                 'rights': rights,
                 'email': email,
                 'link': link,
                 'document_title': document_title
             }
        body_html_intro = _(
            ('<p>Hey %(email)s,<br>as we told you previously, '
             '%(owner)s has invited you to join Fidus Writer and shared the '
             '\'%(document_title)s\' with you.</p>'
             '<p>%(owner)s has now changed your access rights to %(rights)s. '
             '</p>')) % {
                 'owner': owner,
                 'rights': rights,
                 'email': email,
                 'document_title': document_title
             }
    else:
        message_text = _(
            ('Hey %(email)s,\n%(owner)s has invited you to Fidus '
             ' Writer, shared the document \'%(document_title)s\' with you, '
             'and given you %(rights)s access rights. '
             '\nAccess the document through this link: %(link)s')) % {
                 'owner': owner,
                 'rights': rights,
                 'email': email,
                 'link': link,
                 'document_title': document_title
             }
        body_html_intro = _(
            ('<p>Hey %(email)s,<br>%(owner)s has invited you to '
             'Fidus Writer, shared the document \'%(document_title)s\' with '
             'you, and given you %(rights)s access rights.</p>')) % {
                 'owner': owner,
                 'rights': rights,
                 'email': email,
                 'document_title': document_title
             }

    body_html = ('<h1>%(document_title)s %(shared)s</h1>'
                 '%(body_html_intro)s'
                 '<table>'
                 '<tr><td>'
                 '%(Document)s'
                 '</td><td>'
                 '<b>%(document_title)s</b>'
                 '</td></tr>'
                 '<tr><td>'
                 '%(Author)s'
                 '</td><td>'
                 '%(owner)s'
                 '</td></tr>'
                 '<tr><td>'
                 '%(AccessRights)s'
                 '</td><td>'
                 '%(rights)s'
                 '</td></tr>'
                 '</table>'
                 '<div class="actions"><a class="button" href="%(link)s">'
                 '%(AccessTheDocument)s'
                 '</a></div>') % {
                     'shared': _('shared'),
                     'body_html_intro': body_html_intro,
                     'Document': _('Document'),
                     'document_title': document_title,
                     'Author': _('Author'),
                     'owner': owner,
                     'AccessRights': _('Access Rights'),
                     'rights': rights,
                     'link': link,
                     'AccessTheDocument':
                     _('Sign up or log in and access the document')
                 }
    send_mail(_('Document shared:') + ' ' + document_title,
              message_text,
              settings.DEFAULT_FROM_EMAIL, [email],
              fail_silently=True,
              html_message=html_email(body_html))
Esempio n. 7
0
def send_share_notification(request, doc_id, collaborator_id, rights, change):
    owner = request.user.readable_name
    document = Document.objects.get(id=doc_id)
    collaborator = User.objects.get(id=collaborator_id)
    collaborator_name = collaborator.readable_name
    collaborator_email = collaborator.email
    document_title = document.title
    if len(document_title) == 0:
        document_title = _('Untitled')
    link = HttpRequest.build_absolute_uri(request, document.get_absolute_url())
    if change:
        message_text = _(
            ('Hey %(collaborator_name)s,\n%(owner)s has changed your access '
             'rights to %(rights)s on the document \'%(document_title)s\'. '
             '\nAccess the document through this link: %(link)s')) % {
                 'owner': owner,
                 'rights': rights,
                 'collaborator_name': collaborator_name,
                 'link': link,
                 'document_title': document_title
             }
        body_html_intro = _(
            ('<p>Hey %(collaborator_name)s,<br>%(owner)s has changed your '
             'access rights to %(rights)s on the document '
             '\'%(document_title)s\'.</p>')) % {
                 'owner': owner,
                 'rights': rights,
                 'collaborator_name': collaborator_name,
                 'document_title': document_title
             }
    else:
        message_text = _(
            ('Hey %(collaborator_name)s,\n%(owner)s has shared the document '
             '\'%(document_title)s\' with you and given you %(rights)s access '
             'rights. '
             '\nAccess the document through this link: %(link)s')) % {
                 'owner': owner,
                 'rights': rights,
                 'collaborator_name': collaborator_name,
                 'link': link,
                 'document_title': document_title
             }
        body_html_intro = _(
            ('<p>Hey %(collaborator_name)s,<br>%(owner)s has shared the '
             'document \'%(document_title)s\' with you and given you '
             '%(rights)s access rights.</p>')) % {
                 'owner': owner,
                 'rights': rights,
                 'collaborator_name': collaborator_name,
                 'document_title': document_title
             }

    body_html = ('<h1>%(document_title)s %(shared)s</h1>'
                 '%(body_html_intro)s'
                 '<table>'
                 '<tr><td>'
                 '%(Document)s'
                 '</td><td>'
                 '<b>%(document_title)s</b>'
                 '</td></tr>'
                 '<tr><td>'
                 '%(Author)s'
                 '</td><td>'
                 '%(owner)s'
                 '</td></tr>'
                 '<tr><td>'
                 '%(AccessRights)s'
                 '</td><td>'
                 '%(rights)s'
                 '</td></tr>'
                 '</table>'
                 '<div class="actions"><a class="button" href="%(link)s">'
                 '%(AccessTheDocument)s'
                 '</a></div>') % {
                     'shared': _('shared'),
                     'body_html_intro': body_html_intro,
                     'Document': _('Document'),
                     'document_title': document_title,
                     'Author': _('Author'),
                     'owner': owner,
                     'AccessRights': _('Access Rights'),
                     'rights': rights,
                     'link': link,
                     'AccessTheDocument': _('Access the document')
                 }
    send_mail(_('Document shared:') + ' ' + document_title,
              message_text,
              settings.DEFAULT_FROM_EMAIL, [collaborator_email],
              fail_silently=True,
              html_message=html_email(body_html))
Esempio n. 8
0
def comment_notify_js(request):
    response = {}
    if not request.is_ajax() or request.method != 'POST':
        return JsonResponse(
            response,
            status=405
        )
    doc_id = request.POST['doc_id']
    collaborator_id = request.POST['collaborator_id']
    comment_text = request.POST['comment_text']
    comment_html = bleach.clean(
        request.POST['comment_html'],
        strip=True
    )
    notification_type = request.POST['type']
    collaborator = User.objects.filter(pk=collaborator_id).first()
    document = Document.objects.filter(pk=doc_id).first()
    if (
        not document or
        not collaborator or
        not comment_text or
        not comment_html or
        not has_doc_access(document, request.user) or
        not has_doc_access(document, collaborator) or
        not notification_type
    ):
        return JsonResponse(
            response,
            status=403
        )
    commentator = request.user.readable_name
    collaborator_name = collaborator.readable_name
    collaborator_email = collaborator.email
    document_title = document.title
    if len(document_title) == 0:
        document_title = _('Untitled')
    link = HttpRequest.build_absolute_uri(request, document.get_absolute_url())

    if notification_type == 'mention':

        message_text = _(
            ('Hey %(collaborator_name)s,\n%(commentator)s has mentioned you '
             'in a comment in the document \'%(document)s\':'
             '\n\n%(comment_text)s'
             '\n\nGo to the document here: %(link)s')
        ) % {
               'commentator': commentator,
               'collaborator_name': collaborator_name,
               'link': link,
               'document': document_title,
               'comment_text': comment_text
        }

        body_html_title = _(
            ('Hey %(collaborator_name)s,<br>%(commentator)s has mentioned '
             'you in a comment in the document \'%(document_title)s\'.')
        ) % {
            'commentator': commentator,
            'collaborator_name': collaborator_name,
            'document_title': document_title
        }
        message_title = _('Comment on :') + ' ' + document_title
    else:
        message_text = _(
            ('Hey %(collaborator_name)s,\n%(commentator)s has assigned you to '
             'a comment in the document \'%(document)s\':\n\n%(comment_text)s'
             '\n\nGo to the document here: %(link)s')
        ) % {
               'commentator': commentator,
               'collaborator_name': collaborator_name,
               'link': link,
               'document': document_title,
               'comment_text': comment_text
        }
        body_html_title = _(
            ('Hey %(collaborator_name)s,<br>%(commentator)s has assigned you '
             'to a comment in the document \'%(document_title)s\'.')
        ) % {
            'commentator': commentator,
            'collaborator_name': collaborator_name,
            'document_title': document_title
        }
        message_title = _('Comment assignment on :') + ' ' + document_title

    body_html = _(
        ('<p>Hey %(collaborator_name)s,<br>%(commentator)s has assigned '
         'you to a comment in the document \'%(document)s\':</p>'
         '%(comment_html)s'
         '<p>Go to the document <a href="%(link)s">here</a>.</p>')
    ) % {
        'commentator': commentator,
        'collaborator_name': collaborator_name,
        'link': link,
        'document': document_title,
        'comment_html': comment_html
    }

    body_html = (
        '<h1>%(body_html_title)s</h1>'
        '<table>'
        '<tr><td>'
        '%(Document)s'
        '</td><td>'
        '<b>%(document_title)s</b>'
        '</td></tr>'
        '<tr><td>'
        '%(Author)s'
        '</td><td>'
        '%(commentator)s'
        '</td></tr>'
        '<tr><td>'
        '%(Comment)s'
        '</td><td>'
        '%(comment_html)s'
        '</td></tr>'
        '</table>'
        '<div class="actions"><a class="button" href="%(link)s">'
        '%(AccessTheDocument)s'
        '</a></div>'
    ) % {
        'body_html_title': body_html_title,
        'Document': _('Document'),
        'document_title': document_title,
        'Author': _('Author'),
        'commentator': commentator,
        'Comment': _('Comment'),
        'comment_html': comment_html,
        'link': link,
        'AccessTheDocument': _('Access the document')
    }

    send_mail(
        message_title,
        message_text,
        settings.DEFAULT_FROM_EMAIL,
        [collaborator_email],
        fail_silently=True,
        html_message=html_email(body_html)
    )
    return JsonResponse(
        response,
        status=200
    )
Esempio n. 9
0
def send_share_notification(request, doc_id, collaborator_id, right, change):
    owner = request.user.readable_name
    document = Document.objects.get(id=doc_id)
    collaborator = User.objects.get(id=collaborator_id)
    collaborator_name = collaborator.readable_name
    collaborator_email = collaborator.email
    document_title = document.title
    if len(document_title) == 0:
        document_title = _('Untitled')
    link = HttpRequest.build_absolute_uri(request, document.get_absolute_url())
    if change:
        message_text = _(
            ('Hey %(collaborator_name)s,\n%(owner)s has changed your access '
             'rights to %(right)s on the document \'%(document_title)s\'. '
             '\nAccess the document through this link: %(link)s')
        ) % {
            'owner': owner,
            'right': right,
            'collaborator_name': collaborator_name,
            'link': link,
            'document_title': document_title
        }
        body_html_title = _(
            ('Hey %(collaborator_name)s,<br>%(owner)s has changed your access '
             'rights to %(right)s on the document \'%(document_title)s\'.')
        ) % {
            'owner': owner,
            'right': right,
            'collaborator_name': collaborator_name,
            'document_title': document_title
        }
    else:
        message_text = _(
            ('Hey %(collaborator_name)s,\n%(owner)s has shared the document '
             '\'%(document_title)s\' with you and given you %(right)s access '
             'rights. '
             '\nAccess the document through this link: %(link)s')
        ) % {
            'owner': owner,
            'right': right,
            'collaborator_name': collaborator_name,
            'link': link,
            'document_title': document_title
        }
        body_html_title = _(
            ('Hey %(collaborator_name)s,<br>%(owner)s has shared the document '
             '\'%(document_title)s\' with you and given you %(right)s access '
             'rights.')
        ) % {
            'owner': owner,
            'right': right,
            'collaborator_name': collaborator_name,
            'document_title': document_title
        }

    body_html = (
        '<h1>%(body_html_title)s</h1>'
        '<table>'
        '<tr><td>'
        '%(Document)s'
        '</td><td>'
        '<b>%(document_title)s</b>'
        '</td></tr>'
        '<tr><td>'
        '%(Author)s'
        '</td><td>'
        '%(owner)s'
        '</td></tr>'
        '<tr><td>'
        '%(AccessRights)s'
        '</td><td>'
        '%(right)s'
        '</td></tr>'
        '</table>'
        '<div class="actions"><a class="button" href="%(link)s">'
        '%(AccessTheDocument)s'
        '</a></div>'
    ) % {
        'body_html_title': body_html_title,
        'Document': _('Document'),
        'document_title': document_title,
        'Author': _('Author'),
        'owner': owner,
        'AccessRights': _('Access Rights'),
        'right': right,
        'link': link,
        'AccessTheDocument': _('Access the document')
    }
    send_mail(
        _('Document shared:') +
        ' ' +
        document_title,
        message_text,
        settings.DEFAULT_FROM_EMAIL,
        [collaborator_email],
        fail_silently=True,
        html_message=html_email(body_html)
    )