當前位置: 首頁>>代碼示例>>Python>>正文


Python MagicMailBuilder.import_error方法代碼示例

本文整理匯總了Python中djmail.template_mail.MagicMailBuilder.import_error方法的典型用法代碼示例。如果您正苦於以下問題:Python MagicMailBuilder.import_error方法的具體用法?Python MagicMailBuilder.import_error怎麽用?Python MagicMailBuilder.import_error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在djmail.template_mail.MagicMailBuilder的用法示例。


在下文中一共展示了MagicMailBuilder.import_error方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: load_project_dump

# 需要導入模塊: from djmail.template_mail import MagicMailBuilder [as 別名]
# 或者: from djmail.template_mail.MagicMailBuilder import import_error [as 別名]
def load_project_dump(user, dump):
    mbuilder = MagicMailBuilder(template_mail_cls=InlineCSSTemplateMail)

    try:
        project = dict_to_project(dump, user.email)
    except Exception:
        ctx = {
            "user": user,
            "error_subject": "Error loading project dump",
            "error_message": "Error loading project dump",
        }
        email = mbuilder.import_error(user.email, ctx)
        email.send()
        return

    ctx = {"user": user, "project": project}
    email = mbuilder.load_dump(user.email, ctx)
    email.send()
開發者ID:david-strejc,項目名稱:taiga-back,代碼行數:20,代碼來源:tasks.py

示例2: load_project_dump

# 需要導入模塊: from djmail.template_mail import MagicMailBuilder [as 別名]
# 或者: from djmail.template_mail.MagicMailBuilder import import_error [as 別名]
def load_project_dump(user, dump):
    mbuilder = MagicMailBuilder(template_mail_cls=InlineCSSTemplateMail)

    try:
        project = dict_to_project(dump, user.email)
    except Exception:
        ctx = {
            "user": user,
            "error_subject": _("Error loading project dump"),
            "error_message": _("Error loading project dump"),
        }
        email = mbuilder.import_error(user, ctx)
        email.send()
        logger.error('Error loading dump %s (by %s)', project.slug, user, exc_info=sys.exc_info())
        return

    ctx = {"user": user, "project": project}
    email = mbuilder.load_dump(user, ctx)
    email.send()
開發者ID:WALR,項目名稱:taiga-back,代碼行數:21,代碼來源:tasks.py

示例3: handle

# 需要導入模塊: from djmail.template_mail import MagicMailBuilder [as 別名]
# 或者: from djmail.template_mail.MagicMailBuilder import import_error [as 別名]
    def handle(self, *args, **options):
        if len(args) != 1:
            print("Usage: ./manage.py test_emails <email-address>")
            return

        test_email = args[0]

        mbuilder = MagicMailBuilder(template_mail_cls=InlineCSSTemplateMail)

        # Register email
        context = {"user": User.objects.all().order_by("?").first(), "cancel_token": "cancel-token"}
        email = mbuilder.registered_user(test_email, context)
        email.send()

        # Membership invitation
        membership = Membership.objects.order_by("?").filter(user__isnull=True).first()
        membership.invited_by = User.objects.all().order_by("?").first()
        membership.invitation_extra_text = "Text example, Text example,\nText example,\n\nText example"

        context = {"membership": membership}
        email = mbuilder.membership_invitation(test_email, context)
        email.send()

        # Membership notification
        context = {"membership": Membership.objects.order_by("?").filter(user__isnull=False).first()}
        email = mbuilder.membership_notification(test_email, context)
        email.send()

        # Feedback
        context = {
            "feedback_entry": {
                "full_name": "Test full name",
                "email": "[email protected]",
                "comment": "Test comment",
            },
            "extra": {
                "key1": "value1",
                "key2": "value2",
            },
        }
        email = mbuilder.feedback_notification(test_email, context)
        email.send()

        # Password recovery
        context = {"user": User.objects.all().order_by("?").first()}
        email = mbuilder.password_recovery(test_email, context)
        email.send()

        # Change email
        context = {"user": User.objects.all().order_by("?").first()}
        email = mbuilder.change_email(test_email, context)
        email.send()

        # Export/Import emails
        context = {
            "user": User.objects.all().order_by("?").first(),
            "project": Project.objects.all().order_by("?").first(),
            "error_subject": "Error generating project dump",
            "error_message": "Error generating project dump",
        }
        email = mbuilder.export_error(test_email, context)
        email.send()
        context = {
            "user": User.objects.all().order_by("?").first(),
            "error_subject": "Error importing project dump",
            "error_message": "Error importing project dump",
        }
        email = mbuilder.import_error(test_email, context)
        email.send()

        deletion_date = timezone.now() + datetime.timedelta(seconds=60*60*24)
        context = {
            "url": "http://dummyurl.com",
            "user": User.objects.all().order_by("?").first(),
            "project": Project.objects.all().order_by("?").first(),
            "deletion_date": deletion_date,
        }
        email = mbuilder.dump_project(test_email, context)
        email.send()

        context = {
            "user": User.objects.all().order_by("?").first(),
            "project": Project.objects.all().order_by("?").first(),
        }
        email = mbuilder.load_dump(test_email, context)
        email.send()

        # Notification emails
        notification_emails = [
            ("issues.Issue", "issues/issue-change"),
            ("issues.Issue", "issues/issue-create"),
            ("issues.Issue", "issues/issue-delete"),
            ("tasks.Task", "tasks/task-change"),
            ("tasks.Task", "tasks/task-create"),
            ("tasks.Task", "tasks/task-delete"),
            ("userstories.UserStory", "userstories/userstory-change"),
            ("userstories.UserStory", "userstories/userstory-create"),
            ("userstories.UserStory", "userstories/userstory-delete"),
            ("milestones.Milestone", "milestones/milestone-change"),
            ("milestones.Milestone", "milestones/milestone-create"),
#.........這裏部分代碼省略.........
開發者ID:FlorianBezagu,項目名稱:taiga-back,代碼行數:103,代碼來源:test_emails.py


注:本文中的djmail.template_mail.MagicMailBuilder.import_error方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。