Exemple #1
0
def page_change(change_type, request, page, subscribers, **kwargs):
    """Sends notification about page being changed in some way"""

    # send notifications to all subscribers
    if subscribers:
        recipients = set()

        for lang in subscribers:
            _ = lambda text: request.getText(text, lang=lang)
            jids = [u.jid for u in subscribers[lang] if u.jid]
            names = [u.name for u in subscribers[lang] if u.jid]
            msg = notification.page_change_message(change_type, request, page,
                                                   lang, **kwargs)
            page_url = request.getQualifiedURL(page.url(request))
            url = {'url': page_url, 'description': _("Changed page")}
            data = {
                'action': change_type,
                'subject': _('Page changed'),
                'url_list': [url],
                'text': msg['text'],
                'diff': msg.get('diff', ''),
                'comment': msg.get('comment', ''),
                'editor': msg['editor'],
                'old_name': msg.get('old_name', ''),
                'page_name': msg.get('page_name', ''),
                'revision': msg.get('revision', '')
            }

            result = send_notification(request, jids, data)

            if result:
                recipients.update(names)

        if recipients:
            return notification.Success(recipients)
Exemple #2
0
def prep_page_changed_mail(request, page, comment, email_lang, revisions, trivial):
    """ Prepare information required for email notification about page change

    @param page: the modified page instance
    @param comment: editor's comment given when saving the page
    @param email_lang: language of email
    @param revisions: revisions of this page (newest first!)
    @param trivial: the change is marked as trivial
    @return: dict with email title and body
    @rtype: dict

    """
    change = notification.page_change_message("page_changed", request, page, email_lang, comment=comment, revisions=revisions)
    _ = lambda text: request.getText(text, lang=email_lang)

    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)}

    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),
        }

    return {'subject': subject, 'text': change['text'] + pagelink + change['diff']}
Exemple #3
0
def page_change(change_type, request, page, subscribers, **kwargs):
    """Sends notification about page being changed in some way"""

    # send notifications to all subscribers
    if subscribers:
        recipients = set()

        for lang in subscribers:
            _ = lambda text: request.getText(text, lang=lang)
            jids = [u.jid for u in subscribers[lang] if u.jid]
            names = [u.name for u in subscribers[lang] if u.jid]
            msg = notification.page_change_message(change_type, request, page, lang, **kwargs)
            page_url = request.getQualifiedURL(page.url(request))
            url = {'url': page_url, 'description': _("Changed page")}
            data = {'action': change_type, 'subject': _('Page changed'),
                            'url_list': [url], 'text': msg['text'], 'diff': msg.get('diff', ''),
                            'comment': msg.get('comment', ''), 'editor': msg['editor'],
                            'old_name': msg.get('old_name', ''), 'page_name': msg.get('page_name', ''),
                            'revision': msg.get('revision', '')}

            result = send_notification(request, jids, data)

            if result:
                recipients.update(names)

        if recipients:
            return notification.Success(recipients)
Exemple #4
0
def page_change(change_type, request, page, subscribers, **kwargs):
    """Sends notification about page being changed in some way"""

    # send notifications to all subscribers
    if subscribers:
        recipients = set()

        for lang in subscribers:
            _ = lambda text: request.getText(text, lang=lang)
            jids = [u.jid for u in subscribers[lang] if u.jid]
            names = [u.name for u in subscribers[lang] if u.jid]
            msg = notification.page_change_message(change_type, request, page, lang, **kwargs)
            page_url = request.getQualifiedURL(page.url(request))
            url = {"url": page_url, "description": _("Changed page")}
            data = {
                "action": change_type,
                "subject": _("Page changed"),
                "url_list": [url],
                "text": msg["text"],
                "diff": msg.get("diff", ""),
                "comment": msg.get("comment", ""),
                "editor": msg["editor"],
                "old_name": msg.get("old_name", ""),
                "page_name": msg.get("page_name", ""),
                "revision": msg.get("revision", ""),
            }

            result = send_notification(request, jids, data)

            if result:
                recipients.update(names)

        if recipients:
            return notification.Success(recipients)
