def is_event(self, obj): return IATEvent.providedBy(obj)
def dict_from_item(item): if hasPloneAppEvent and (IEvent.providedBy(item) or IOccurrence.providedBy(item)): is_occurrence = IOccurrence.providedBy(item) and True or False acc = IEventAccessor(item) return { "status": "ok", "id": "UID_%s" % (acc.uid), "title": acc.title, "description": acc.description, "start": acc.start.isoformat(), "end": acc.end.isoformat(), "url": acc.url, "editable": editable, "allDay": acc.whole_day, "className": "contextualContentMenuEnabled %s %s %s %s" % ( state and "state-%s" % str(state) or "", editable and "editable" or "", css and css or "", is_occurrence and "occurrence" or "", ), "color": color, } elif IATEvent.providedBy(item): allday = (item.end() - item.start()) > 1.0 adapted = interfaces.ISFBaseEventFields(item, None) if adapted: allday = adapted.allDay return [ { "status": "ok", "id": "UID_%s" % (item.UID()), "title": item.Title(), "description": item.Description(), "start": item.start().rfc822(), "end": item.end().rfc822(), "url": item.absolute_url(), "editable": editable, "allDay": allday, "className": "contextualContentMenuEnabled %s %s %s" % (state and "state-%s" % str(state) or "", editable and "editable" or "", css and css or ""), "color": color, } ] elif ICatalogBrain.providedBy(item): if type(item.end) != DateTime: brainend = DateTime(item.end) brainstart = DateTime(item.start) else: brainend = item.end brainstart = item.start allday = (brainend - brainstart) > 1.0 if getattr(item, "SFAllDay", None) in [False, True]: allday = item.SFAllDay return [ { "status": "ok", "id": "UID_%s" % (item.UID), "title": item.Title, "description": item.Description, "start": brainstart.rfc822(), "end": brainend.rfc822(), "url": item.getURL(), "editable": editable, "allDay": allday, "className": "contextualContentMenuEnabled %s %s %s" % (state and "state-%s" % str(state) or "", editable and "editable" or "", css and css or ""), "color": color, } ] else: raise ValueError("item type not supported for: %s" % repr(item))
def is_event(self): return IATEvent.providedBy(self.context)
def dict_from_item(item): if hasPloneAppEvent and (IEvent.providedBy(item) or IOccurrence.providedBy(item)): # plone.app.event DX or AT Event is_occurrence = IOccurrence.providedBy(item) acc = IEventAccessor(item) return { "status": "ok", "id": "UID_%s" % (acc.uid), "title": acc.title, "description": acc.description, "start": acc.start.isoformat(), "end": acc.end.isoformat(), "url": acc.url, "editable": editable, "allDay": acc.whole_day, "className": "contextualContentMenuEnabled %s %s %s %s" % ( state and "state-%s" % str(state) or "", editable and "editable" or "", css and css or "", is_occurrence and "occurrence" or ""), "color": color} elif IATEvent.providedBy(item): # Products.ATContentTypes ATEvent allday = (item.end() - item.start()) > 1.0 adapted = interfaces.ISFBaseEventFields(item, None) if adapted: allday = adapted.allDay return { "status": "ok", "id": "UID_%s" % (item.UID()), "title": item.Title(), "description": item.Description(), "start": item.start().ISO8601(), "end": item.end().ISO8601(), "url": item.absolute_url(), "editable": editable, "allDay": allday, "className": "contextualContentMenuEnabled %s %s %s" % ( state and "state-%s" % str(state) or "", editable and "editable" or "", css and css or ""), "color": color} elif ICatalogBrain.providedBy(item): # Event catalog brain if type(item.end) != DateTime: brainend = DateTime(item.end) brainstart = DateTime(item.start) else: brainend = item.end brainstart = item.start allday = (brainend - brainstart) > 1.0 if getattr(item, 'SFAllDay', None) in [False, True]: allday = item.SFAllDay return { "status": "ok", "id": "UID_%s" % (item.UID), "title": item.Title, "description": item.Description, "start": brainstart.ISO8601(), "end": brainend.ISO8601(), "url": item.getURL(), "editable": editable, "allDay": allday, "className": "contextualContentMenuEnabled %s %s %s" % ( state and "state-%s" % str(state) or "", editable and "editable" or "", css and css or ""), "color": color} else: raise ValueError('item type not supported for: %s' % repr(item))
def dict_from_item(item): if hasPloneAppEvent and (IEvent.providedBy(item) or IOccurrence.providedBy(item)): # plone.app.event DX or AT Event is_occurrence = IOccurrence.providedBy(item) acc = IEventAccessor(item) return { "status": "ok", "id": "UID_%s" % (acc.uid), "title": acc.title, "description": acc.description, "start": acc.start.isoformat(), "end": acc.end.isoformat(), "url": acc.url, "editable": editable, "allDay": acc.whole_day, "className": "contextualContentMenuEnabled %s %s %s %s" % ( state and "state-%s" % str(state) or "", editable and "editable" or "", css and css or "", is_occurrence and "occurrence" or ""), "color": color} elif IATEvent.providedBy(item): # Products.ATContentTypes ATEvent allday = (item.end() - item.start()) > 1.0 adapted = interfaces.ISFBaseEventFields(item, None) if adapted: allday = adapted.allDay return { "status": "ok", "id": "UID_%s" % (item.UID()), "title": item.Title(), "description": item.Description(), "start": item.start().ISO8601(), "end": item.end().ISO8601(), "url": item.absolute_url(), "editable": editable, "allDay": allday, "className": "contextualContentMenuEnabled %s %s %s" % ( state and "state-%s" % str(state) or "", editable and "editable" or "", css and css or ""), "color": color} elif ICatalogBrain.providedBy(item): # Event catalog brain if type(item.end) != DateTime: brainend = DateTime(item.end) brainstart = DateTime(item.start) else: brainend = item.end brainstart = item.start allday = (brainend - brainstart) > 1.0 if getattr(item, 'SFAllDay', None) in [False, True]: allday = item.SFAllDay # Set Mexico City Time brainstart = DateTime(' '.join( (brainstart.Date(), brainstart.Time(), 'America/Mexico_City'))) brainend = DateTime(' '.join( (brainend.Date(), brainend.Time(), 'America/Mexico_City'))) return { "status": "ok", "id": "UID_%s" % (item.UID), "title": item.Title, "description": item.Description, "start": brainstart.ISO8601(), "end": brainend.ISO8601(), "url": item.getURL(), "editable": editable, "allDay": allday, "className": "contextualContentMenuEnabled %s %s %s" % ( state and "state-%s" % str(state) or "", editable and "editable" or "", css and css or ""), "color": color} else: raise ValueError('item type not supported for: %s' % repr(item))