changeset 2470:f15b9bf952d4

Merge devel.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Fri, 20 Jul 2007 02:57:58 +0200
parents 474b7a1fc031 (current diff) 663867be4afc (diff)
children 572f8ce1adff
files
diffstat 5 files changed, 45 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Fri Jul 20 01:56:33 2007 +0200
+++ b/MoinMoin/PageEditor.py	Fri Jul 20 02:57:58 2007 +0200
@@ -1055,7 +1055,11 @@
             if notify:
                 # send notifications
                 from MoinMoin import events
-                e = events.PageChangedEvent(self.request, self, comment, trivial)
+
+                if trivial:
+                    e = events.TrivialPageChangedEvent(self.request, self, comment)
+                else:
+                    e = events.PageChangedEvent(self.request, self, comment)
                 results = events.send_event(e)
 
                 recipients = set()
--- a/MoinMoin/events/__init__.py	Fri Jul 20 01:56:33 2007 +0200
+++ b/MoinMoin/events/__init__.py	Fri Jul 20 02:57:58 2007 +0200
@@ -41,14 +41,24 @@
 
 class PageChangedEvent(PageEvent):
 
-    description = _(u"""Page has been modified (edit, creation, deletion)""")
+    description = _(u"""Page has been modified""")
     req_superuser = False
 
-    def __init__(self, request, page, comment, trivial):
+    def __init__(self, request, page, comment):
         PageEvent.__init__(self, request)
         self.page = page
         self.comment = comment
-        self.trivial = trivial
+
+
+class TrivialPageChangedEvent(PageEvent):
+
+    description = _(u"Page has been modified in a trivial fashion")
+    req_superuser = False
+
+    def __init__(self, request, page, comment):
+        PageEvent.__init__(self, request)
+        self.page = page
+        self.comment = comment
 
 
 class PageRenamedEvent(PageEvent):
@@ -113,7 +123,7 @@
 
 class SubscribedToPageEvent(PageEvent):
 
-    description = _(u"""An user has subscribed to a page""")
+    description = _(u"""A user has subscribed to a page""")
     req_superuser = True
 
     def __init__(self, request, pagename, username):
--- a/MoinMoin/events/emailnotify.py	Fri Jul 20 01:56:33 2007 +0200
+++ b/MoinMoin/events/emailnotify.py	Fri Jul 20 02:57:58 2007 +0200
@@ -17,8 +17,8 @@
 from MoinMoin import user
 from MoinMoin.Page import Page
 from MoinMoin.mail import sendmail
-from MoinMoin.events import PageChangedEvent, UserCreatedEvent, FileAttachedEvent
 from MoinMoin.user import User, getUserList
+import MoinMoin.events as ev
 import MoinMoin.events.notification as notification
 
 
@@ -80,7 +80,7 @@
         # send email to all subscribers
         for lang in subscribers:
             users = [u for u in subscribers[lang]
-                     if PageChangedEvent.__name__ in u.email_subscribed_events]
+                     if ev.PageChangedEvent.__name__ in u.email_subscribed_events]
             emails = [u.email for u in users]
             names = [u.name for u in users]
             data = prep_page_changed_mail(request, page, comment, lang, revisions, trivial)
@@ -152,9 +152,11 @@
     if not event.request.cfg.mail_enabled:
         return
 
-    if isinstance(event, PageChangedEvent):
-        return notify_subscribers(event.request, event.page, event.comment, event.trivial)
-    elif isinstance(event, UserCreatedEvent):
+    if isinstance(event, ev.PageChangedEvent):
+        return notify_subscribers(event.request, event.page, event.comment, False)
+    elif isinstance(event, ev.TrivialPageChangedEvent):
+        return notify_subscribers(event.request, event.page, event.comment, True)
+    elif isinstance(event, ev.UserCreatedEvent):
         return handle_user_created(event)
-    elif isinstance(event, FileAttachedEvent):
+    elif isinstance(event, ev.FileAttachedEvent):
         return handle_file_attached(event)
--- a/MoinMoin/events/jabbernotify.py	Fri Jul 20 01:56:33 2007 +0200
+++ b/MoinMoin/events/jabbernotify.py	Fri Jul 20 02:57:58 2007 +0200
@@ -32,7 +32,9 @@
         return
 
     if isinstance(event, ev.PageChangedEvent):
-        return handle_page_changed(event)
+        return handle_page_changed(event, False)
+    elif isinstance(event, ev.TrivialPageChangedEvent):
+        return handle_page_changed(event, True)
     elif isinstance(event, ev.JabberIDSetEvent) or isinstance(event, ev.JabberIDUnsetEvent):
         return handle_jid_changed(event)
     elif isinstance(event, ev.FileAttachedEvent):
@@ -91,12 +93,12 @@
     return notification.Success(names)
 
 
-def handle_page_changed(event):
+def handle_page_changed(event, trivial):
     """ Handles events related to page changes """
     request = event.request
     page = event.page
 
-    subscribers = page.getSubscribers(request, return_users=1, trivial=event.trivial)
+    subscribers = page.getSubscribers(request, return_users=1, trivial=trivial)
     notification.filter_subscriber_list(event, subscribers, True)
     return page_change("page_changed", request, page, subscribers, \
                        revisions=page.getRevList(), comment=event.comment)
--- a/MoinMoin/userprefs/notification.py	Fri Jul 20 01:56:33 2007 +0200
+++ b/MoinMoin/userprefs/notification.py	Fri Jul 20 02:57:58 2007 +0200
@@ -126,14 +126,15 @@
                         type='checkbox',
                         checked=checked,
                         name='subscribe:%s:%s' % (notiftype, evname))))
-            tr.append(html.TD().append(html.Raw(evdescr)))
+            tr.append(html.TD().append(html.Raw(self.request.getText(evdescr))))
 
         return table
 
     def create_form(self):
         """ Create the complete HTML form code. """
         _ = self._
-        self._form = self.make_form()
+        self._form = self.make_form(
+            _('Select the events you want to be notified about.'))
 
         self._form.append(html.INPUT(type="hidden", name="action", value="userprefs"))
         self._form.append(html.INPUT(type="hidden", name="handler", value="prefs"))
@@ -149,19 +150,17 @@
 
         self.make_row(_('Subscribed events'), [self._event_select()])
 
-        # subscribed pages
-        if self.cfg.mail_enabled:
-            # Get list of subscribe pages, DO NOT sort! it should
-            # stay in the order the user entered it in his input
-            # box.
-            notifylist = self.request.user.getSubscriptionList()
+        # Get list of subscribe pages, DO NOT sort! it should
+        # stay in the order the user entered it in his input
+        # box.
+        notifylist = self.request.user.getSubscriptionList()
 
-            self.make_row(
-                html.Raw(_('Subscribed wiki pages[[BR]](one regex per line)')),
-                [html.TEXTAREA(name="subscribed_pages", rows="6", cols="50").append(
-                    '\n'.join(notifylist)), ],
-                valign="top"
-            )
+        self.make_row(
+            html.Raw(_('Subscribed wiki pages[[BR]](one regex per line)')),
+            [html.TEXTAREA(name="subscribed_pages", rows="6", cols="50").append(
+                '\n'.join(notifylist)), ],
+            valign="top"
+        )
 
         # Add buttons
         self.make_row('', [