当前位置: 首页>>代码示例>>Python>>正文


Python Period.get_occurrence_partials方法代码示例

本文整理汇总了Python中schedule.periods.Period.get_occurrence_partials方法的典型用法代码示例。如果您正苦于以下问题:Python Period.get_occurrence_partials方法的具体用法?Python Period.get_occurrence_partials怎么用?Python Period.get_occurrence_partials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在schedule.periods.Period的用法示例。


在下文中一共展示了Period.get_occurrence_partials方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: json_period

# 需要导入模块: from schedule.periods import Period [as 别名]
# 或者: from schedule.periods.Period import get_occurrence_partials [as 别名]
def json_period(request, calender_id):
    calendar = get_object_or_404(Calendar, pk=calender_id)
    ts_start = float(request.GET.get("start", None))
    ts_end = float(request.GET.get("end", None))
    # if not request.is_ajax(): raise Http404

    # period = Month(GET_EVENTS_FUNC(request,calendar)
    # ,date=datetime.datetime(year=2008,month=11,day=1)
    # ,date=datetime.datetime.now()
    # )

    period = Period(
        GET_EVENTS_FUNC(request, calendar),
        start=datetime.datetime.fromtimestamp(ts_start),
        end=datetime.datetime.fromtimestamp(ts_end),
    )

    context = {"calendar": calendar, "occurences": period.get_occurrence_partials()}  # {occurence,class}
    dates = [
        {
            "title": occ["occurrence"].title,
            "start": occ["occurrence"].start.isoformat(),
            "end": occ["occurrence"].end.isoformat(),
            "allDay": False,
        }
        for occ in period.get_occurrence_partials()
    ]

    return HttpResponse(json.dumps(dates), mimetype="application/json")
开发者ID:frejsoya,项目名称:django-schedule,代码行数:31,代码来源:views.py

示例2: TestPeriod

# 需要导入模块: from schedule.periods import Period [as 别名]
# 或者: from schedule.periods.Period import get_occurrence_partials [as 别名]
class TestPeriod(TestCase):
    def setUp(self):
        rule = Rule.objects.create(frequency="WEEKLY")
        cal = Calendar.objects.create(name="MyCal")
        data = {
            'title': 'Recent Event',
            'start': datetime.datetime(2008, 1, 5, 8, 0, tzinfo=pytz.utc),
            'end': datetime.datetime(2008, 1, 5, 9, 0, tzinfo=pytz.utc),
            'end_recurring_period': datetime.datetime(2008, 5, 5, 0, 0, tzinfo=pytz.utc),
            'rule': rule,
            'calendar': cal,
        }
        Event.objects.create(**data)
        self.period = Period(
            events=Event.objects.all(),
            start=datetime.datetime(2008, 1, 4, 7, 0, tzinfo=pytz.utc),
            end=datetime.datetime(2008, 1, 21, 7, 0, tzinfo=pytz.utc))

    def test_get_occurrences(self):
        occurrence_list = self.period.occurrences
        self.assertEqual(
            ["%s to %s" % (o.start, o.end) for o in occurrence_list],
            [
                '2008-01-05 08:00:00+00:00 to 2008-01-05 09:00:00+00:00',
                '2008-01-12 08:00:00+00:00 to 2008-01-12 09:00:00+00:00',
                '2008-01-19 08:00:00+00:00 to 2008-01-19 09:00:00+00:00',
            ]
        )

    def test_get_occurrence_partials(self):
        occurrence_dicts = self.period.get_occurrence_partials()
        self.assertEqual(
            [
                (occ_dict["class"], occ_dict["occurrence"].start, occ_dict["occurrence"].end)
                for occ_dict in occurrence_dicts
            ],
            [
                (1,
                 datetime.datetime(2008, 1, 5, 8, 0, tzinfo=pytz.utc),
                 datetime.datetime(2008, 1, 5, 9, 0, tzinfo=pytz.utc)),
                (1,
                 datetime.datetime(2008, 1, 12, 8, 0, tzinfo=pytz.utc),
                 datetime.datetime(2008, 1, 12, 9, 0, tzinfo=pytz.utc)),
                (1,
                 datetime.datetime(2008, 1, 19, 8, 0, tzinfo=pytz.utc),
                 datetime.datetime(2008, 1, 19, 9, 0, tzinfo=pytz.utc))
            ])

    def test_has_occurrence(self):
        self.assertTrue(self.period.has_occurrences())
        slot = self.period.get_time_slot(
            datetime.datetime(2008, 1, 4, 7, 0, tzinfo=pytz.utc),
            datetime.datetime(2008, 1, 4, 7, 12, tzinfo=pytz.utc))
        self.assertFalse(slot.has_occurrences())
