예제 #1
0
 def __init__(self, *args, evaluation, export=False, **kwargs):
     super().__init__(*args, **kwargs)
     self.template = EmailTemplate()
     self.evaluation = evaluation
     self.recipient_groups = None
     self.fields['subject'].required = not export
     self.fields['body'].required = not export
예제 #2
0
파일: forms.py 프로젝트: rschwanhold/EvaP
 def __init__(self, *args, **kwargs):
     self.instance = kwargs.pop('instance')
     self.export = kwargs.pop('export', False)
     self.template = EmailTemplate()
     super().__init__(*args, **kwargs)
     self.fields['subject'].required = not self.export
     self.fields['body'].required = not self.export
예제 #3
0
 def test_copy_plain_content_on_empty_html_content(self):
     template = EmailTemplate(
         subject="Example", plain_content="Example plain content\nWith newline", html_content=""
     )
     template.send_to_user(self.user, {}, {}, False)
     self.assertEqual(mail.outbox[0].body, "Example plain content\nWith newline")
     self.assertIn("Example plain content<br />With newline", mail.outbox[0].alternatives[0][0])
예제 #4
0
파일: forms.py 프로젝트: PFischbeck/EvaP
 def __init__(self, *args, evaluation, export=False, **kwargs):
     super().__init__(*args, **kwargs)
     self.template = EmailTemplate()
     self.evaluation = evaluation
     self.recipient_groups = None
     self.fields["subject"].required = not export
     self.fields["plain_content"].required = not export
     self.fields["html_content"].required = False
예제 #5
0
 def test_escape_special_characters_in_html_email(self):
     template = EmailTemplate(
         subject="<h1>Special Email</h1>",
         plain_content="Example plain content",
         html_content="Special Content: {{special_content}}",
     )
     template.send_to_user(self.user, {}, {"special_content": "0 < 1"}, False)
     self.assertIn("&lt;h1&gt;Special Email&lt;/h1&gt;", mail.outbox[0].alternatives[0][0])
     self.assertIn("Special Content: 0 &lt; 1", mail.outbox[0].alternatives[0][0])
예제 #6
0
파일: test_models.py 프로젝트: jb3rndt/EvaP
 def test_send_multi_alternatives_email(self):
     template = EmailTemplate(
         subject="Example", plain_content="Example plain content", html_content="<p>Example html content</p>"
     )
     template.send_to_user(self.user, {}, {}, False)
     self.assertEqual(len(mail.outbox), 1)
     self.assertTrue(isinstance(mail.outbox[0], mail.message.EmailMultiAlternatives))
     self.assertEqual(mail.outbox[0].body, "Example plain content")
     self.assertEqual(len(mail.outbox[0].alternatives), 1)
     self.assertEqual(mail.outbox[0].alternatives[0][1], "text/html")
     self.assertIn("<p>Example html content</p>", mail.outbox[0].alternatives[0][0])
예제 #7
0
파일: test_models.py 프로젝트: jb3rndt/EvaP
    def test_plain_content_escaped_and_copied_on_empty_html_content(self):
        template = EmailTemplate(subject="Subject <>&", plain_content="A\nB <>& {{ some_var }}", html_content="")
        template.send_to_user(self.user, {}, {"some_var": "0 < 1"}, False)

        self.assertEqual(len(mail.outbox), 1)
        message = mail.outbox[0]
        self.assertEqual(message.alternatives[0][1], "text/html")
        html_content = message.alternatives[0][0]

        self.assertEqual("Subject <>&", message.subject)
        self.assertEqual("A\nB <>& 0 < 1", message.body)
        self.assertIn("A<br>B &lt;&gt;&amp; 0 &lt; 1\n", html_content)
        self.assertNotIn("<>&", html_content)
예제 #8
0
파일: test_models.py 프로젝트: jb3rndt/EvaP
    def test_escaping_with_html_content(self):
        template = EmailTemplate(
            subject="Subject <>&",
            plain_content="A\nB <>& {{ some_var }}",
            html_content="Html content &amp;<br/> {{ some_var }}",
        )
        template.send_to_user(self.user, {}, {"some_var": "0 < 1"}, False)

        self.assertEqual(len(mail.outbox), 1)
        message = mail.outbox[0]
        self.assertEqual(message.alternatives[0][1], "text/html")
        html_content = message.alternatives[0][0]

        self.assertEqual("Subject <>&", message.subject)
        self.assertEqual("A\nB <>& 0 < 1", message.body)
        self.assertIn("Html content &amp;<br/> 0 &lt; 1", html_content)
        self.assertNotIn("<>&", html_content)
예제 #9
0
 def __init__(self, *args, course, export=False, **kwargs):
     super().__init__(*args, **kwargs)
     self.template = EmailTemplate()
     self.course = course
     self.fields['subject'].required = not export
     self.fields['body'].required = not export
예제 #10
0
 def __init__(self, *args, **kwargs):
     self.instance = kwargs.pop('instance')
     self.template = EmailTemplate()
     super().__init__(*args, **kwargs)