Mercurial > moin > 1.9
changeset 6034:f77842ede10f
email notification: internally use python template strings to assemble the subject and texts from given components
this way, one can easily leave away some stuff (e.g. the diff display) or do minor changes (like always linking to the full page, not the diff view).
not configurable yet, will come in separate changeset.
removed notification.page_link - was only used at 1 place.
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Fri, 28 Feb 2014 20:04:49 +0100 |
parents | f70b9ab3dedc |
children | be1e6321ba13 |
files | MoinMoin/events/emailnotify.py MoinMoin/events/notification.py |
diffstat | 2 files changed, 21 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/events/emailnotify.py Fri Feb 28 19:38:41 2014 +0100 +++ b/MoinMoin/events/emailnotify.py Fri Feb 28 20:04:49 2014 +0100 @@ -35,28 +35,35 @@ change = notification.page_change_message("page_changed", request, page, email_lang, comment=comment, revisions=revisions) _ = lambda text: request.getText(text, lang=email_lang) + intro = change['text'] + diff = change['diff'] + + if change.has_key('comment'): + comment = _("Comment:") + "\n" + change['comment'] + "\n\n" + else: + comment = '' + if len(revisions) >= 2: querystr = {'action': 'diff', 'rev2': str(revisions[0]), 'rev1': str(revisions[1])} else: querystr = {} - - pagelink = "%(link)s\n\n" % {'link': notification.page_link(request, page, querystr)} + # links to diff or to page (if only 1 rev): + difflink = request.getQualifiedURL(page.url(request, querystr)) + # always links to page: + pagelink = request.getQualifiedURL(page.url(request)) - subject = _('[%(sitename)s] %(trivial)sUpdate of "%(pagename)s" by %(username)s') % { - 'trivial': (trivial and _("Trivial ")) or "", - 'sitename': page.cfg.sitename or "Wiki", - 'pagename': page.page_name, - 'username': page.uid_override or user.getUserIdentification(request), - } + trivial = (trivial and _("Trivial ")) or "" + sitename = page.cfg.sitename or "Wiki" + pagename = page.page_name + username = page.uid_override or user.getUserIdentification(request) - if change.has_key('comment'): - comment = _("Comment:") + "\n" + change['comment'] + "\n\n" - else: - comment = '' - - return {'subject': subject, 'text': change['text'] + pagelink + comment + change['diff']} + subject_template = _('[%(sitename)s] %(trivial)sUpdate of "%(pagename)s" by %(username)s') + subject = subject_template % locals() + text_template = '%(intro)s%(difflink)s\n\n%(comment)s%(diff)s' + text = text_template % locals() + return {'subject': subject, 'text': text} def send_notification(request, from_address, emails, data):
--- a/MoinMoin/events/notification.py Fri Feb 28 19:38:41 2014 +0100 +++ b/MoinMoin/events/notification.py Fri Feb 28 20:04:49 2014 +0100 @@ -48,17 +48,6 @@ pass -def page_link(request, page, querystr): - """Create an absolute url to a given page with optional action - - @param page: a page to link to - @type page: MoinMoin.Page.Page - @param querystr: a dict passed to wikiutil.makeQueryString - - """ - return request.getQualifiedURL(page.url(request, querystr)) - - def page_change_message(msgtype, request, page, lang, **kwargs): """Prepare a notification text for a page change of given type