Пример #1
0
def get_exports(context, request, uuids):
    Export = namedtuple('Export', ('urls', 'title', 'description'))

    Url = namedtuple('Url', ('href', 'title'))

    translate = utils.translator(context, request)

    query = '&uuid='.join(uuids)
    urltemplate = ''.join(
        (context.absolute_url(), '/reservation-export.{ext}?source={id}&uuid=',
         query))

    exports = []
    for source in sources:

        urls = []
        for extension, title in extensions.items():
            urls.append(
                Url(urltemplate.format(ext=extension, id=source.id),
                    translate(title)))
        exports.append(
            Export(
                urls,
                translate(source.title),
                translate(source.description),
            ))

    return exports
Пример #2
0
    def events(self):
        resource = self.context
        scheduler = resource.scheduler()
        translate = utils.translator(self.context, self.request)

        is_exposed = exposure.for_allocations([resource])

        # get an event for each exposed allocation
        events = []
        for alloc in scheduler.allocations_in_range(*self.range):

            if not is_exposed(alloc):
                continue

            start = alloc.display_start(settings.timezone())
            end = alloc.display_end(settings.timezone())

            # get the urls
            urls = self.urls(alloc)

            # calculate the availability for title and class
            availability, title, klass = utils.event_availability(
                resource, self.request, scheduler, alloc
            )

            if alloc.partly_available:
                partitions = alloc.availability_partitions()
            else:
                # if the allocation is not partly available there can only
                # be one partition meant to be shown as empty unless the
                # availability is zero
                partitions = [(100, availability == 0.0)]

            event_header = alloc.whole_day and translate(_(u'Whole Day'))

            events.append(dict(
                title=title,
                start=start.isoformat(),
                end=end.isoformat(),
                className=klass,
                url=urls.default,
                menu=urls.menu,
                menuorder=urls.order,
                allocation=alloc.id,
                partitions=partitions,
                group=alloc.group,
                allDay=False,
                moveurl=urls.move,
                header=event_header
            ))

        return events
Пример #3
0
    def events(self):
        resource = self.context
        scheduler = resource.scheduler()
        translate = utils.translator(self.context, self.request)

        is_exposed = exposure.for_allocations(resource, [resource])

        # get an event for each exposed allocation
        events = []
        for alloc in scheduler.allocations_in_range(*self.range):

            if not is_exposed(alloc):
                continue

            start, end = alloc.display_start, alloc.display_end

            # get the urls
            urls = self.urls(alloc)

            # calculate the availability for title and class
            availability, title, klass = utils.event_availability(
                resource, self.request, scheduler, alloc
            )

            if alloc.partly_available:
                partitions = alloc.availability_partitions(scheduler)
            else:
                # if the allocation is not partly available there can only
                # be one partition meant to be shown as empty unless the
                # availability is zero
                partitions = [(100, availability == 0.0)]

            event_header = alloc.whole_day and translate(_(u'Whole Day'))

            events.append(dict(
                title=title,
                start=start.isoformat(),
                end=end.isoformat(),
                className=klass,
                url=urls.default,
                menu=urls.menu,
                menuorder=urls.order,
                allocation=alloc.id,
                partitions=partitions,
                group=alloc.group,
                allDay=False,
                moveurl=urls.move,
                header=event_header
            ))

        return events
Пример #4
0
def get_exports(context, request, uuids):
    Export = namedtuple(
        'Export', ('urls', 'title', 'description')
    )

    Url = namedtuple(
        'Url', ('href', 'title')
    )

    translate = utils.translator(context, request)

    query = '&uuid='.join(uuids)
    urltemplate = ''.join(
        (
            context.absolute_url(), 
            '/reservation-export.{ext}?source={id}&uuid=', 
            query
        )
    )

    exports = []
    for source in sources:
        
        urls = []
        for extension, title in extensions.items():
            urls.append(
                Url(
                    urltemplate.format(ext=extension, id=source.id),
                    translate(title)
                )
            )
        exports.append(Export(
            urls,
            translate(source.title),
            translate(source.description),
        ))

    return exports