def dictFromObject(self, item, args={}):
        eventPhysicalPath = "/".join(item.getPhysicalPath())
        wft = getToolByName(self.context, "portal_workflow")
        state = wft.getInfoFor(self.context, "review_state")
        member = self.context.portal_membership.getAuthenticatedMember()
        if member.has_permission("Modify portal content", item):
            editable = True

        copycut = ""
        if self.copyDict and eventPhysicalPath == self.copyDict["url"]:
            copycut = self.copyDict["op"] == 1 and " event_cutted" or " event_copied"

        typeClass = " type-" + item.portal_type
        colorDict = getColorIndex(self.context, self.request, eventPhysicalPath)
        colorIndex = colorDict.get("class", "")
        color = colorDict.get("color", "")
        extraClass = self.getObjectExtraClass(item)

        events = []
        HANDLE_RECURRENCE = HAS_RECURRENCE_SUPPORT and self.request.get("start") and self.request.get("end")
        if HANDLE_RECURRENCE:
            start = DateTime(self.request.get("start"))
            end = DateTime(self.request.get("end"))
            events = IRecurrenceSupport(item).occurrences(range_start=start, range_end=end)
        else:
            events = item
        return dict_from_events(
            events, editable=editable, state=state, color=color, css=copycut + typeClass + colorIndex + extraClass
        )
    def __call__(self):
        event = self.context
        context = self.context
        referer = self.request.get("HTTP_REFERER")
        if referer:
            portal = getToolByName(self.context, "portal_url").getPortalObject()
            url = "/" + portal.id + referer.replace(portal.absolute_url(), "")
            context = portal.restrictedTraverse(url)
        eventPhysicalPath = "/".join(event.getPhysicalPath())
        wft = getToolByName(context, "portal_workflow")
        state = wft.getInfoFor(event, "review_state")
        member = context.portal_membership.getAuthenticatedMember()
        editable = bool(member.has_permission("Modify portal content", event))

        copycut = ""
        if self.copyDict and eventPhysicalPath == self.copyDict["url"]:
            copycut = self.copyDict["op"] == 1 and " event_cutted" or " event_copied"

        typeClass = " type-" + event.portal_type
        colorDict = getColorIndex(context, self.request, eventPhysicalPath)
        colorIndex = colorDict.get("class", "")
        color = colorDict.get("color", "")
        extraClass = self.getExtraClass()

        events = []
        HANDLE_RECURRENCE = HAS_RECURRENCE_SUPPORT and self.request.get("start") and self.request.get("end")
        if HANDLE_RECURRENCE:
            start = DateTime(self.request.get("start"))
            end = DateTime(self.request.get("end"))
            events = IRecurrenceSupport(event).occurrences(range_start=start, range_end=end)
        else:
            events = event
        return dict_from_events(
            events, editable=editable, state=state, color=color, css=copycut + typeClass + colorIndex + extraClass
        )
