r252745 - in Products.PloneBooking/branches/lbellenghi/Products/PloneBooking: . browser content

"Luca Bellenghi" <svn-changes-z4DKO/[email protected]> Mon, 10 Feb 2014 15:39:33 +0000 (UTC)
Newsgroups gmane.comp.web.zope.plone.collective.cvs
Message-ID <[email protected]>
Author: lucabel
Date: Mon Feb 10 15:39:33 2014
New Revision: 252745

Modified:
   Products.PloneBooking/branches/lbellenghi/Products/PloneBooking/BookingTool.py
   Products.PloneBooking/branches/lbellenghi/Products/PloneBooking/browser/configure.zcml
   Products.PloneBooking/branches/lbellenghi/Products/PloneBooking/content/Booking.py
Log:
update

Modified: Products.PloneBooking/branches/lbellenghi/Products/PloneBooking/BookingTool.py
==============================================================================
--- Products.PloneBooking/branches/lbellenghi/Products/PloneBooking/BookingTool.py	(original)
+++ Products.PloneBooking/branches/lbellenghi/Products/PloneBooking/BookingTool.py	Mon Feb 10 15:39:33 2014
@@ -37,7 +37,7 @@
 from AccessControl import getSecurityManager
 from AccessControl.SecurityManagement import newSecurityManager
 from AccessControl.SpecialUsers import emergency_user
-        
+
 #from OFS.PropertyManager import PropertyManager
 from DateTime import DateTime
 
@@ -55,7 +55,8 @@
 # PloneBooking imports
 from Products.PloneBooking.BookingPermissions import AddBooking
 from Products.PloneBooking.DateManager import DateManager
-from Products.generator import i18n
+#from Products.generator import i18n
+from zope import i18n
 from Products.PloneBooking.content.vocabulary import CALENDAR_VIEWS, VIEW_MODES, LISTING_VIEWS
 from Products.PloneBooking.config import I18N_DOMAIN
 
@@ -72,11 +73,7 @@
     id = 'portal_booking'
     title = "Misc utilities for PloneBooking application"
     meta_type = "BookingTool"
-    
-    __implements__ = (ActionProviderBase.__implements__,
-                      SimpleItem.__implements__, )
 
-    
     manage_options = (ActionProviderBase.manage_options + SimpleItem.manage_options)
     security = ClassSecurityInfo()
 
@@ -87,25 +84,25 @@
         b_end: timestamp. Ending date of booking
         start: timestamp. Beginning date of tested period
         end: timestamp. Ending date of tested period
-     
+
         return is_booked: boolean
         """
         is_booked = False
-    
+
         if b_start < start:
             if b_end > start:
                 is_booked = True
         else:
             if b_end < end or b_start < end:
                 is_booked = True
-    
+
         return is_booked
 
     security.declarePublic('filterBookingBrains')
     def filterBookingBrains(self, booking_brains, start_date, end_date):
         """Returns brains  booked in interval of start date and end date
         """
-        
+
         result = []
         for brain in booking_brains:
             booking_start_date = brain['start']
@@ -119,11 +116,11 @@
     def getAllPeriodicBookingBrains(self, booking_uid):
         """Returns periodic brains for a booking.
         """
-        
+
         atool = getToolByName(self, 'archetype_tool')
         obj = atool.getObject(booking_uid)
         return obj.getAllPeriodicBookingBrains()
-        
+
     security.declarePublic('cancelBooking')
     def cancelBooking(self, booking):
         """
@@ -137,40 +134,40 @@
         # Use manager role to change permissions
         current_user = getSecurityManager().getUser()
         newSecurityManager(request, emergency_user)
-        
+
         # delete booking
         booked_object.manage_delObjects([booking_id,])
-        
+
         # Restore current user permission
         newSecurityManager(request, current_user)
-    
-    security.declarePublic('getBookingDefaultTitle')    
+
+    security.declarePublic('getBookingDefaultTitle')
     def getBookingDefaultTitle(self):
         """Returns booking default title.
         It is used when no title is defined on booking"""
-        
+
         msg_id = "label_booking"
         msg_default = "Booking"
         return i18n.translate(I18N_DOMAIN, msg_id, context=self, default=msg_default)
-        
+
     security.declarePublic('buildFilter')
     def buildFilter(self, **kwargs):
         """Returns a dictionnary using kwargs.
         Removes None values."""
