mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Adding email for new followers as a background task.
This commit is contained in:
parent
16781c6450
commit
b17552c256
3 changed files with 67 additions and 0 deletions
18
apps/social/tasks.py
Normal file
18
apps/social/tasks.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from celery.task import Task
|
||||
from apps.social.models import MSharedStory, MSocialProfile
|
||||
|
||||
|
||||
class PostToService(Task):
|
||||
|
||||
def run(self, shared_story_id, service):
|
||||
try:
|
||||
shared_story = MSharedStory.objects.get(id=shared_story_id)
|
||||
shared_story.post_to_service(service)
|
||||
except MSharedStory.DoesNotExist:
|
||||
print "Story not found (%s). Can't post to: %s" % (shared_story_id, service)
|
||||
|
||||
class EmailNewFollower(Task):
|
||||
|
||||
def run(self, follower_user_id, followee_user_id):
|
||||
user_profile = MSocialProfile.objects.get(user_id=followee_user_id)
|
||||
user_profile.send_email_for_new_follower(follower_user_id)
|
13
templates/mail/email_new_follower.txt
Normal file
13
templates/mail/email_new_follower.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
{% extends "mail/email_base.txt" %}
|
||||
|
||||
{% block body %}Say hello to your newest follower: {{ follower_profile.username }}.
|
||||
|
||||
{% if common_followers %}You follow {{ common_followers|length }} {{ common_followers|pluralize:"person,people" }} who follow {{ follower_profile.username }}:
|
||||
|
||||
{% for follower in common_followers %} * {{ follower.username }}
|
||||
{% endfor %}{% endif %}
|
||||
|
||||
{% if common_followings %}You follow {{ common_followers|length }} {{ common_followers|pluralize:"person,people" }} that {{ follower_profile.username }} also follows:
|
||||
|
||||
{% for following in common_followings %} * {{ following.username }}
|
||||
{% endfor %}{% endif %}{% endblock %}
|
36
templates/mail/email_new_follower.xhtml
Normal file
36
templates/mail/email_new_follower.xhtml
Normal file
|
@ -0,0 +1,36 @@
|
|||
{% extends "mail/email_base.xhtml" %}
|
||||
|
||||
{% block body %}
|
||||
<p style="font-size: 37px; color:#555555; margin-top: 18px;margin-bottom: 10px;padding-top:6px;">
|
||||
Say hello to your newest follower:
|
||||
</p>
|
||||
<div style="margin: 24px 0;font-size: 24px;text-align: center;">
|
||||
<img src="{{ follower_profile.photo_url }}" style="max-width: 200px; max-height: 200px;margin: 0 auto;border-radius: 3px;">
|
||||
<div style="margin: 8px 0 0 0;font-weight: bold;">{{ follower_profile.username }}</div>
|
||||
</div>
|
||||
|
||||
{% if common_followers %}
|
||||
<div style="clear: both; overflow: hidden">
|
||||
<p style="margin: 12px 0 12px;line-height: 16px;clear: both;">You follow {{ common_followers|length }} {{ common_followers|pluralize:"person,people" }} who follow{{ common_followers|pluralize:"s," }} {{ follower_profile.username }}:</p>
|
||||
{% for follower in common_followers %}
|
||||
<div style="margin: 0 12px 12px 0; float: left;">
|
||||
<img src="{{ follower.email_photo_url }}" style="float: left; border-radius: 3px;margin-right: 6px; width: 24px; height: 24px;">
|
||||
{{ follower.username }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if common_followings %}
|
||||
<div style="clear: both; overflow: hidden">
|
||||
<p style="display: block; margin: 12px 0 12px;line-height: 16px;clear: both;">You and {{ follower_profile.username }} both follow {{ common_followings|length }} {{ common_followings|pluralize:"person,people" }}:</p>
|
||||
{% for following in common_followings %}
|
||||
<div style="margin: 0 12px 24px 0; float: left;">
|
||||
<img src="{{ following.email_photo_url }}" style="float: left; border-radius: 3px;margin-right: 6px; width: 24px; height: 24px;">
|
||||
{{ following.username }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
Loading…
Add table
Reference in a new issue