Skip to content
Browse files

Removed old example templates, changed __init__ function, so that aut…

…ocompletion in IDE works
  • Loading branch information...
1 parent dda8faf commit 4152cc25614163dd4771672bda2f23675a98adff Kevin Renskers committed
View
2 README.md
@@ -21,7 +21,7 @@ Sending email should be as easy as creating an instance of the email class, prov
This email class doesn't know about mail queues. You can use a custom email backend or a project like [Django-mailer](https://github.com/jtauber/django-mailer) for that.
## Usage
- from generic_email import Email
+ from generic_mail import Email
# This will send text email only, uses the email/base_text_email.html template with the "body" template variable
email = Email('to@example.com', 'Subject', 'Line one\n\nLine two')
View
18 generic_mail/__init__.py
@@ -47,15 +47,21 @@ class Email(object):
_custom_templates = False
_markdown = None
- def __init__(self, **kwargs):
+ def __init__(self, to=None, subject=None, text_body=None, html_body=None, attachments=None, cc=None, bcc=None,
+ from_address=None, text_template=None, html_template=None, **kwargs):
"""
Init the class, the kwargs will be used as context variables
"""
- for key in kwargs.copy():
- if hasattr(self, key) and not key.startswith('_'):
- setattr(self, key, kwargs[key])
- del kwargs[key]
-
+ self.to = to or self.to
+ self.subject = subject or self.subject
+ self.attachments = attachments or self.attachments
+ self.cc = cc or self.cc
+ self.bcc = bcc or self.bcc
+ self.from_address = from_address or self.from_address
+ self.text_body = text_body or self.text_body
+ self.html_body = html_body or self.html_body
+ self.text_template = text_template or self.text_template
+ self.html_template = html_template or self.html_template
self.kwargs = kwargs
if self.text_template or self.html_template:
View
2 generic_mail/templates/email/base_html_email.html
@@ -1,3 +1 @@
-<p>Hello,</p>
{{ body|safe }}
-<p>Goodbye.</p>
View
4 generic_mail/templates/email/base_text_email.html
@@ -1,5 +1 @@
-Hello,
-
{{ body }}
@hvdklauw
hvdklauw added a note

Here you also want a |safe escape.

Reasoning: It's text mail and you don't want any html tags to be escaped, they will be displayed as is.
<strong> vs &lt;strong&gt;

@kevinrenskers Owner

Will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
-
-Goodbye.
View
3 generic_mail/templates/email/my_html_email.html
@@ -1,3 +0,0 @@
-<p>Hello,</p>
-<p>This is email.</p>
-<p>Goodbye.</p>
View
5 generic_mail/templates/email/my_text_email.html
@@ -1,5 +0,0 @@
-Hello,
-
-This is email.
-
-Goodbye.

0 comments on commit 4152cc2

Please sign in to comment.
Something went wrong with that request. Please try again.