-        
+
         result = {}
         for key, value in kwargs.items():
             if value is not None:
                 result[key] = value
         return result
-    
+
     security.declarePublic('getIntervalOfMinutesGroupKeys')
     def getIntervalOfMinutesGroupKeys(self, start_date, end_date, interval):
         """"""
-        
+
         group_keys = []
         interval_in_seconds = interval * 60.0
-        
+
         # Round start date and end date to interval
         start_ts = self.zdt2ts(start_date)
         start_ts_from_zero = self.zdt2ts(DateTime(start_date.year(), start_date.month(), start_date.day()))
@@ -180,20 +177,20 @@
         end_ts_from_zero = self.zdt2ts(DateTime(end_date.year(), end_date.month(), end_date.day()))
         new_end_ts = end_ts_from_zero + math.ceil((end_ts - end_ts_from_zero) / interval_in_seconds) * interval_in_seconds
         nb_intervals = int((new_end_ts - new_start_ts) / interval_in_seconds)
-        
+
         for i in range(0, nb_intervals):
             key_date = new_start_dt + (i * (interval_in_seconds / 86400.0))
             key_interval = (key_date.hour() * 60 + key_date.minute())
             group_keys.append((key_date.year(), key_date.month(), key_date.day(), key_interval))
         return group_keys
-    
+
     security.declarePublic('getDayGroupKeys')
     def getDayGroupKeys(self, start_date, end_date):
         """"""
-        
+
         group_keys = []
         interval_in_seconds = 86400.0
-        
+
         # Round start date and end date to day
         new_start_ts = self.zdt2ts(DateTime(start_date.year(), start_date.month(), start_date.day()))
         new_start_dt = self.ts2zdt(new_start_ts)
@@ -201,19 +198,19 @@
         end_ts_from_zero = self.zdt2ts(DateTime(end_date.year(), end_date.month(), end_date.day()))
         new_end_ts = end_ts_from_zero + math.ceil((end_ts - end_ts_from_zero) / interval_in_seconds) * interval_in_seconds
         nb_days = int((new_end_ts - new_start_ts) / interval_in_seconds)
-        
+
         for i in range(0, nb_days):
             key_date = new_start_dt + i
             group_keys.append((key_date.year(), key_date.month(), key_date.day()))
         return group_keys
-    
+
     security.declarePublic('getWeekGroupKeys')
     def getWeekGroupKeys(self, start_date, end_date):
         """"""
-        
+
         group_keys = []
         interval_in_seconds = 7 * 86400.0
-        
+
         # Assume monday is the first day of the week
         # and sunday is the last day of the week
         new_start_dt = DateTime(start_date.year(), start_date.month(), start_date.day()) - (start_date.dow() - 1) % 7 # Get the monday before start_date
@@ -223,20 +220,20 @@
         new_end_ts = end_ts
         if end_ts != end_ts_from_zero:
             new_end_ts += interval_in_seconds
-     
+
         nb_weeks = int((new_end_ts - new_start_ts) / interval_in_seconds)
-     
+
         for i in range(0, nb_weeks):
             key_date = new_start_dt + (i * 7)
             group_keys.append((key_date.year(), key_date.week()))
         return group_keys
-    
+
     security.declarePublic('getMonthGroupKeys')
     def getMonthGroupKeys(self, start_date, end_date):
         """"""
-        
+
         group_keys = []
-        
+
         end_ts = self.zdt2ts(end_date)
         end_ts_from_zero = self.zdt2ts(DateTime(end_date.year(), end_date.month(), 1))
         end_year = end_date.year()
@@ -247,90 +244,90 @@
                 end_year -= 1
             else:
                 end_month -= 1
-        
+
         # Round start date and end date to month
         start_months = (start_date.year() * 12 + start_date.month())
         end_months = (end_year * 12 + end_month)
         nb_months = end_months - start_months + 1
-        
+
         for i in range(0, nb_months):
             new_month = (start_months + i - 1)%12 + 1
             new_year = (start_months + i - 1)/12
             group_keys.append((new_year, new_month))
         return group_keys
-    
+
     security.declarePublic('getYearGroupKeys')
     def getYearGroupKeys(self, start_date, end_date):
         """"""
-        
+
         group_keys = []
