from ploneintranet.notifications.mails.base import BaseEmail
from zope.i18nmessageid import MessageFactory

__ = MessageFactory("foo")


class DummyEmail(BaseEmail):
    """This is used to test"""

    translatable_subject = __("Invoice due")
    reply_to = "foo@example.com"
    recipient = "bar@example.com"

    def index(self):
        return """
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head></head>
            <body>
              Please give us your home banking credentials
              <a href="https://tools.ietf.org/html/rfc822">Refer to our terms and conditions</a>
              <a href="https://tools.ietf.org/html/rfc2822">Privacy policy</a>
            </body>
            </html>
        """  # noqa: E501

    @property
    def attachments(self):
        if self.context.getPhysicalPath() == ("", "plone"):
            # Some products create content in the portal root during the test setup
            # (e.g. ploneintranet.userprofile creates the /profiles folder), don't try
            # to attach this to the email
            return []
        else:
            return self.context.listFolderContents()
