You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/03/04 22:11:45 UTC
[2/5] git commit: [#6305] ticket:535 Merged email notifications for
ticket changes.
[#6305] ticket:535 Merged email notifications for ticket changes.
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/1d8f6572
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1d8f6572
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1d8f6572
Branch: refs/heads/master
Commit: 1d8f65722f04cd19a9eaf4345874eaf233daaaaa
Parents: 15f9c5c
Author: Ferens Dmitriy <fe...@gmail.com>
Authored: Mon Feb 24 17:04:03 2014 +0200
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Mar 4 20:32:09 2014 +0000
----------------------------------------------------------------------
Allura/allura/model/discuss.py | 17 ++++++++++-------
Allura/allura/model/notification.py | 2 +-
.../forgetracker/data/ticket_changed_tmpl | 2 ++
ForgeTracker/forgetracker/tracker_main.py | 18 ++++++++++--------
4 files changed, 23 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1d8f6572/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index c5762a9..b9f25d1 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -256,8 +256,9 @@ class Thread(Artifact, ActivityObject):
else:
return g.spam_checker.check(post.text, artifact=post, user=c.user)
- def post(self, text, message_id=None, parent_id=None,
- timestamp=None, ignore_security=False, is_meta=False, **kw):
+ def post(self, text, message_id=None, parent_id=None, notify=True,
+ notification_text=None, timestamp=None, ignore_security=False,
+ is_meta=False, **kw):
if not ignore_security:
require_access(self, 'post')
if self.ref_id and self.artifact:
@@ -283,7 +284,8 @@ class Thread(Artifact, ActivityObject):
if ignore_security or not self.is_spam(post) and has_access(self, 'unmoderated_post')():
log.info('Auto-approving message from %s', c.user.username)
file_info = kw.get('file_info', None)
- post.approve(file_info, notify=kw.get('notify', True))
+ post.approve(file_info, notify=notify,
+ notification_text=notification_text)
else:
self.notify_moderators(post)
return post
@@ -659,7 +661,7 @@ class Post(Message, VersionedArtifact, ActivityObject):
super(Post, self).delete()
self.thread.num_replies = max(0, self.thread.num_replies - 1)
- def approve(self, file_info=None, notify=True):
+ def approve(self, file_info=None, notify=True, notification_text=None):
if self.status == 'ok':
return
self.status = 'ok'
@@ -674,7 +676,7 @@ class Post(Message, VersionedArtifact, ActivityObject):
security.simple_grant(
self.acl, author_role._id, 'unmoderated_post')
if notify:
- self.notify(file_info=file_info)
+ self.notify(file_info=file_info, notification_text=notification_text)
artifact = self.thread.artifact or self.thread
session(self).flush()
self.thread.last_post_date = max(
@@ -688,14 +690,15 @@ class Post(Message, VersionedArtifact, ActivityObject):
related_nodes=[self.app_config.project],
tags=['comment'])
- def notify(self, file_info=None, check_dup=False):
+ def notify(self, file_info=None, check_dup=False, notification_text=None):
if self.project.notifications_disabled:
return # notifications disabled for entire project
artifact = self.thread.artifact or self.thread
n = Notification.query.get(
_id=artifact.url() + self._id) if check_dup else None
if not n:
- n = Notification.post(artifact, 'message', post=self,
+ n = Notification.post(artifact, 'message',
+ post=self, text=notification_text,
file_info=file_info)
if not n:
return
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1d8f6572/Allura/allura/model/notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index d0e9f29..ce92a4c 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -151,7 +151,7 @@ class Notification(MappedClass):
post = ''
if topic == 'message':
post = kwargs.pop('post')
- text = post.text
+ text = kwargs.get('text', post.text)
file_info = kwargs.pop('file_info', None)
if file_info is not None:
text = "%s\n\n\nAttachment:" % text
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1d8f6572/ForgeTracker/forgetracker/data/ticket_changed_tmpl
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/data/ticket_changed_tmpl b/ForgeTracker/forgetracker/data/ticket_changed_tmpl
index 3043949..763b8ed 100644
--- a/ForgeTracker/forgetracker/data/ticket_changed_tmpl
+++ b/ForgeTracker/forgetracker/data/ticket_changed_tmpl
@@ -54,3 +54,5 @@ ${'\n'.join(difflib.unified_diff(
{% end %}\
{% end %}\
{% end %}\
+{% if comment %}- **Comment**:
+${comment}{% end %}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1d8f6572/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 193570d..b1ea985 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -19,6 +19,7 @@
import logging
import re
from datetime import datetime, timedelta
+from functools import partial
from urllib import urlencode, unquote
from webob import exc
import json
@@ -1424,16 +1425,17 @@ class TicketController(BaseController, FeedController):
changes[cf.label] = cf_val(cf)
self.ticket.custom_fields[cf.name] = value
changes[cf.label] = cf_val(cf)
+
+ tpl = pkg_resources.resource_filename(
+ 'forgetracker','data/ticket_changed_tmpl')
+ render = partial(h.render_genshi_plaintext, tpl, changelist=changes.get_changed())
+ post_text = render(comment=None)
+ notification_text = render(comment=comment) if comment else None
thread = self.ticket.discussion_thread
- tpl_fn = pkg_resources.resource_filename(
- 'forgetracker', 'data/ticket_changed_tmpl')
- change_text = h.render_genshi_plaintext(
- tpl_fn,
- changelist=changes.get_changed())
- thread.add_post(text=change_text, is_meta=True)
+ thread.add_post(text=post_text, is_meta=True,
+ notification_text=notification_text)
self.ticket.commit()
- if comment:
- self.ticket.discussion_thread.post(text=comment)
+ if comment: thread.post(text=comment, notify=False)
g.director.create_activity(c.user, 'modified', self.ticket,
related_nodes=[c.project], tags=['ticket'])
c.app.globals.invalidate_bin_counts()