-        
+
         end_ts = self.zdt2ts(end_date)
         end_ts_from_zero = self.zdt2ts(DateTime(end_date.year(), 1, 1))
         end_year = end_date.year()
-        
+
         if end_ts == end_ts_from_zero:
             end_year -= 1
         new_start_dt, new_end_dt = self.getDateRangeFromYear(start_date.year(), end_year)
         first_year = new_start_dt.year()
         nb_years = new_end_dt.year() - first_year
-        
+
         for i in range(0, nb_years):
             group_keys.append(first_year + i)
         return group_keys
-    
-    
+
+
     security.declarePublic('getViewModeDisplayList')
     def getViewModeDisplayList(self):
         """Returns view mode display list"""
-        
+
         return VIEW_MODES
-    
+
     security.declarePublic('getListingViewDisplayList')
     def getListingViewDisplayList(self):
         """Returns listing view display list"""
-        
+
         return LISTING_VIEWS
 
     security.declarePublic('getCalendarViewDisplayList')
     def getCalendarViewDisplayList(self):
         """Returns listing view display list"""
-        
+
         return CALENDAR_VIEWS
-    
+
     security.declarePublic('getViewModeVocabulary')
     def getViewModeVocabulary(self):
         """Returns view mode vocabulary"""
-        
+
         dl = self.getViewModeDisplayList()
         return Vocabulary(dl, self, I18N_DOMAIN)
-    
+
     security.declarePublic('getListingViewVocabulary')
     def getListingViewVocabulary(self):
         """Returns listing view vocabulary"""
-        
+
         dl = self.getListingViewDisplayList()
         return Vocabulary(dl, self, I18N_DOMAIN)
 
     security.declarePublic('getCalendarViewVocabulary')
     def getCalendarViewVocabulary(self):
         """Returns listing view vocabulary"""
-        
+
         dl = self.getCalendarViewDisplayList()
         return Vocabulary(dl, self, I18N_DOMAIN)
-    
+
     def escapeText(self, text):
         """Escape chars on text. It can be very useful to use text in javascript
-        
+
         @param text: text to escape
         """
-    
+
         # If matching escapable char call this function
         def escape(match):
             """Escape chars"""
-    
+
             char = match.group(0)
-    
+
             # Special chars already escaped. Apply double escape
             if char== '\n':
                 return '\\n'
@@ -338,14 +335,14 @@
                 return '\\n'
             elif char== '\t':
                 return '\\t'
-    
+
             return '\\%s' % char
-    
+
         # Text must be an encoded string
         if type(text) != StringType and type(text) != type(u''):
             raise ValueError, "You can just escape strings: %s" % str(text)
-        
+
         # Escape text
         return ESCAPE_CHARS.sub(escape, text)
-    
+
 InitializeClass(BookingTool)

Modified: Products.PloneBooking/branches/lbellenghi/Products/PloneBooking/browser/configure.zcml
==============================================================================
--- Products.PloneBooking/branches/lbellenghi/Products/PloneBooking/browser/configure.zcml	(original)
+++ Products.PloneBooking/branches/lbellenghi/Products/PloneBooking/browser/configure.zcml	Mon Feb 10 15:39:33 2014
@@ -6,6 +6,7 @@
    xmlns:plone="http://namespaces.plone.org/plone"
    i18n_domain="plonebooking">
 
+<include package="Products.CMFCore" />
   <browser:page
       for="Products.PloneBooking.interfaces.IBookingCenter"
       name="filter_select_options"
@@ -32,4 +33,4 @@
     permission="cmf.ModifyPortalContent"
   />
 
-</configure>
\ No newline at end of file
+</configure>

Modified: Products.PloneBooking/branches/lbellenghi/Products/PloneBooking/content/Booking.py
==============================================================================
--- Products.PloneBooking/branches/lbellenghi/Products/PloneBooking/content/Booking.py	(original)
+++ Products.PloneBooking/branches/lbellenghi/Products/PloneBooking/content/Booking.py	Mon Feb 10 15:39:33 2014
@@ -48,7 +48,8 @@
     # No multilingual support
     from Products.Archetypes.public import *
 
-from Products.generator import i18n
+#from Products.generator import i18n
+from zope import i18n
 
 #PloneBooking imports
 from Products.PloneBooking.config import PROJECTNAME, I18N_DOMAIN

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk