Adding email for first share to tell users about their blurblog.

This commit is contained in:
Samuel Clay 2013-04-22 15:24:38 -07:00
parent 912c632e1d
commit d209b2e905
25 changed files with 88 additions and 20 deletions

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
from apps.analyzer import views
urlpatterns = patterns('',

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
from apps.api import views
urlpatterns = patterns('',

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import url, patterns
from django.conf.urls import url, patterns
from apps.categories import views
urlpatterns = patterns('',

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
from apps.feed_import import views
urlpatterns = patterns('apps.feed_import.views',

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
from apps.mobile import views
urlpatterns = patterns('apps.mobile.views',

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import url, patterns
from django.conf.urls import url, patterns
from apps.oauth import views
urlpatterns = patterns('',

View file

@ -296,6 +296,36 @@ class Profile(models.Model):
msg.send(fail_silently=True)
logging.user(self.user, "~BB~FM~SBSending email for new user: %s" % self.user.email)
def send_first_share_to_blurblog_email(self, force=False):
from apps.social.models import MSocialProfile, MSharedStory
if not self.user.email:
return
sent_email, created = MSentEmail.objects.get_or_create(receiver_user_id=self.user.pk,
email_type='first_share')
if not created and not force:
return
social_profile = MSocialProfile.objects.get(user_id=self.user.pk)
params = {
'shared_stories': MSharedStory.objects.filter(user_id=self.user.pk).count(),
'blurblog_url': social_profile.blurblog_url,
'blurblog_rss': social_profile.blurblog_rss
}
user = self.user
text = render_to_string('mail/email_first_share_to_blurblog.txt', params)
html = render_to_string('mail/email_first_share_to_blurblog.xhtml', params)
subject = "Your shared stories on NewsBlur are available on your Blurblog"
msg = EmailMultiAlternatives(subject, text,
from_email='NewsBlur <%s>' % settings.HELLO_EMAIL,
to=['%s <%s>' % (user, user.email)])
msg.attach_alternative(html, "text/html")
msg.send(fail_silently=True)
logging.user(self.user, "~BB~FM~SBSending first share to blurblog email to: %s" % self.user.email)
def send_new_premium_email(self, force=False):
subs = UserSubscription.objects.filter(user=self.user)

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
from apps.profile import views
urlpatterns = patterns('',

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
from apps.push import views
urlpatterns = patterns('',

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
from apps.reader import views
urlpatterns = patterns('',

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
from apps.recommendations import views
urlpatterns = patterns('',

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import url, patterns
from django.conf.urls import url, patterns
from apps.rss_feeds import views
urlpatterns = patterns('',

View file

@ -114,6 +114,13 @@ class MSocialProfile(mongo.Document):
self.username_slug,
Site.objects.get_current().domain.replace('www.', ''))
@property
def blurblog_rss(self):
return "%s%s" % (self.blurblog_url, reverse('shared-stories-rss-feed',
kwargs={'user_id': self.user_id,
'username': self.username_slug}))
def recommended_users(self):
r = redis.Redis(connection_pool=settings.REDIS_POOL)
following_key = "F:%s:F" % (self.user_id)

View file

@ -25,6 +25,12 @@ class EmailFollowRequest(Task):
def run(self, follower_user_id, followee_user_id):
user_profile = MSocialProfile.get_user(followee_user_id)
user_profile.send_email_for_follow_request(follower_user_id)
class EmailFirstShare(Task):
def run(self, user_id):
user = User.objects.get(pk=user_id)
user.profile.send_first_share_to_blurblog_email()
class EmailCommentReplies(Task):

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import url, patterns
from django.conf.urls import url, patterns
from apps.social import views
urlpatterns = patterns('',

View file

@ -17,7 +17,7 @@ from apps.rss_feeds.models import MStory, Feed, MStarredStory
from apps.social.models import MSharedStory, MSocialServices, MSocialProfile, MSocialSubscription, MCommentReply
from apps.social.models import MInteraction, MActivity, MFollowRequest
from apps.social.tasks import PostToService, EmailCommentReplies, EmailStoryReshares
from apps.social.tasks import UpdateRecalcForSubscription
from apps.social.tasks import UpdateRecalcForSubscription, EmailFirstShare
from apps.analyzer.models import MClassifierTitle, MClassifierAuthor, MClassifierFeed, MClassifierTag
from apps.analyzer.models import apply_classifier_titles, apply_classifier_feeds, apply_classifier_authors, apply_classifier_tags
from apps.analyzer.models import get_classifiers_for_user, sort_classifiers_by_feed
@ -553,6 +553,8 @@ def mark_story_as_shared(request):
EmailStoryReshares.apply_async(kwargs=dict(shared_story_id=shared_story.id),
countdown=settings.SECONDS_TO_DELAY_CELERY_EMAILS)
EmailFirstShare.apply_async(kwargs=dict(user_id=request.user.pk))
if format == 'html':
stories = MSharedStory.attach_users_to_stories(stories, profiles)
return render_to_response('social/social_story.xhtml', {

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
from apps.statistics import views
urlpatterns = patterns('',

View file

@ -0,0 +1,13 @@
{% extends "mail/email_base.txt" %}
{% block body %}Your shared story is now on your Blurblog
You can view your Blurblog here: {{ blurblog_url }}
Your Blurblog also has an RSS feed: {{ blurblog_rss }}
{% if shared_stories > 1 %}You've already shared {{ shared_stories }} stories, but you may not have known that your shared stories are on your Blurblog.{% else %}You just shared your first story on NewsBlur. All of your shared stories are available on your Blurblog.{% endif %}
This is a personal website made for you that you can customize. You can also share out links to your blurblog, where friends and followers can reply and re-share your stories.
Blurblogs were built so you would have a way to share stories with people who aren't on NewsBlur and don't want to load the entire reader just to read and comment on your shared stories.{% endblock body %}

View file

@ -0,0 +1,10 @@
{% extends "mail/email_base.xhtml" %}
{% block body %}
<p style="font-size: 37px; color:#555555; margin-top: 18px;margin-bottom: 10px;padding-top:6px;">Your shared story is now on your Blurblog</p>
<p style="line-height: 20px;">You can view your Blurblog here: {{ blurblog_url }}</p>
<p style="line-height: 20px;">Your Blurblog also has an RSS feed: {{ blurblog_rss }}</p>
<p style="line-height: 20px;">{% if shared_stories > 1 %}You've already shared {{ shared_stories }} stories, but you may not have known that your shared stories are on your Blurblog.{% else %}You just shared your first story on NewsBlur. All of your shared stories are available on your Blurblog.{% endif %}</p>
<p style="line-height: 20px;">This is a personal website made for you that you can customize. You can also share out links to your blurblog, where friends and followers can reply and re-share your stories.</p>
<p style="line-height: 20px;">Blurblogs were built so you would have a way to share stories with people who aren't on NewsBlur and don't want to load the entire reader just to read and comment on your shared stories.</p>
{% endblock %}

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import include, url, patterns
from django.conf.urls import include, url, patterns
from django.conf import settings
from apps.reader import views as reader_views
from apps.static import views as static_views

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
urlpatterns = patterns('paypal.standard.ipn.views',
(r'^ipn/$', 'ipn'),

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
urlpatterns = patterns('paypal.standard.ipn.views',
url(r'^$', 'ipn', name="paypal-ipn"),

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
urlpatterns = patterns('paypal.standard.pdt.views',
(r'^pdt/$', 'pdt'),

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
urlpatterns = patterns('paypal.standard.pdt.views',
url(r'^$', 'pdt', name="paypal-pdt"),

View file

@ -1,4 +1,4 @@
from django.conf.urls.defaults import *
from django.conf.urls import *
from zebra import views