Skip to content

Commit

Permalink
#212 notify project watcher of tag activity
Browse files Browse the repository at this point in the history
  • Loading branch information
tonylampada committed Dec 30, 2013
1 parent 27904b3 commit b27819b
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 1 deletion.
32 changes: 32 additions & 0 deletions djangoproject/core/services/mail_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,38 @@ def send_func(watch):
_notify_watchers(send_func, watches)


def notifyWatchers_project_tag_added(user, project, tag, watches):
def send_func(watch):
if watch.user.id != user.id:
_send_mail_to_user(user=watch.user,
subject=user.getUserInfo().screenName + " added the tag [%s] to project [%s]" % (tag, project.name),
templateName='email/project_tag_added.html',
contextData={"project": project,
"user": user,
"you": watch.user,
"SITE_HOME": settings.SITE_HOME,
"tag": tag,
},
whentrue='receiveEmail_issue_work')
_notify_watchers(send_func, watches)


def notifyWatchers_project_tag_removed(user, project, tag, watches):
def send_func(watch):
if watch.user.id != user.id:
_send_mail_to_user(user=watch.user,
subject=user.getUserInfo().screenName + " removed tag [%s] from project [%s]" % (tag, project.name),
templateName='email/project_tag_removed.html',
contextData={"project": project,
"user": user,
"you": watch.user,
"SITE_HOME": settings.SITE_HOME,
"tag": tag,
},
whentrue='receiveEmail_issue_work')
_notify_watchers(send_func, watches)


def notifyWatchers_acceptingpayments(solution, watches):
def send_func(watch):
if(watch.user.id != solution.programmer.id):
Expand Down
6 changes: 5 additions & 1 deletion djangoproject/core/views/json_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.http import HttpResponse
from django.utils.translation import ugettext as _
import json
from core.services import issue_services, tag_services, activity_services, watch_services
from core.services import issue_services, tag_services, activity_services, watch_services, mail_services
import traceback
import logging
from django.contrib.auth.decorators import login_required
Expand Down Expand Up @@ -79,6 +79,8 @@ def add_tag(request):
if not objtype in ['Project', 'Issue']:
raise BaseException('Wrong objtype: %s' % objtype)
tag_services.addTag(name, objtype, objid)
watches = watch_services.find_project_watches(project)
mail_services.notifyWatchers_project_tag_added(request.user, project, name, watches)
ActionLog.log_project_tag_added(user=request.user, project_id=objid, tag_name=name)
return HttpResponse('')

Expand All @@ -89,6 +91,8 @@ def remove_tag(request):
objtype = request.POST.get('objtype')
objid = int(request.POST.get('objid'))
tag_services.removeTag(name, objtype, objid)
watches = watch_services.find_project_watches(project)
mail_services.notifyWatchers_project_tag_removed(request.user, project, name, watches)
ActionLog.log_project_tag_removed(user=request.user, project_id=objid, tag_name=name)
return HttpResponse('')

Expand Down
17 changes: 17 additions & 0 deletions djangoproject/templates/email/project_tag_added.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% extends "email/base.html" %}
{% block mainContent%}
Hello {{ you.getUserInfo.screenName }}<br>
<a href="{{SITE_HOME}}{{ user.get_view_link }}" style="color: #08C;text-decoration: none;cursor: auto;">
{{ user.getUserInfo.screenName }}
</a>
added the tag <strong>{{ tag }}</strong> to project
<a href="{{SITE_HOME}}/project/{{ project.id }}">{{ project.name }}</a>
project.<br><br>

We will let you know if there are any updates.

<br><br>
{% include 'email/include/email_settings_notice.html' %}

{% endblock mainContent%}

17 changes: 17 additions & 0 deletions djangoproject/templates/email/project_tag_removed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% extends "email/base.html" %}
{% block mainContent%}
Hello {{ you.getUserInfo.screenName }}<br>
<a href="{{SITE_HOME}}{{ user.get_view_link }}" style="color: #08C;text-decoration: none;cursor: auto;">
{{ user.getUserInfo.screenName }}
</a>
removed tag <strong>{{ tag }}</strong> from project
<a href="{{SITE_HOME}}/project/{{ project.id }}">{{ project.name }}</a>
project.<br><br>

We will let you know if there are any updates.

<br><br>
{% include 'email/include/email_settings_notice.html' %}

{% endblock mainContent%}

0 comments on commit b27819b

Please sign in to comment.