Exemplo n.º 1
0
class CalendarSubMenuItem(BrowserSubMenuItem):
    implements(ICalendarSubMenuItem)

    title = _(u"label_calendar_menu", default=u"Calendar")
    description = _(u"title_calendar_menu",
                    default=u"Manage calendar options for this content.")
    submenuId = "plone_contentmenu_calendaring"

    order = 4
    extra = {"id": "plone-contentmenu-calendaring"}

    @property
    def action(self):
        return self.context.absolute_url() + "/manage_calendaring_form"

    def available(self):
        context = self.context
        member = getMultiAdapter((context, self.request),
                                 name="plone_portal_state").member()
        if IATFolder.providedBy(context) and member.has_permission(
                'monet.calendar.extensions.ManageCalendars', context):
            return IMonetCalendarExtensionsLayer in browserlayerutils.registered_layers(
            )
        return False

    def disabled(self):
        return False

    def selected(self):
        return False
 def make_calendarsection(self):
     context = self.context
     alsoProvides(context, IMonetCalendarSection)
     context.reindexObject(idxs=['object_provides'])
     self.putils.addPortalMessage(_(u'Status changed'))
     self.putils.addPortalMessage(_(u'warn_layout_change',
                                    default=u'You may want to change the current layout to "Calendar view"'))
     self.request.response.redirect(context.absolute_url())
 def remove_calendarsection(self):
     context = self.context
     noLongerProvides(context, IMonetCalendarSection)
     context.reindexObject(idxs=['object_provides'])
     self.putils.addPortalMessage(_(u'Status changed'))
     if context.getProperty('layout')=='monetsearchevents':
         self.putils.addPortalMessage(_(u'The view of the folder has been changed'))
         context.manage_changeProperties({'layout': 'folder_listing'})
     self.request.response.redirect(context.absolute_url())
Exemplo n.º 4
0
 def _validate(self, date_from, date_to, directLocalization=False):
     """Perform a date validation
     return the error message or an empty string is validation pass
     """
     key = default = None
     message_error = ''
     if not date_from or not date_to:
         key, default = (u'label_failed_arguments',
                         u'Dates are not valid, please retry.')
     elif self.checkInvalidDateGreaterThan(date_from, date_to):
         key, default = (
             u'label_failed_gtinterval',
             u'The second date (TO) must be greater than or equal to the first date (FROM). Please re-enter dates.'
         )
     elif self.checkInvalidDateInterval(date_from, date_to):
         key, default = (
             u'label_failed_interval',
             u'The search of events must be inside a range or 60 days. Please re-enter dates.'
         )
     if key:
         if not directLocalization:
             message_error = _(key, default=default)
         else:
             message_error = self._translation_service.utranslate(
                 domain='monet.calendar.extensions',
                 msgid=key,
                 default=default,
                 context=self.context)
     return message_error
Exemplo n.º 5
0
    def sortedEventsBySlots(self, events):
        """Sorted events by slot"""

        mp = getToolByName(self, 'portal_properties')
        special_event_types_pro = mp.monet_calendar_event_properties.special_event_types
        special_event_types = DisplayList()
        for etype in special_event_types_pro:
            special_event_types.add(etype, _(etype))

        sorted_events = {
            'morning': [],
            'afternoon': [],
            'night': [],
            'allday': [],
            'sequence_slots': ['morning', 'afternoon', 'night', 'allday']
        }
        sorted_events_keys = sorted_events.keys()

        for event in events:
            inter = list(
                set(event.getEventType).intersection(set(special_event_types)))
            if inter:
                if not inter[0] in sorted_events['sequence_slots']:
                    sorted_events['sequence_slots'].append(inter[0])
                    sorted_events[inter[0]] = []
                sorted_events[inter[0]].append(event)
                continue
            for key in sorted_events_keys:
                if event.getSlots == key:
                    sorted_events[key].append(event)
        return sorted_events
 def sortedEventsBySlots(self,events):
     """Sorted events by slot"""
     
     mp = getToolByName(self,'portal_properties')
     special_event_types_pro = mp.monet_calendar_event_properties.special_event_types
     special_event_types = DisplayList()
     for etype in special_event_types_pro:
         special_event_types.add(etype,_(etype))
 
     sorted_events = {'morning':[],
                      'afternoon':[],
                      'night':[],
                      'allday':[],
                      'sequence_slots':['morning','afternoon','night','allday']}
     sorted_events_keys = sorted_events.keys()
     
     for event in events:
         inter = list(set(event.getEventType).intersection(set(special_event_types)))
         if inter:
             if not inter[0] in sorted_events['sequence_slots']:
                 sorted_events['sequence_slots'].append(inter[0])
                 sorted_events[inter[0]] = []
             sorted_events[inter[0]].append(event)
             continue
         for key in sorted_events_keys:
             if event.getSlots == key:
                 sorted_events[key].append(event)
     return sorted_events