Beispiel #3
0
    def dictFromObject(self, item, kwargs={}):
        eventPhysicalPath = '/'.join(item.getPhysicalPath())
        wft = getToolByName(self.context, 'portal_workflow')
        state = wft.getInfoFor(self.context, 'review_state')
        member = self.context.portal_membership.getAuthenticatedMember()
        if member.has_permission('Modify portal content', item):
            editable = True

        copycut = ''
        if self.copyDict and eventPhysicalPath == self.copyDict['url']:
            copycut = self.copyDict['op'] == 1 and ' event_cutted' \
                                             or ' event_copied'

        typeClass = ' type-' + item.portal_type
        colorDict = getColorIndex(self.context, self.request, eventPhysicalPath)
        colorIndex = colorDict.get('class', '')
        color = colorDict.get('color', '')
        extraClass = self.getObjectExtraClass(item)

        events = []
        if handle_recurrence(self.request) and IRecurrenceSupport(item, None):
            events = get_recurring_events(self.request, item)
        else:
            events = item
        return (dict_from_events(
            events,
            editable=editable,
            state=state,
            color=color,
            css=copycut + typeClass + colorIndex + extraClass
            ))
    def dictFromBrain(self, brain, editableEvents=[]):

        if brain.UID in editableEvents:
            editable = True
        else:
            editable = False

        copycut = ""
        if self.copyDict and brain.getPath() == self.copyDict["url"]:
            copycut = self.copyDict["op"] == 1 and " event_cutted" or " event_copied"
        typeClass = " type-" + brain.portal_type
        colorDict = getColorIndex(self.context, self.request, brain=brain)
        colorIndex = colorDict.get("class", "")
        color = colorDict.get("color", "")
        extraClass = self.getBrainExtraClass(brain)

        events = []
        HANDLE_RECURRENCE = HAS_RECURRENCE_SUPPORT and self.request.get("start") and self.request.get("end")
        if HANDLE_RECURRENCE:
            event = brain.getObject()
            start = DateTime(self.request.get("start"))
            end = DateTime(self.request.get("end"))
            events = IRecurrenceSupport(event).occurrences(range_start=start, range_end=end)
        else:
            events = brain
        return dict_from_events(
            events,
            editable=editable,
            state=brain.review_state,
            color=color,
            css=copycut + typeClass + colorIndex + extraClass,
        )
Beispiel #5
0
    def __call__(self):
        context = self.context

        eventPhysicalPath = '/'.join(context.getPhysicalPath())
        wft = getToolByName(context, 'portal_workflow')
        state = wft.getInfoFor(context, 'review_state')
        member = context.portal_membership.getAuthenticatedMember()
        editable = bool(member.has_permission('Modify portal content', context))
        allday = (context.end() - context.start()) > 1.0

        adapted = interfaces.ISFBaseEventFields(context, None)
        if adapted:
            allday = adapted.allDay

        copycut = ''
        if self.copyDict and eventPhysicalPath == self.copyDict['url']:
            copycut = self.copyDict['op'] == 1 and ' event_cutted' or ' event_copied'

        typeClass = ' type-' + context.portal_type
        colorIndex = getColorIndex(context, self.request, eventPhysicalPath)
        extraClass = self.getExtraClass()
        return {"status": "ok",
                "id": "UID_%s" % context.UID(),
                "title": context.Title(),
                "description": context.Description(),
                "start": context.start().rfc822(),
                "end": context.end().rfc822(),
                "url": context.absolute_url(),
                "editable": editable,
                "allDay": allday,
                "className": "contextualContentMenuEnabled state-" + str(state) + (editable and " editable" or "")+copycut+typeClass+colorIndex+extraClass}
Beispiel #6
0
    def dictFromBrain(self, brain, editableEvents=[]):

        if brain.UID in editableEvents:
            editable = True
        else:
            editable = False

        copycut = ''
        if self.copyDict and brain.getPath() == self.copyDict['url']:
            copycut = self.copyDict['op'] == 1 and ' event_cutted' \
                                             or ' event_copied'
        typeClass = ' type-' + brain.portal_type
        colorDict = getColorIndex(self.context, self.request, brain=brain)
        colorIndex = colorDict.get('class', '')
        color = colorDict.get('color', '')
        extraClass = self.getBrainExtraClass(brain)

        events = []
        if handle_recurrence(self.request):
            event = brain.getObject()
            if IRecurrenceSupport(event, None):
                events = get_recurring_events(self.request, event)
            else:
                events = brain
        else:
            events = brain
        return (dict_from_events(
            events,
            editable=editable,
            state=brain.review_state,
            color=color,
            css=copycut + typeClass + colorIndex + extraClass
            ))
