[Moin-devel] CVS: MoinMoin Page.py,1.128,1.129 PageEditor.py,1.19,1.20 wikiaction.py,1.76,1.77
J?rgen Hermann
jhermann at users.sourceforge.net
Tue Jun 18 11:09:06 EDT 2002
Update of /cvsroot/moin/MoinMoin
In directory usw-pr-cvs1:/tmp/cvs-serv26603/MoinMoin
Modified Files:
Page.py PageEditor.py wikiaction.py
Log Message:
Subscriber list shown on page info
Index: Page.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/Page.py,v
retrieving revision 1.128
retrieving revision 1.129
diff -C2 -r1.128 -r1.129
*** Page.py 8 Jun 2002 21:08:41 -0000 1.128
--- Page.py 18 Jun 2002 18:08:45 -0000 1.129
***************
*** 154,157 ****
--- 154,196 ----
+ def getSubscribers(self, request, **kw):
+ """ Get all subscribers of this page.
+ Return dict with email lists per language.
+
+ include_self == 1: include current user (default: 0)
+ return_users == 1: return user instances (default: 0)
+ """
+ include_self = kw.get('include_self', 0)
+ return_users = kw.get('return_users', 0)
+
+ # extract categories of this page
+ pageList = self.getPageLinks(request)
+ CATEGORY_RE = re.compile(config.page_category_regex)
+ pageList = filter(CATEGORY_RE.match, pageList)
+
+ # add current page name for list matching
+ pageList.append(self.page_name)
+
+ # get email addresses of the all wiki user which have a profile stored;
+ # add the address only if the user has subscribed to the page and
+ # the user is not the current editor
+ userlist = user.getUserList()
+ emails = {}
+ for uid in userlist:
+ if uid == request.user.id and not include_self: continue # no self notification
+ subscriber = user.User(request, uid)
+ if not subscriber.email: continue # skip empty email address
+
+ if subscriber.isSubscribedTo(pageList):
+ lang = subscriber.language or 'en'
+ if not emails.has_key(lang): emails[lang] = []
+ if return_users:
+ emails[lang].append(subscriber)
+ else:
+ emails[lang].append(subscriber.email)
+
+ return emails
+
+
def send_page(self, request, msg=None, **keywords):
""" Send the formatted page to stdout.
Index: PageEditor.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/PageEditor.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** PageEditor.py 12 Jun 2002 21:09:48 -0000 1.19
--- PageEditor.py 18 Jun 2002 18:08:45 -0000 1.20
***************
*** 269,294 ****
Return message, indicating success or errors.
"""
! # extract categories of this page
! pageList = self.getPageLinks(request)
! CATEGORY_RE = re.compile(config.page_category_regex)
! pageList = filter(CATEGORY_RE.match, pageList)
!
! # add current page name for list matching
! pageList.append(self.page_name)
!
! # get email addresses of the all wiki user which have a profile stored;
! # add the address only if the user has subscribed to the page and
! # the user is not the current editor
! userlist = user.getUserList()
! emails = {}
! for uid in userlist:
! if uid == request.user.id: continue # no self notification
! subscriber = user.User(request, uid)
! if not subscriber.email: continue # skip empty email address
!
! if subscriber.isSubscribedTo(pageList):
! lang = subscriber.language or 'en'
! if not emails.has_key(lang): emails[lang] = []
! emails[lang].append(subscriber.email)
if emails:
--- 269,273 ----
Return message, indicating success or errors.
"""
! emails = self._getSubscribers(request)
if emails:
Index: wikiaction.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/wikiaction.py,v
retrieving revision 1.76
retrieving revision 1.77
diff -C2 -r1.76 -r1.77
*** wikiaction.py 12 Jun 2002 21:09:48 -0000 1.76
--- wikiaction.py 18 Jun 2002 18:08:45 -0000 1.77
***************
*** 296,299 ****
--- 296,309 ----
if attachment_info: attachment_info(pagename, request.form)
+ # show subscribers
+ subscribers = page.getSubscribers(request, include_self=1, return_users=1)
+ if subscribers:
+ request.write('<p>', _('The following users subscribed to this page:'))
+ for lang in subscribers.keys():
+ request.write('<br>[%s] ' % lang)
+ for user in subscribers[lang]:
+ request.write('<a href="mailto:%s">%s</a> ' % (urllib.quote(user.email), cgi.escape(user.name)))
+ request.write('</p>')
+
# show links
links = page.getPageLinks(request)
More information about the Moin-devel
mailing list