[Zope3-checkins] CVS: zopeproducts/zwiki/browser - subscriptions.pt:1.1 configure.zcml:1.4 wikipage.py:1.4

Stephan Richter srichter@cbu.edu
Thu, 10 Apr 2003 21:37:46 -0400


Update of /cvs-repository/zopeproducts/zwiki/browser
In directory cvs.zope.org:/tmp/cvs-serv29237/browser

Modified Files:
	configure.zcml wikipage.py 
Added Files:
	subscriptions.pt 
Log Message:
- Checked in a diff modules for making diffs between the old and the new
  version of the Wiki Page contents

- Added very simple mail subscription

- Some more Tweaks in the older code.

Ok, I am too tired to write more senseful things right now...


=== Added File zopeproducts/zwiki/browser/subscriptions.pt ===
<html metal:use-macro="views/standard_macros/page">
  <head>
    <style metal:fill-slot="style_slot">
    </style>
  </head>
  <body>
    <div metal:fill-slot="body">

      <form action="changeSubscriptions.html" method="post" 
            i18n:domain="wiki">

        <div class="row">
            <div class="label" i18n:translate="">Current Subscriptions</div>
            <div class="field">
	      <div tal:repeat="email view/subscriptions">
                <input type="checkbox" name="remails:list" 
                       value="" tal:attributes="value email">
                <div tal:replace="email">zope3@zope3.org</div>
              </div>
              <input type="submit" name="REMOVE" value="Remove" 
                   i18n:attributes="value remove-button">
            </div>
        </div>

        <div class="row">
            <div class="label" i18n:translate="">
              Enter new Users (separate by 'Return')
            </div>
            <div class="field">
	      <textarea name="emails" cols="40" rows="10"></textarea>
            </div>
        </div>

      	<div class="row">
      	  <div class="controls">
      	    <input type="submit" value="Refresh" 
                i18n:attributes="value refresh-button" />
      	    <input type="submit" name="ADD" value="Add" 
      		i18n:attributes="value add-button" />
      	  </div>
      	</div>

      </form>

    </div>
  </body>
</html>


=== zopeproducts/zwiki/browser/configure.zcml 1.3 => 1.4 ===
--- zopeproducts/zwiki/browser/configure.zcml:1.3	Thu Apr 10 07:31:39 2003
+++ zopeproducts/zwiki/browser/configure.zcml	Thu Apr 10 21:37:46 2003
@@ -48,6 +48,15 @@
       permission="zopeproducts.zwiki.ViewWikiPage"
       menu="zmi_views" title="Search"/>
 
+  <browser:pages
+      for="zopeproducts.zwiki.interfaces.IWiki"
+      class=".wikipage.MailSubscriptions"
+      permission="zopeproducts.zwiki.EditWikiPage">
+      <browser:page name="subscriptions.html" template="subscriptions.pt"
+          menu="zmi_views" title="Subscriptions" />
+      <browser:page name="changeSubscriptions.html" attribute="change" />
+  </browser:pages>
+
   <browser:defaultView
       name="toc.html"
       for="zopeproducts.zwiki.interfaces.IWiki"/>
@@ -64,7 +73,7 @@
       label="Add Wiki Page"
       name="AddWikiPage"
       schema="zopeproducts.zwiki.interfaces.IWikiPage"
-      content_factory="zopeproducts.zwiki.wiki.WikiPage"
+      content_factory="zopeproducts.zwiki.wikipage.WikiPage"
       permission="zopeproducts.zwiki.AddWikiPage"
       fields="source type"
       class=".wikipage.AddWikiPage"
@@ -118,6 +127,15 @@
       <browser:page name="addComment.html" attribute="comment" />
   </browser:pages>
 
+  <browser:pages
+      for="zopeproducts.zwiki.interfaces.IWikiPage"
+      class=".wikipage.MailSubscriptions"
+      permission="zopeproducts.zwiki.EditWikiPage">
+      <browser:page name="subscriptions.html" template="subscriptions.pt"
+          menu="zmi_views" title="Subscriptions" />
+      <browser:page name="changeSubscriptions.html" attribute="change" />
+  </browser:pages>
+
   <browser:defaultView
       name="view.html"
       for="zopeproducts.zwiki.interfaces.IWikiPage"/>
@@ -142,12 +160,14 @@
     <browser:menuItem title="Edit" action="@@edit.html"/>
     <browser:menuItem title="Parents" action="@@parents.html"/>
     <browser:menuItem title="TOC" action="@@toc.html"/>
+    <browser:menuItem title="Subscriptions" action="@@subscriptions.html"/>
   </browser:menuItems>
 
   <browser:menuItems menu="wikipage_actions" 
       for="zopeproducts.zwiki.interfaces.IWiki">
     <browser:menuItem title="Table of Contents" action="@@toc.html"/>
     <browser:menuItem title="Search" action="@@search.html"/>
+    <browser:menuItem title="Subscriptions" action="@@subscriptions.html"/>
   </browser:menuItems>
 
   <!-- Register a browser-specific traverser --> 


=== zopeproducts/zwiki/browser/wikipage.py 1.3 => 1.4 ===
--- zopeproducts/zwiki/browser/wikipage.py:1.3	Thu Apr 10 08:50:41 2003
+++ zopeproducts/zwiki/browser/wikipage.py	Thu Apr 10 21:37:46 2003
@@ -27,7 +27,8 @@
 from zope.app.form.widget import CustomWidget
 from zope.app.traversing import getParent, getPath, objectName
 
-from zopeproducts.zwiki.interfaces import IWikiPageHierarchy
+from zopeproducts.zwiki.interfaces import \
+     IWikiPageHierarchy, IMailSubscriptions
 
 urlchars = r'[A-Za-z0-9/:@_%~#=&\.\-\?\+\$,]+'
 urlendchar  = r'[A-Za-z0-9/]'
@@ -325,3 +326,23 @@
     def source(self):
         return '> ' + self.context.source.replace('\n', '\n> ')
 
+
+class MailSubscriptions:
+
+    def subscriptions(self):
+        return getAdapter(self.context, IMailSubscriptions).getSubscriptions()
+
+    def change(self):
+        if 'ADD' in self.request:
+            emails = self.request['emails'].split('\n')
+            getAdapter(self.context,
+                       IMailSubscriptions).addSubscriptions(emails)
+        elif 'REMOVE' in self.request:
+            emails = self.request['remails']
+            print emails
+            if isinstance(emails, (str, unicode)):
+                emails = [emails]
+            getAdapter(self.context,
+                       IMailSubscriptions).removeSubscriptions(emails)
+
+        self.request.response.redirect('.')