Exemplo n.º 7
0
    def getEventTypeName(self, key):
        mp = getToolByName(self, 'portal_properties')
        event_types_pro = mp.monet_calendar_event_properties.event_types
        event_types = DisplayList()
        for etype in event_types_pro:
            event_types.add(etype, _(etype))

        return event_types.getValue(key)
 def getEventTypeName(self,key):
     mp = getToolByName(self,'portal_properties')
     event_types_pro = mp.monet_calendar_event_properties.event_types
     event_types = DisplayList()
     for etype in event_types_pro:
         event_types.add(etype,_(etype))
     
     return event_types.getValue(key)
 def getSummarySearchDates(self, dates):
     """Return a part of the summary of the search from request
     """
     if dates.get('date_from') and dates.get('date_to'):
         date_from = self.context.toLocalizedTime(dates.get('date_from').strftime('%m/%d/%Y'),long_format=0)
         date_to = self.context.toLocalizedTime(dates.get('date_to').strftime('%m/%d/%Y'),long_format=0)
         return _(u'summary_search_from_to',
                 default='from ${date_from} to ${date_to}',
                 mapping={'date_from':date_from,
                          'date_to':date_to},
                 )
     else:
         date = self.context.toLocalizedTime(dates.get('date').strftime('%m/%d/%Y'),long_format=0)
         return _(u'summary_search_in',
                 default='in ${date}',
                 mapping={'date':date},
                 )
 def getSlotsName(self,key):
     mp = getToolByName(self,'portal_properties')
     
     special_event_types_pro = mp.monet_calendar_event_properties.special_event_types
     special_event_types = DisplayList()
     for etype in special_event_types_pro:
         special_event_types.add(etype,_(etype))
     
     return (key in special_event_types) and special_event_types.getValue(key) or SlotsVocab[key]
Exemplo n.º 11
0
    def getSlotsName(self, key):
        mp = getToolByName(self, 'portal_properties')

        special_event_types_pro = mp.monet_calendar_event_properties.special_event_types
        special_event_types = DisplayList()
        for etype in special_event_types_pro:
            special_event_types.add(etype, _(etype))

        return (key in special_event_types
                ) and special_event_types.getValue(key) or SlotsVocab[key]
Exemplo n.º 12
0
 def getSummarySearchDates(self, dates):
     """Return a part of the summary of the search from request
     """
     if dates.get('date_from') and dates.get('date_to'):
         date_from = self.context.toLocalizedTime(
             dates.get('date_from').strftime('%m/%d/%Y'), long_format=0)
         date_to = self.context.toLocalizedTime(
             dates.get('date_to').strftime('%m/%d/%Y'), long_format=0)
         return _(
             u'summary_search_from_to',
             default='from ${date_from} to ${date_to}',
             mapping={
                 'date_from': date_from,
                 'date_to': date_to
             },
         )
     else:
         date = self.context.toLocalizedTime(
             dates.get('date').strftime('%m/%d/%Y'), long_format=0)
         return _(
             u'summary_search_in',
             default='in ${date}',
             mapping={'date': date},
         )
 def _validate(self, date_from, date_to, directLocalization=False):
     """Perform a date validation
     return the error message or an empty string is validation pass
     """
     key = default = None
     message_error = ''
     if not date_from or not date_to:
         key, default = (u'label_failed_arguments',
                         u'Dates are not valid, please retry.')
     elif self.checkInvalidDateGreaterThan(date_from,date_to):
         key, default = (u'label_failed_gtinterval',
                         u'The second date (TO) must be greater than or equal to the first date (FROM). Please re-enter dates.')
     elif self.checkInvalidDateInterval(date_from,date_to):
         key, default = (u'label_failed_interval',
                         u'The search of events must be inside a range or 60 days. Please re-enter dates.')
     if key:
         if not directLocalization:
             message_error = _(key, default=default)
         else:
             message_error = self._translation_service.utranslate(domain='monet.calendar.extensions',
                                                                  msgid=key,
                                                                  default=default,
                                                                  context=self.context)
     return message_error