开发者ID:drodger,项目名称:django-scheduler,代码行数:56,代码来源:test_periods.py

示例3: TestPeriod

# 需要导入模块: from schedule.periods import Period [as 别名]
# 或者: from schedule.periods.Period import get_occurrence_partials [as 别名]
class TestPeriod(TestCase):
    def setUp(self):
        rule = Rule(frequency="WEEKLY")
        rule.save()
        cal = Calendar(name="MyCal")
        cal.save()
        data = {
            'title': 'Recent Event',
            'start': datetime.datetime(2008, 1, 5, 8, 0),
            'end': datetime.datetime(2008, 1, 5, 9, 0),
            'end_recurring_period': datetime.datetime(2008, 5, 5, 0, 0),
            'rule': rule,
            'calendar': cal
        }
        recurring_event = Event(**data)
        recurring_event.save()
        self.period = Period(events=Event.objects.all(),
                             start=datetime.datetime(2008, 1, 4, 7, 0),
                             end=datetime.datetime(2008, 1, 21, 7, 0))

    def test_get_occurrences(self):
        occurrence_list = self.period.occurrences
        expected = [
            '2008-01-05 08:00:00 to 2008-01-05 09:00:00',
            '2008-01-12 08:00:00 to 2008-01-12 09:00:00',
            '2008-01-19 08:00:00 to 2008-01-19 09:00:00',
        ]
        self.assertEqual(["%s to %s" % (o.start, o.end) for o in occurrence_list], expected)

    def test_get_occurrence_partials(self):
        occurrence_dicts = self.period.get_occurrence_partials()
        self.assertEqual(
            [(occ_dict["class"],
            occ_dict["occurrence"].start,
            occ_dict["occurrence"].end)
            for occ_dict in occurrence_dicts],
            [
                (1,
                 datetime.datetime(2008, 1, 5, 8, 0),
                 datetime.datetime(2008, 1, 5, 9, 0)),
                (1,
                 datetime.datetime(2008, 1, 12, 8, 0),
                 datetime.datetime(2008, 1, 12, 9, 0)),
                (1,
                 datetime.datetime(2008, 1, 19, 8, 0),
                 datetime.datetime(2008, 1, 19, 9, 0))
            ])

    def test_has_occurrence(self):
        self.assert_(self.period.has_occurrences())
        slot = self.period.get_time_slot(datetime.datetime(2008, 1, 4, 7, 0),
                                         datetime.datetime(2008, 1, 4, 7, 12))
        self.failIf(slot.has_occurrences())
开发者ID:macanhhuy,项目名称:django-schedule,代码行数:55,代码来源:test_periods.py

示例4: TestPeriod

