[Zope-CMF] CMFCalendar patch

Sylvain Thénault Sylvain Thénault
Fri, 20 Dec 2002 11:06:29 +0100


--9amGYk9869ThD9tj
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

hi,

I've a patch which make the calendar tool working with a custom
workflow. It allows to select in the ZMI configure's tab which states
are required for an event to be shown in the calendar.

My problem is that I'm not sure about where to submit it... Is it
http://collector.zope.org/CMF (there is no CMFCalendar topic) ?

If someone is interested, I join the patch to this mail.

-- 
Sylvain Thénault

  LOGILAB           http://www.logilab.org


--9amGYk9869ThD9tj
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="CMFCalendar.patch"

diff -ru ./CalendarTool.py /home/syt/Zope-2.6.0-src/lib/python/Products/CMFCalendar/CalendarTool.py
--- ./CalendarTool.py	2002-08-02 19:21:38.000000000 +0200
+++ /home/syt/Zope-2.6.0-src/lib/python/Products/CMFCalendar/CalendarTool.py	2002-12-18 16:19:08.000000000 +0100
@@ -51,13 +51,15 @@
     def __init__(self):
         self.calendar_types = ['Event']
         self.use_session = ""
-
+        self.show_states = ['published']
+        
     security.declareProtected( CMFCorePermissions.ManagePortal
                              , 'edit_configuration' )
-    def edit_configuration(self, show_types, use_session):
+    def edit_configuration(self, show_types, use_session, show_states):
         """ Change the configuration of the calendar tool """
         self.calendar_types = show_types
         self.use_session = use_session
+        self.show_states = show_states
         if hasattr(self.REQUEST, 'RESPONSE'):
             self.REQUEST.RESPONSE.redirect('manage_configure')
         
@@ -130,7 +132,7 @@
         last_date=DateTime(str(month)+'/'+str(last_day)+'/'+str(year))
     
         query=self.portal_catalog(Type=self.calendar_types,
-                                  review_state='published',	                          
+                                  review_state=self.show_states,
                                   start=(first_date, last_date),
                                   start_usage='range:min:max',
                                   sort_on='start')
@@ -143,7 +145,7 @@
 
         # if you look at calendar_slot you can see how to do this in 1 query - runyaga
         query+=self.portal_catalog(Type=self.calendar_types,
-                                   review_state='published',
+                                   review_state=self.show_states,
                                    end=(first_date, last_date),
                                    end_usage='range:min:max',
                                    sort_on='end')
@@ -209,19 +211,19 @@
 
         # Get all events that Start on this day
         query=self.portal_catalog(Type=self.calendar_types,
-                                  review_state='published',	                          
+                                  review_state=self.show_states,	                          
                                   start=(first_date,last_date),
                                   start_usage='range:min:max')
         
         # Get all events that End on this day
         query+=self.portal_catalog(Type=self.calendar_types,
-                                  review_state='published',	                          
+                                  review_state=self.show_states,	                          
                                   end=(first_date,last_date),
                                   end_usage='range:min:max')
 
         # Get all events that Start before this day AND End after this day
         query+=self.portal_catalog(Type=self.calendar_types,
-                                  review_state='published',
+                                  review_state=self.show_states,
                                   start=first_date,
                                   start_usage='range:max',
                                   end=last_date,
diff -ru ./www/configureCalendarTool.zpt /home/syt/Zope-2.6.0-src/lib/python/Products/CMFCalendar/www/configureCalendarTool.zpt
--- ./www/configureCalendarTool.zpt	2002-05-10 17:45:48.000000000 +0200
+++ /home/syt/Zope-2.6.0-src/lib/python/Products/CMFCalendar/www/configureCalendarTool.zpt	2002-12-20 10:57:24.000000000 +0100
@@ -30,6 +30,24 @@
  an attribute 'end' which return DateTime objects to the Catalog.
  </p>
 
+ <h3>Worflow states to be visible the calendar</h3>
+
+ <select name="show_states:list" size="7" multiple>
+ 
+  <tal:block tal:repeat="state python:here.portal_catalog.uniqueValuesFor('review_state')">
+  
+   <option value="#"
+           tal:attributes="value state;
+	                   selected python:state in here.show_states and 1 or 0;"
+           tal:content="state">state</option>
+
+  </tal:block>
+
+ </select>
+
+ <p>
+ </p>
+
   <tal:define tal:define="use_session here/portal_calendar/getUseSession">
 
     <tal:use_session tal:condition="python:use_session">

--9amGYk9869ThD9tj--