Beispiel #7
0
    def dictFromObject(self, item):
        eventPhysicalPath = '/'.join(item.getPhysicalPath())
        wft = getToolByName(self.context, 'portal_workflow')
        state = wft.getInfoFor(self.context, 'review_state')
        member = self.context.portal_membership.getAuthenticatedMember()
        if member.has_permission('Modify portal content', item):
            editable = True

        if item.end() - item.start() > 1.0:
            allday = True
        else:
            allday = False

        adapted = interfaces.ISFBaseEventFields(item, None)
        if adapted:
            allday = adapted.allDay

        copycut = ''
        if self.copyDict and eventPhysicalPath == self.copyDict['url']:
            copycut = self.copyDict[
                'op'] == 1 and ' event_cutted' or ' event_copied'

        typeClass = ' type-' + item.portal_type
        colorIndex = getColorIndex(self.context, self.request,
                                   eventPhysicalPath)
        extraClass = self.getObjectExtraClass(item)
        if hasPloneAppEvent:
            occurences = item.occurrences()
        else:
            occurences = [(item.start().rfc822(), item.end().rfc822())]
        events = []
        for occurence_start, occurence_end in occurences:
            events.append({
                "status":
                "ok",
                "id":
                "UID_%s" % (item.UID()),
                "title":
                item.Title(),
                "description":
                item.Description(),
                "start":
                hasPloneAppEvent and occurence_start.isoformat()
                or occurence_start,
                "end":
                hasPloneAppEvent and occurence_end.isoformat()
                or occurence_end,
                "url":
                item.absolute_url(),
                "editable":
                editable,
                "allDay":
                allday,
                "className":
                "contextualContentMenuEnabled state-" + str(state) +
                (editable and " editable" or "") + copycut + typeClass +
                colorIndex + extraClass
            })

        return events
