コード例 #1
0
ファイル: resource.py プロジェクト: scott50301/DS-project
def get_queries(resources):
    libres_util = getUtility(ILibresUtility)
    libres_util.context.set_service(
        'exposure',
        lambda ctx: LibresExposure(exposure.for_allocations(resources)))

    return libres.db.queries.Queries(libres_util.context)
コード例 #2
0
    def scheduler(self, language=None):
        uuid = utils.string_uuid(self.uuid())
        is_exposed = exposure.for_allocations(self, [uuid])

        return db.Scheduler(
            self.uuid(), is_exposed=is_exposed, language=language
        )
コード例 #3
0
    def events(self):
        """ Returns the events for the overview. """

        start, end = self.range
        if not all((start, end)):
            return []

        events = []

        uuids = self.uuids()

        is_exposed = exposure.for_allocations(self.context, uuids)

        days = db.availability_by_day(start, end, uuids, is_exposed)
        for day, result in days.items():

            event_start = datetime(day.year, day.month, day.day, 0, 0)
            event_end = event_start + timedelta(days=+1, microseconds=-1)

            availability, resources = result
            events.append(
                dict(start=event_start.isoformat(),
                     end=event_end.isoformat(),
                     title=u'',
                     uuids=[utils.string_uuid(r) for r in resources],
                     className=utils.event_class(availability)))

        return events
コード例 #4
0
    def events(self):
        """ Returns the events for the overview. """

        start, end = self.range
        if not all((start, end)):
            return []

        events = []

        uuids = self.uuids()

        is_exposed = exposure.for_allocations(self.context, uuids)

        days = db.availability_by_day(start, end, uuids, is_exposed)
        for day, result in days.items():

            event_start = datetime(day.year, day.month, day.day, 0, 0)
            event_end = event_start + timedelta(days=+1, microseconds=-1)

            availability, resources = result
            events.append(dict(
                start=event_start.isoformat(),
                end=event_end.isoformat(),
                title=u'',
                uuids=[utils.string_uuid(r) for r in resources],
                className=utils.event_class(availability)
            ))

        return events
コード例 #5
0
def get_queries(resources):
    libres_util = getUtility(ILibresUtility)
    libres_util.context.set_service(
        'exposure',
        lambda ctx: LibresExposure(exposure.for_allocations(resources))
    )

    return libres.db.queries.Queries(libres_util.context)
コード例 #6
0
ファイル: resource.py プロジェクト: scott50301/DS-project
    def scheduler(self, language=None):
        uuid = utils.string_uuid(self.uuid())

        libres_util = getUtility(ILibresUtility)
        libres_util.context.set_service(
            'exposure',
            lambda ctx: LibresExposure(exposure.for_allocations([uuid])))

        return libres_util.scheduler(uuid, settings.timezone().zone)
コード例 #7
0
    def scheduler(self, language=None):
        uuid = utils.string_uuid(self.uuid())

        libres_util = getUtility(ILibresUtility)
        libres_util.context.set_service(
            'exposure',
            lambda ctx: LibresExposure(exposure.for_allocations([uuid]))
        )

        return libres_util.scheduler(uuid, settings.timezone().zone)
コード例 #8
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
コード例 #9
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