diff --git a/badges/badge/models.py b/badges/badge/models.py
index 6ec3486..37873f7 100644
--- a/badges/badge/models.py
+++ b/badges/badge/models.py
@@ -4,6 +4,7 @@
from .db import Badge
from .db import Award
from .notification_helpers import send_badge_creation_notification
+from .notification_helpers import send_badge_published_notification
from .notification_helpers import send_badge_awarded_notification
@@ -136,6 +137,7 @@ def publish_badge(uri):
badge_db.author_uri,
reverse('badge_view', args=(badge_db.pk, )),
)
+ send_badge_published_notification(_badge2dict(badge_db))
return True
diff --git a/badges/badge/notification_helpers.py b/badges/badge/notification_helpers.py
index 27c447a..7609111 100644
--- a/badges/badge/notification_helpers.py
+++ b/badges/badge/notification_helpers.py
@@ -15,6 +15,19 @@ def send_badge_creation_notification(badge):
context=context
)
+def send_badge_published_notification(badge):
+ subject_template = 'emails/badge_published_subject.txt'
+ text_template = 'emails/badge_published.txt'
+ html_template = 'emails/badge_published.html'
+ context = {'badge': fetch_badge_resources(badge)}
+ return send_notification_i18n(
+ badge['author_uri'],
+ subject_template,
+ text_template,
+ html_template,
+ context=context
+ )
+
def send_badge_awarded_notification(badge, expert_uri):
subject_template = 'emails/badge_awarded_subject.txt'
diff --git a/badges/badge/views.py b/badges/badge/views.py
index c1093b6..67ee0b6 100644
--- a/badges/badge/views.py
+++ b/badges/badge/views.py
@@ -1,6 +1,6 @@
from django.core.serializers.json import DjangoJSONEncoder
from django import http
-from django.http import HttpResponse
+from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.core.urlresolvers import reverse
@@ -70,6 +70,10 @@ def create(request):
@require_login
def preview(request, badge_id):
badge = badge_api.get_badge(badge_api.id2uri(badge_id))
+
+ if badge['published_date']:
+ return HttpResponseRedirect(reverse('badge_view', args=[badge_id]))
+
fetch_badge_resources(badge)
user = request.session['user']
user['is_author'] = _user_is_author(badge, user)
diff --git a/badges/badges/settings.py b/badges/badges/settings.py
index 99c2247..656bae0 100644
--- a/badges/badges/settings.py
+++ b/badges/badges/settings.py
@@ -207,4 +207,4 @@ def skip_suspicious_operations(record):
#################################################################
MANDRILL_API_KEY = ""
EMAIL_BACKEND = "djrill.mail.backends.djrill.DjrillBackend"
-DEFAULT_FROM_EMAIL = "badges@p2pu.org"
\ No newline at end of file
+DEFAULT_FROM_EMAIL = "P2PU team
-Your badge {{ badge.title }} is published, live, and ready-to-go. +Your badge {{ badge.title }} is created. Woohoo! +
++ Your Badge is created, but that doesn't mean that people can apply for it yet. If you haven't already, then you + must publish it and let the world see your creation. Publish it by pressing on the "Publish" button + here.
- + |
{{ badge.title }} {{ badge.description|purge_content }} -{{ badge.requirements }} +{{ badge.requirements|purge_content }} |
-Your Badge now exists on badges.p2pu.org and learners can apply for it immediately. As the Badge's creator, this badge will automatically appear on your profile. -
--Tell the world about your spiffy Badge! {% include 'emails/social_buttons.html' %} +
As the Badge's creator, this badge will automatically appear on your profile.
diff --git a/badges/templates/emails/badge_created.txt b/badges/templates/emails/badge_created.txt index 70cd9fc..7c79ef7 100644 --- a/badges/templates/emails/badge_created.txt +++ b/badges/templates/emails/badge_created.txt @@ -1,20 +1,16 @@ -{% load projects_tags %}{% load i18n %}{% blocktrans with title=badge.title decription=badge.description|purge_content requirements=badge.requirements%} +{% 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. +Your badge {{ badge.title }} is created. Woohoo! -{{ title }} -{{ description }} -{{ requirements }} +* 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. As the Badge's creator, this badge will automatically appear on your profile. +Your Badge is created, but that doesn't mean that people can apply for it yet. If you haven't already, then you must publish it and let the world see your creation. Publish it by pressing on the "Publish" button at http://badges.p2pu.org{% url badge_preview badge.id %} -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 +As the Badge's creator, this badge will automatically appear on your profile. {% blocktrans %} Yours in the future of learning, diff --git a/badges/templates/emails/badge_published.html b/badges/templates/emails/badge_published.html new file mode 100644 index 0000000..b582640 --- /dev/null +++ b/badges/templates/emails/badge_published.html @@ -0,0 +1,42 @@ +{% extends 'emails/base.html' %} +{% load i18n %} +{% load projects_tags %} + +{% block body %} +
+Howdy! +
++Your badge {{ badge.title }} is published, live, and ready-to-go. +
++ + + + | +
+ {{ badge.title }} +{{ badge.description|purge_content }} +{{ badge.requirements|purge_content }} + |
+
+Your Badge now exists on badges.p2pu.org and learners can apply for it immediately. +
++Tell the world about your spiffy Badge! {% include 'emails/social_buttons.html' %} +
+ ++ +
+
+Yours in the future of learning,
+- The P2PU team
+