Beispiel #8
0
    def dictFromBrain(self, brain, editableEvents=[]):

        if brain.UID in editableEvents:
            editable = True
        else:
            editable = False

        if brain.end - brain.start > 1.0:
            allday = True
        else:
            allday = False

        if getattr(brain, 'SFAllDay', None) in [False, True]:
            allday = brain.SFAllDay

        copycut = ''
        if self.copyDict and brain.getPath() == self.copyDict['url']:
            copycut = self.copyDict[
                'op'] == 1 and ' event_cutted' or ' event_copied'
        typeClass = ' type-' + brain.portal_type
        colorIndex = getColorIndex(self.context, self.request, brain=brain)
        extraClass = self.getBrainExtraClass(brain)
        if HAS_RECURRENCE_SUPPORT:
            event = brain.getObject()
            start = DateTime(self.request.get('start'))
            end = DateTime(self.request.get('end'))
            occurences = IRecurrence(event).occurrences(limit_start=start,
                                                        limit_end=end)
        else:
            occurences = [(brain.start.rfc822(), brain.end.rfc822())]
        events = []
        for occurence_start, occurence_end in occurences:
            events.append({
                "id":
                "UID_%s" % (brain.UID),
                "title":
                brain.Title,
                "description":
                brain.Description,
                "start":
                HAS_RECURRENCE_SUPPORT and occurence_start.isoformat()
                or occurence_start,
                "end":
                HAS_RECURRENCE_SUPPORT and occurence_end.isoformat()
                or occurence_end,
                "url":
                brain.getURL(),
                "editable":
                editable,
                "allDay":
                allday,
                "className":
                "contextualContentMenuEnabled state-" +
                str(brain.review_state) + (editable and " editable" or "") +
                copycut + typeClass + colorIndex + extraClass
            })
        return events
    def __call__(self):
        event = self.context
        context = self.context
        referer = self.request.get('HTTP_REFERER')
        if referer:
            portal = getToolByName(self.context, 'portal_url').getPortalObject()
            url = '/'+portal.id+referer.replace(portal.absolute_url(), '')
            context = portal.restrictedTraverse(url)
        eventPhysicalPath = '/'.join(event.getPhysicalPath())
        wft = getToolByName(context, 'portal_workflow')
        state = wft.getInfoFor(event, 'review_state')
        member = context.portal_membership.getAuthenticatedMember()
        editable = bool(member.has_permission('Modify portal content', event))
        allday = (event.end() - event.start()) > 1.0

        adapted = interfaces.ISFBaseEventFields(event, None)
        if adapted:
            allday = adapted.allDay

        copycut = ''
        if self.copyDict and eventPhysicalPath == self.copyDict['url']:
            copycut = self.copyDict['op'] == 1 and ' event_cutted' or ' event_copied'

        typeClass = ' type-' + event.portal_type
        colorDict = getColorIndex(context, self.request, eventPhysicalPath)
        colorIndex = colorDict.get('class', '')
        color = colorDict.get('color', '')
        extraClass = self.getExtraClass()

        HANDLE_RECURRENCE = HAS_RECURRENCE_SUPPORT and self.request.get('start') and self.request.get('end')
        if HANDLE_RECURRENCE:
            start = DateTime(self.request.get('start'))
            end = DateTime(self.request.get('end'))
            occurences = IRecurrence(event).occurrences(limit_start=start, limit_end=end)
            occurenceClass = ' occurence'
        else:
            occurences = [(event.start().rfc822(), event.end().rfc822())]
            occurenceClass = ''
        events = []
        for occurence_start, occurence_end in occurences:
            events.append({
                "status": "ok",
                "id": "UID_%s" % (event.UID()),
                "title": event.Title(),
                "description": event.Description(),
                "start": HANDLE_RECURRENCE and occurence_start.isoformat() or occurence_start,
                "end": HANDLE_RECURRENCE and occurence_end.isoformat() or occurence_end,
                "url": event.absolute_url(),
                "editable": editable,
                "allDay": allday,
                "className": "contextualContentMenuEnabled state-" + str(state) + (editable and " editable" or "")+copycut+typeClass+colorIndex+extraClass+occurenceClass,
                "color": color})

        return events
    def dictFromBrain(self, brain, editableEvents=[]):
        if type(brain.end) != DateTime:
            brainend = DateTime(brain.end)
            brainstart = DateTime(brain.start)
        else:
            brainend = brain.end
            brainstart = brain.start

        if brain.UID in editableEvents:
            editable = True
        else:
            editable = False

        if brainend - brainstart > 1.0:
            allday = True
        else:
            allday = False

        if getattr(brain, 'SFAllDay', None) in [False,True]:
            allday = brain.SFAllDay

        copycut = ''
        if self.copyDict and brain.getPath() == self.copyDict['url']:
            copycut = self.copyDict['op'] == 1 and ' event_cutted' or ' event_copied'
        typeClass = ' type-'+brain.portal_type
        colorDict = getColorIndex(self.context, self.request, brain=brain)
        colorIndex = colorDict.get('class', '')
        color = colorDict.get('color', '')
        extraClass = self.getBrainExtraClass(brain)
        HANDLE_RECURRENCE = HAS_RECURRENCE_SUPPORT and self.request.get('start') and self.request.get('end')
        if HANDLE_RECURRENCE:
            event = brain.getObject()
            start = DateTime(self.request.get('start'))
            end = DateTime(self.request.get('end'))
            occurences = IRecurrence(event).occurrences(limit_start=start, limit_end=end)
            occurenceClass = ' occurence'
        else:
            occurences = [(brainstart.rfc822(), brainend.rfc822())]
            occurenceClass = ''
        events = []
        for occurence_start, occurence_end in occurences:
            events.append({
                "id": "UID_%s" % (brain.UID),
                "title": brain.Title,
                "description": brain.Description,
                "start": HANDLE_RECURRENCE and occurence_start.isoformat() or occurence_start,
                "end": HANDLE_RECURRENCE and occurence_end.isoformat() or occurence_end,
                "url": brain.getURL(),
                "editable": editable,
                "allDay": allday,
                "className": "contextualContentMenuEnabled state-" + str(brain.review_state) + (editable and " editable" or "")+copycut+typeClass+colorIndex+extraClass+occurenceClass,
                "color": color})
        return events
    def dictFromObject(self, item, args={}):
        eventPhysicalPath = '/'.join(item.getPhysicalPath())
        wft = getToolByName(self.context, 'portal_workflow')
        state = wft.getInfoFor(self.context, 'review_state')
        member = self.context.portal_membership.getAuthenticatedMember()
        if member.has_permission('Modify portal content', item):
            editable = True

        if item.end() - item.start() > 1.0:
            allday = True
        else:
            allday = False

        adapted = interfaces.ISFBaseEventFields(item, None)
        if adapted:
            allday = adapted.allDay

        copycut = ''
        if self.copyDict and eventPhysicalPath == self.copyDict['url']:
            copycut = self.copyDict['op'] == 1 and ' event_cutted' or ' event_copied'

        typeClass = ' type-' + item.portal_type
        colorDict = getColorIndex(self.context, self.request, eventPhysicalPath)
        colorIndex = colorDict.get('class', '')
        color = colorDict.get('color', '')
        extraClass = self.getObjectExtraClass(item)
        HANDLE_RECURRENCE = HAS_RECURRENCE_SUPPORT and self.request.get('start') and self.request.get('end')
        if HANDLE_RECURRENCE:
            start = DateTime(self.request.get('start'))
            end = DateTime(self.request.get('end'))
            occurences = IRecurrence(item).occurrences(limit_start=start, limit_end=end)
            occurenceClass = ' occurence'
        else:
            occurences = [(item.start().rfc822(), item.end().rfc822())]
            occurenceClass = ''
        events = []
        for occurence_start, occurence_end in occurences:
            events.append({
                "status": "ok",
                "id": "UID_%s" % (item.UID()),
                "title": item.Title(),
                "description": item.Description(),
                "start": HANDLE_RECURRENCE and occurence_start.isoformat() or occurence_start,
                "end": HANDLE_RECURRENCE and occurence_end.isoformat() or occurence_end,
                "url": item.absolute_url(),
                "editable": editable,
                "allDay": allday,
                "className": "contextualContentMenuEnabled state-" + str(state) + (editable and " editable" or "")+copycut+typeClass+colorIndex+extraClass+occurenceClass,
                "color": color})

        return events
    def dictFromObject(self, item):
        eventPhysicalPath = '/'.join(item.getPhysicalPath())
        wft = getToolByName(self.context, 'portal_workflow')
        state = wft.getInfoFor(self.context, 'review_state')
        member = self.context.portal_membership.getAuthenticatedMember()
        if member.has_permission('Modify portal content', item):
            editable = True

        if item.end() - item.start() > 1.0:
            allday = True
        else:
            allday = False

        adapted = interfaces.ISFBaseEventFields(item, None)
        if adapted:
            allday = adapted.allDay

        copycut = ''
        if self.copyDict and eventPhysicalPath == self.copyDict['url']:
            copycut = self.copyDict['op'] == 1 and ' event_cutted' or ' event_copied'

        typeClass = ' type-' + item.portal_type
        colorIndex = getColorIndex(self.context, self.request, eventPhysicalPath)
        extraClass = self.getObjectExtraClass(item)
        if hasPloneAppEvent:
            occurences = item.occurrences()
        else:
            occurences = [(item.start().rfc822(), item.end().rfc822())]
        events = []
        for occurence_start, occurence_end in occurences:
            events.append({
                "status": "ok",
                "id": "UID_%s" % (item.UID()),
                "title": item.Title(),
                "description": item.Description(),
                "start": hasPloneAppEvent and occurence_start.isoformat() or occurence_start,
                "end": hasPloneAppEvent and occurence_end.isoformat() or occurence_end,
                "url": item.absolute_url(),
                "editable": editable,
                "allDay": allday,
                "className": "contextualContentMenuEnabled state-" + str(state) + (editable and " editable" or "")+copycut+typeClass+colorIndex+extraClass})

        return events