Exemple #5
0
def prep_page_changed_mail(request, page, comment, email_lang, revisions,
                           trivial):
    """ Prepare information required for email notification about page change

    @param page: the modified page instance
    @param comment: editor's comment given when saving the page
    @param email_lang: language of email
    @param revisions: revisions of this page (newest first!)
    @param trivial: the change is marked as trivial
    @return: dict with email title and body
    @rtype: dict

    """
    change = notification.page_change_message("page_changed",
                                              request,
                                              page,
                                              email_lang,
                                              comment=comment,
                                              revisions=revisions)
    _ = lambda text: request.getText(text, lang=email_lang)

    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)
    }

    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),
    }

    if change.has_key('comment'):
        comment = _("Comment:") + "\n" + change['comment'] + "\n\n"
    else:
        comment = ''

    return {
        'subject': subject,
        'text': change['text'] + pagelink + comment + change['diff']
    }
def prep_page_changed_mail(request, page, comment, email_lang, revisions,
                           trivial=False, change_type="page_changed",
                           old_page=None):
    """ Prepare information required for email notification about page change

    @param page: the modified page instance
    @param comment: editor's comment given when saving the page
    @param email_lang: language of email
    @param revisions: revisions of this page (newest first!)
    @param trivial: the change is marked as trivial
    @return: dict with email title and body
    @rtype: dict

    """
    old_name = old_page and old_page.page_name or None  # for rename
    change = notification.page_change_message(change_type, request, page, email_lang,
                                              comment=comment, revisions=revisions, trivial=trivial,
                                              old_name=old_name)
    _ = lambda text: request.getText(text, lang=email_lang)
    cfg = request.cfg
    intro = change['text']
    diff = change['diff']
    subject = change['subject']

    if change.has_key('comment'):
        comment = _("Comment:") + "\n" + change['comment'] + "\n\n"
    else:
        comment = ''

    diff_revs = None
    if change_type == "page_changed" and len(revisions) >= 2:
        diff_revs = revisions[1], revisions[0]
    elif change_type == "page_deleted" and len(revisions) >= 1:
        diff_revs = revisions[0], revisions[0] + 1

    if diff_revs:
        querystr = {'action': 'diff', 'rev1': str(diff_revs[0]), 'rev2': str(diff_revs[1])}
    else:
        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))

    sitename = page.cfg.sitename or "Wiki"
    pagename = page.page_name
    username = page.uid_override or user.getUserIdentification(request)

    text = _(cfg.mail_notify_page_text) % locals()
    return {'subject': subject, 'text': text}
Exemple #7
0
def prep_page_changed_mail(request,
                           page,
                           comment,
                           email_lang,
                           revisions,
                           trivial=False,
                           change_type="page_changed",
                           old_page=None):
    """ Prepare information required for email notification about page change

    @param page: the modified page instance
    @param comment: editor's comment given when saving the page
    @param email_lang: language of email
    @param revisions: revisions of this page (newest first!)
    @param trivial: the change is marked as trivial
    @return: dict with email title and body
    @rtype: dict

    """
    old_name = old_page and old_page.page_name or None  # for rename
    change = notification.page_change_message(change_type,
                                              request,
                                              page,
                                              email_lang,
                                              comment=comment,
                                              revisions=revisions,
                                              trivial=trivial,
                                              old_name=old_name)
    _ = lambda text: request.getText(text, lang=email_lang)
    cfg = request.cfg
    intro = change['text']
    diff = change['diff']
    subject = change['subject']

    if change.has_key('comment'):
        comment = _("Comment:") + "\n" + change['comment'] + "\n\n"
    else:
        comment = ''

    diff_revs = None
    if change_type == "page_changed" and len(revisions) >= 2:
        diff_revs = revisions[1], revisions[0]
    elif change_type == "page_deleted" and len(revisions) >= 1:
        diff_revs = revisions[0], revisions[0] + 1

    if diff_revs:
        querystr = {
            'action': 'diff',
            'rev1': str(diff_revs[0]),
            'rev2': str(diff_revs[1])
        }
    else:
        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))

    sitename = page.cfg.sitename or "Wiki"
    pagename = page.page_name
    username = page.uid_override or user.getUserIdentification(request)

    text = _(cfg.mail_notify_page_text) % locals()
    return {'subject': subject, 'text': text}