-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing email notifications that did not work correctly #76
Open
ercchy
wants to merge
3
commits into
p2pu:master
Choose a base branch
from
ercchy:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,4 +207,4 @@ def skip_suspicious_operations(record): | |
################################################################# | ||
MANDRILL_API_KEY = "" | ||
EMAIL_BACKEND = "djrill.mail.backends.djrill.DjrillBackend" | ||
DEFAULT_FROM_EMAIL = "[email protected]" | ||
DEFAULT_FROM_EMAIL = "P2PU team <[email protected]>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
from django import template | ||
from django.template.defaultfilters import mark_safe | ||
from subprocess import Popen, PIPE | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.filter | ||
def purge_content(value): | ||
return mark_safe(value.replace('<p> </p>', '')) | ||
return mark_safe(value.replace('<p> </p>', '')) | ||
|
||
@register.filter | ||
def html2text(value): | ||
""" | ||
Pipes given HTML string into the text browser W3M, which renders it. | ||
Rendered text is grabbed from STDOUT and returned. | ||
""" | ||
try: | ||
cmd = "w3m -dump -T text/html -O ascii" | ||
proc = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE) | ||
return proc.communicate(str(value))[0] | ||
except OSError: | ||
# something bad happened, so just return the input | ||
return value | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% extends 'emails/base.html' %} | ||
{% load i18n %} | ||
{% load projects_tags %} | ||
|
||
{% block body %} | ||
<p> | ||
Howdy! | ||
</p> | ||
<p> | ||
Your badge {{ badge.title }} is published, live, and ready-to-go. | ||
</p> | ||
<table> | ||
<tbody> | ||
<tr> | ||
<td> | ||
<a href="http://badges.p2pu.org{% url badge_view badge.id %}"> | ||
<img src="http://badges.p2pu.org{{ badge.image.url }}" width="160px"/> | ||
</a> | ||
</td> | ||
<td style="padding-left:20px; text-valign:top;"> | ||
<p>{{ badge.title }}</p> | ||
<p>{{ badge.description|purge_content }}</p> | ||
<p>{{ badge.requirements|purge_content }}</p> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<p> | ||
Your Badge now exists on <a href="http://badges.p2pu.org{% url badge_view badge.id %}">badges.p2pu.org</a> and learners can apply for it immediately. | ||
</p> | ||
<p> | ||
Tell the world about your spiffy Badge! {% include 'emails/social_buttons.html' %} | ||
</p> | ||
|
||
<p> | ||
|
||
</p> | ||
<p> | ||
Yours in the future of learning, <br/> | ||
- The P2PU team | ||
</p> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{% load projects_tags %}{% load i18n %}{% blocktrans with title=badge.title description=badge.description|purge_content requirements=badge.requirements|html2text %} | ||
Howdy! | ||
|
||
Your badge {{ title }} is published, live, and ready-to-go. | ||
|
||
* Title: {{ title }} | ||
* Description: {{ description }} | ||
* Requirements: {{ requirements }} | ||
{% endblocktrans %} | ||
|
||
Your Badge now exists at http://badges.p2pu.org{% url badge_view badge.id %} and learners can apply for it immediately. | ||
|
||
Tell the world about your spiffy Badge! | ||
|
||
Google+ - https://plus.google.com/share?url=http://badges.p2pu.org{% url badge_view badge.id %} | ||
|
||
Tweet - http://twitter.com/share?url=http://badges.p2pu.org{% url badge_view badge.id %}&text=Check out the spiffy badge I made!&via=p2pu | ||
|
||
{% blocktrans %} | ||
Yours in the future of learning, | ||
- The P2PU team | ||
{% endblocktrans %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{% load i18n %}{% blocktrans with badge_title=badge.title%}You've just published a {{ badge_title }} Badge. Congrats!{% endblocktrans %} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look how text content is generated from HTML emails for the Mechanical MOOC: https://github.com/p2pu/mechanical-mooc/blob/master/mail/views.py#L22-L27.