Beispiel #13
0
    def __call__(self):
        event = self.context
        context = self.context
        referer = self.request.get('HTTP_REFERER')
        if referer:
            portal = getToolByName(self.context, 'portal_url').getPortalObject()
            url = '/' + portal.id + referer.replace(portal.absolute_url(), '')
            context = portal.restrictedTraverse(url)
        eventPhysicalPath = '/'.join(event.getPhysicalPath())
        wft = getToolByName(context, 'portal_workflow')
        state = wft.getInfoFor(event, 'review_state')
        member = context.portal_membership.getAuthenticatedMember()
        editable = bool(member.has_permission('Modify portal content', event))

        copycut = ''
        if self.copyDict and eventPhysicalPath == self.copyDict['url']:
            copycut = self.copyDict['op'] == 1 and ' event_cutted' \
                                             or ' event_copied'

        typeClass = ' type-' + event.portal_type
        colorDict = getColorIndex(context, self.request, eventPhysicalPath)
        colorIndex = colorDict.get('class', '')
        color = colorDict.get('color', '')
        extraClass = self.getExtraClass()

        events = []
        if handle_recurrence(self.request):
            start = DateTime(self.request.get('start'))
            end = DateTime(self.request.get('end'))
            events = IRecurrenceSupport(event).occurrences(range_start=start,
                                                           range_end=end)
        else:
            events = event
        return (dict_from_events(
            events,
            editable=editable,
            state=state,
            color=color,
            css=copycut + typeClass + colorIndex + extraClass
            ))
    def dictFromBrain(self, brain, editableEvents=[]):

        if brain.UID in editableEvents:
            editable = True
        else:
            editable = False

        if brain.end - brain.start > 1.0:
            allday = True
        else:
            allday = False

        if getattr(brain, 'SFAllDay', None) in [False,True]:
            allday = brain.SFAllDay

        copycut = ''
        if self.copyDict and brain.getPath() == self.copyDict['url']:
            copycut = self.copyDict['op'] == 1 and ' event_cutted' or ' event_copied'
        typeClass = ' type-'+brain.portal_type
        colorIndex = getColorIndex(self.context, self.request, brain=brain)
        extraClass = self.getBrainExtraClass(brain)
        if hasPloneAppEvent:
            event = brain.getObject()
            occurences = event.occurrences()
        else:
            occurences = [(brain.start.rfc822(), brain.end.rfc822())]
        events = []
        for occurence_start, occurence_end in occurences:
            events.append({
                "id": "UID_%s" % (brain.UID),
                "title": brain.Title,
                "description": brain.Description,
                "start": hasPloneAppEvent and occurence_start.isoformat() or occurence_start,
                "end": hasPloneAppEvent and occurence_end.isoformat() or occurence_end,
                "url": brain.getURL(),
                "editable": editable,
                "allDay": allday,
                "className": "contextualContentMenuEnabled state-" + str(brain.review_state) + (editable and " editable" or "")+copycut+typeClass+colorIndex+extraClass})
        return events