# 需要导入模块: from schedule.periods import Period [as 别名]
# 或者: from schedule.periods.Period import get_occurrence_partials [as 别名]
class TestPeriod(TestCase):
    def setUp(self):
        rule = Rule(frequency="WEEKLY")
        rule.save()
        cal = Room(name="MyCal")
        cal.save()
        data = {
            "title": "Recent Reservation",
            "start": datetime.datetime(2008, 1, 5, 8, 0),
            "end": datetime.datetime(2008, 1, 5, 9, 0),
            "end_recurring_period": datetime.datetime(2008, 5, 5, 0, 0),
            "rule": rule,
            "room": cal,
        }
        recurring_reservation = Reservation(**data)
        recurring_reservation.save()
        self.period = Period(
            reservations=Reservation.objects.all(),
            start=datetime.datetime(2008, 1, 4, 7, 0),
            end=datetime.datetime(2008, 1, 21, 7, 0),
        )

    def test_get_occurrences(self):
        occurrence_list = self.period.occurrences
        self.assertEqual(
            ["%s to %s" % (o.start, o.end) for o in occurrence_list],
            [
                "2008-01-05 08:00:00 to 2008-01-05 09:00:00",
                "2008-01-12 08:00:00 to 2008-01-12 09:00:00",
                "2008-01-19 08:00:00 to 2008-01-19 09:00:00",
            ],
        )

    def test_get_occurrence_partials(self):
        occurrence_dicts = self.period.get_occurrence_partials()
        self.assertEqual(
            [
                (occ_dict["class"], occ_dict["occurrence"].start, occ_dict["occurrence"].end)
                for occ_dict in occurrence_dicts
            ],
            [
                (1, datetime.datetime(2008, 1, 5, 8, 0), datetime.datetime(2008, 1, 5, 9, 0)),
                (1, datetime.datetime(2008, 1, 12, 8, 0), datetime.datetime(2008, 1, 12, 9, 0)),
                (1, datetime.datetime(2008, 1, 19, 8, 0), datetime.datetime(2008, 1, 19, 9, 0)),
            ],
        )

    def test_has_occurrence(self):
        self.assert_(self.period.has_occurrences())
        slot = self.period.get_time_slot(datetime.datetime(2008, 1, 4, 7, 0), datetime.datetime(2008, 1, 4, 7, 12))
        self.failIf(slot.has_occurrences())
开发者ID:bjdag1234,项目名称:django-schedule-rooms,代码行数:53,代码来源:test_periods.py

示例5: TestPeriod

# 需要导入模块: from schedule.periods import Period [as 别名]
# 或者: from schedule.periods.Period import get_occurrence_partials [as 别名]
class TestPeriod(TestCase):

    def setUp(self):
        rule = Rule(frequency = "WEEKLY")
        rule.save()
        data = {
                'title': 'Recent Event',
                'start': datetime.datetime(2008, 1, 5, 8, 0),
                'end': datetime.datetime(2008, 1, 5, 9, 0),
                'end_recurring_period' : datetime.datetime(2008, 5, 5, 0, 0),
                'rule': rule,
               }
        recurring_event = Event(**data)
        recurring_event.save()
        self.period = Period(events=Event.objects.all(),
                            start = datetime.datetime(2008,1,4,7,0),
                            end = datetime.datetime(2008,1,21,7,0))
    def test_get_occurences(self):
        occurrence_list = self.period.occurrences
        self.assertEqual(["%s to %s" %(o.start, o.end) for o in occurrence_list],
            ['2008-01-05 08:00:00 to 2008-01-05 09:00:00',
             '2008-01-12 08:00:00 to 2008-01-12 09:00:00',
             '2008-01-19 08:00:00 to 2008-01-19 09:00:00'])

    def test_get_occurrence_partials(self):
        occurrence_dicts = self.period.get_occurrence_partials()
        self.assertEqual(
            [(occ_dict["class"],
            occ_dict["occurrence"].start,
            occ_dict["occurrence"].end)
            for occ_dict in occurrence_dicts],
            [
                (1,
                 datetime.datetime(2008, 1, 5, 8, 0),
                 datetime.datetime(2008, 1, 5, 9, 0)),
                (1,
                 datetime.datetime(2008, 1, 12, 8, 0),
                 datetime.datetime(2008, 1, 12, 9, 0)),
                (1,
                 datetime.datetime(2008, 1, 19, 8, 0),
                 datetime.datetime(2008, 1, 19, 9, 0))
            ])
开发者ID:TheProjecter,项目名称:pinax-cohousing,代码行数:44,代码来源:tests.py


注:本文中的schedule.periods.Period.get_occurrence_partials方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。