Exemplo n.º 14
0
    import Products.LinguaPlone
    LINGUAPLONE = True
except ImportError:
    LINGUAPLONE = False

try:
    # python2.6
    import json
except ImportError:
    # python2.4
    import simplejson as json

PLMF = MessageFactory('plonelocales')

SlotsVocab = {
    'morning': _(u'Morning'),
    'afternoon': _(u'Afternoon'),
    'night': _(u'Evening'),
    'allday': _(u'All day long')
}

parameterDatesList = [
    'fromYear', 'fromMonth', 'fromDay', 'toYear', 'toMonth', 'toDay'
]


def daterange(start_date, end_date):
    for n in range((end_date - start_date).days):
        yield start_date + timedelta(n)

Exemplo n.º 15
0
 def monetAllEvents(self):
     return _(u'label_all_events', default=u'-- All events --')
 def monetAllEvents(self):
     return _(u'label_all_events', default=u'-- All events --')
Exemplo n.º 17
0
    def getMenuItems(self, context, request):
        """Return menu item entries in a TAL-friendly form."""

        menu = []
        url = context.absolute_url()

        if not IMonetCalendarSection.providedBy(context):
            menu.append({
                "title":
                _(u"label_make_caledarsection",
                  default=u"Mark as calendar section"),
                "description":
                _(u"help_make_caledarsection",
                  default=u"Mark this section as a calendar."),
                "action":
                url + "/make_calendar_section",
                "selected":
                False,
                "icon":
                None,
                "extra": {
                    "id": "_calendaring_calendar_section",
                    "separator": None,
                    "class": ""
                },
                "submenu":
                None,
            })
        else:
            menu.append({
                "title":
                _(u"label_remove_caledarsection",
                  default=u"Unmark as calendar section"),
                "description":
                _(u"help_remove_caledarsection",
                  default=u"Unmark this section from being a calendar section."
                  ),
                "action":
                url + "/remove_calendar_section",
                "selected":
                False,
                "icon":
                None,
                "extra": {
                    "id": "_calendaring_remove_calendar_section",
                    "separator": None,
                    "class": ""
                },
                "submenu":
                None,
            })

        if not IMonetCalendarSearchRoot.providedBy(context):
            menu.append({
                "title":
                _(u"label_make_caledarsearchroot",
                  default=u"Mark as calendar root"),
                "description":
                _(u"help_make_caledarsearchroot",
                  default=u"Mark this section as a root for searching events. "
                  u"Calendar inside this section will not find event defined above."
                  ),
                "action":
                url + "/make_calendar_search_root",
                "selected":
                False,
                "icon":
                None,
                "extra": {
                    "id": "_calendaring_search_root",
                    "separator": None,
                    "class": ""
                },
                "submenu":
                None,
            })
        else:
            menu.append({
                "title":
                _(u"label_remove_caledarsearchroot",
                  default=u"Unmark as calendar root"),
                "description":
                _(u"help_remove_caledarsearchroot",
                  default=u"Remove the status of root for searching events."),
                "action":
                url + "/remove_calendar_search_root",
                "selected":
                False,
                "icon":
                None,
                "extra": {
                    "id": "_calendaring_remove_search_root",
                    "separator": None,
                    "class": ""
                },
                "submenu":
                None,
            })

        return menu
 def remove_search_root(self):
     context = self.context
     noLongerProvides(context, IMonetCalendarSearchRoot)
     context.reindexObject(idxs=['object_provides'])
     self.putils.addPortalMessage(_(u'Status changed'))
     self.request.response.redirect(context.absolute_url())
    import Products.LinguaPlone
    LINGUAPLONE = True
except ImportError:
    LINGUAPLONE = False
    
try:
    # python2.6
    import json
except ImportError:
    # python2.4
    import simplejson as json


PLMF = MessageFactory('plonelocales')

SlotsVocab = {'morning':_(u'Morning'),
              'afternoon':_(u'Afternoon'),
              'night':_(u'Evening'),
              'allday':_(u'All day long')}

parameterDatesList = ['fromYear',
                      'fromMonth',
                      'fromDay',
                      'toYear',
                      'toMonth',
                      'toDay']

def daterange(start_date, end_date):
    for n in range((end_date - start_date).days):
        yield start_date + timedelta(n)