Beispiel #15
0
    def __call__(self):
        event = self.context
        context = self.context
        referer = self.request.get('HTTP_REFERER')
        if referer:
            portal = getToolByName(self.context,
                                   'portal_url').getPortalObject()
            url = "/".join(portal.getPhysicalPath()) + referer.replace(
                portal.absolute_url(), '')
            context = portal.restrictedTraverse(url)
        eventPhysicalPath = '/'.join(event.getPhysicalPath())
        wft = getToolByName(context, 'portal_workflow')
        state = wft.getInfoFor(event, 'review_state')
        member = context.portal_membership.getAuthenticatedMember()
        editable = bool(member.has_permission('Modify portal content', event))

        copycut = ''
        if self.copyDict and eventPhysicalPath == self.copyDict['url']:
            copycut = self.copyDict['op'] == 1 and ' event_cutted' \
                                             or ' event_copied'

        typeClass = ' type-' + event.portal_type
        colorDict = getColorIndex(context, self.request, eventPhysicalPath)
        colorIndex = colorDict.get('class', '')
        color = colorDict.get('color', '')
        extraClass = self.getExtraClass()

        events = []
        if handle_recurrence(self.request) and IRecurrenceSupport(event, None):
            events = get_recurring_events(self.request, event)
        else:
            events = event
        return (dict_from_events(events,
                                 editable=editable,
                                 state=state,
                                 color=color,
                                 css=copycut + typeClass + colorIndex +
                                 extraClass))