models.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:balafon 作者: ljean 项目源码 文件源码
def mail_to(self):
        """returns a mailto link"""
        unique_emails = sorted(list(set(
            [
                contact.get_email_address() for contact in self.contacts.all() if contact.get_email
            ] + [
                entity.get_email_address() for entity in self.entities.all() if entity.email
            ]
        )))

        if not unique_emails:
            return u""

        body = u""
        if self.uuid and hasattr(self, 'sale'):
            try:
                url = reverse('store_view_sales_document_public', args=[self.uuid])
                body = ugettext(u"Here is a link to your {0}: {1}{2}").format(
                    self.type.name,
                    "http://" + Site.objects.get_current().domain,
                    url
                )
            except ObjectDoesNotExist:
                pass

        return u"mailto:{0}?subject={1}&body={2}".format(
            u",".join(unique_emails),
            self.type.mail_to_subject if (self.type and self.type.mail_to_subject) else self.subject,
            body
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号