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


Python Rule.save方法代码示例

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


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

示例1: setUp

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
    def setUp(self):
        weekly = Rule(frequency = "WEEKLY")
        weekly.save()
        daily = Rule(frequency = "DAILY")
        daily.save()
        cal = Room(name="MyCal")
        cal.save()

        self.reservation1 = Reservation(**{
                'title': 'Weekly Reservation',
                'start': datetime.datetime(2009, 4, 1, 8, 0),
                'end': datetime.datetime(2009, 4, 1, 9, 0),
                'end_recurring_period' : datetime.datetime(2009, 10, 5, 0, 0),
                'rule': weekly,
                'room': cal
               })
        self.reservation1.save()
        self.reservation2 = Reservation(**{
                'title': 'Recent Reservation',
                'start': datetime.datetime(2008, 1, 5, 9, 0),
                'end': datetime.datetime(2008, 1, 5, 10, 0),
                'end_recurring_period' : datetime.datetime(2009, 5, 5, 0, 0),
                'rule': daily,
                'room': cal
               })
        self.reservation2.save()
开发者ID:bjdag1234,项目名称:django-schedule-rooms,代码行数:28,代码来源:test_utils.py

示例2: setUp

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
 def setUp(self):
     rule = Rule(frequency="WEEKLY")
     rule.save()
     cal = Calendar(name="MyCal")
     cal.save()
     self.recurring_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
     }
     self.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),
         'calendar': cal
     }
     self.near_periodend_recurring_data = {
         'title': 'Special Event',
         'start': datetime.datetime(2014, 5, 1, 8, 0, tzinfo=pytz.utc),
         'end': datetime.datetime(2014, 5, 1, 9, 0, tzinfo=pytz.utc),
         'end_recurring_period': datetime.datetime(2014, 5, 8, 9, 0, tzinfo=pytz.utc),
         'rule': rule,
         'calendar': cal
     }
     self.recurring_event = Event.objects.create(**self.recurring_data)
     self.start = datetime.datetime(2008, 1, 12, 0, 0, tzinfo=pytz.utc)
     self.end = datetime.datetime(2008, 1, 27, 0, 0, tzinfo=pytz.utc)
开发者ID:jrutila,项目名称:django-schedule,代码行数:33,代码来源:test_occurrence.py

示例3: test_recurring_event_get_occurrence_in_timezone

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
    def test_recurring_event_get_occurrence_in_timezone(self):
        cal = Calendar(name="MyCal")
        cal.save()
        rule = Rule(frequency = "WEEKLY")
        rule.save()

        # Event start and end are UTC because that is what is coming
        # from the database
        event = self.__create_recurring_event(
                    'Recurrent event test get_occurrence',
                    datetime.datetime(2014, 3, 21, 6, 0, tzinfo=pytz.utc),
                    datetime.datetime(2014, 3, 21, 8, 0, tzinfo=pytz.utc),
                    datetime.datetime(2014, 4, 11, 0, 0, tzinfo=pytz.utc),
                    rule,
                    cal,
                    )
        event.save()
        tzinfo = pytz.timezone('Europe/Helsinki')
        start = tzinfo.localize(datetime.datetime(2014, 3, 28, 8, 0)) # +2
        occurrence = event.get_occurrence(start)
        self.assertEqual(occurrence.start, start)
        occurrence.save()
        # DST change on March 30th from +2 to +3
        start = tzinfo.localize(datetime.datetime(2014, 4, 4, 8, 0)) # +3
        occurrence = event.get_occurrence(start)
        self.assertEqual(occurrence.start, start)
开发者ID:jrutila,项目名称:django-scheduler,代码行数:28,代码来源:test_event.py

示例4: setUp

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
    def setUp(self):
        self.day = Day(events=Event.objects.all(),
                       date=datetime.datetime(datetime.datetime.now().year, 2, 7, 0, 0, tzinfo=pytz.utc))
        self.day_out_of_limit = Day(events=Event.objects.all(),
                       date=datetime.datetime(datetime.datetime.now().year + 3, 2, 7, 0, 0, tzinfo=pytz.utc))
        self.day_out_of_limit_lower = Day(events=Event.objects.all(),
                       date=datetime.datetime(datetime.datetime.now().year - 3, 2, 7, 0, 0, tzinfo=pytz.utc))

        rule = Rule(frequency='WEEKLY')
        rule.save()
        self.cal = Calendar(name='MyCal', slug='MyCalSlug')
        self.cal.save()

        data = {
            'title': 'Recent Event',
            'start': datetime.datetime(datetime.datetime.now().year, 1, 5, 8, 0, tzinfo=pytz.utc),
            'end': datetime.datetime(datetime.datetime.now().year, 1, 5, 9, 0, tzinfo=pytz.utc),
            'end_recurring_period': datetime.datetime(datetime.datetime.now().year, 5, 5, 0, 0, tzinfo=pytz.utc),
            'rule': rule,
            'calendar': self.cal,
        }
        recurring_event = Event(**data)
        recurring_event.save()
        self.period = Period(events=Event.objects.all(),
                             start=datetime.datetime(datetime.datetime.now().year, 1, 4, 7, 0, tzinfo=pytz.utc),
                             end=datetime.datetime(datetime.datetime.now().year, 1, 21, 7, 0, tzinfo=pytz.utc))
开发者ID:nwaxiomatic,项目名称:django-scheduler,代码行数:28,代码来源:test_templatetags.py

示例5: test_recurring_event_with_moved_get_occurrences_after

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
    def test_recurring_event_with_moved_get_occurrences_after(self):

        cal = Calendar(name="MyCal")
        cal.save()
        rule = Rule(frequency="WEEKLY")
        rule.save()
        recurring_event= self.__create_recurring_event(
                    'Recurrent event test get_occurrence',
                    datetime.datetime(2008, 1, 5, 8, 0, tzinfo=pytz.utc),
                    datetime.datetime(2008, 1, 5, 9, 0, tzinfo=pytz.utc),
                    datetime.datetime(2008, 5, 5, 0, 0, tzinfo=pytz.utc),
                    rule,
                    cal,
                    )

        recurring_event.save()
        occurrence = recurring_event.get_occurrence(datetime.datetime(2008, 1, 12, 8, 0, tzinfo=pytz.utc))
        occurrence.move(
          datetime.datetime(2008, 1, 15, 8, 0, tzinfo=pytz.utc),
          datetime.datetime(2008, 1, 15, 9, 0, tzinfo=pytz.utc))
        gen = recurring_event.occurrences_after(
          datetime.datetime(2008, 1, 14, 8, 0, tzinfo=pytz.utc))
        occurrence2 = next(gen)
        #    end = datetime.datetime(2008, 1, 6, tzinfo=pytz.utc))
        #occurrence = occurrences[0]
        #occurrence2 = recurring_event.occurrences_after(datetime.datetime(2008, 1, 5, tzinfo=pytz.utc)).next()
        self.assertEqual(occurrence, occurrence2)
开发者ID:nwaxiomatic,项目名称:django-scheduler,代码行数:29,代码来源:test_event.py

示例6: setUp

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
    def setUp(self):
        weekly = Rule(frequency="WEEKLY")
        weekly.save()
        daily = Rule(frequency="DAILY")
        daily.save()
        cal = Calendar(name="MyCal")
        cal.save()

        self.event1 = Event(**{
            'title': 'Weekly Event',
            'start': datetime.datetime(2009, 4, 1, 8, 0),
            'end': datetime.datetime(2009, 4, 1, 9, 0),
            'end_recurring_period': datetime.datetime(2009, 10, 5, 0, 0),
            'rule': weekly,
            'calendar': cal
        })
        self.event1.save()
        self.event2 = Event(**{
            'title': 'Recent Event',
            'start': datetime.datetime(2008, 1, 5, 9, 0),
            'end': datetime.datetime(2008, 1, 5, 10, 0),
            'end_recurring_period': datetime.datetime(2009, 5, 5, 0, 0),
            'rule': daily,
            'calendar': cal
        })
        self.event2.save()
开发者ID:macanhhuy,项目名称:django-schedule,代码行数:28,代码来源:test_utils.py

示例7: test_event_can_be_recurring

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
 def test_event_can_be_recurring(self):
     rule = Rule(
         name=random_string(),
         description=random_string(),
         frequency='WEEKLY',
     )
     rule.save()
     try:
         url = reverse(
             'openduty.events.create_or_edit_event',
             kwargs = {
                 'calendar_slug': self.cal.slug,
                 'event_id': str(self.event.id),
             },
         )
         response = self.client.post(
             path = url,
             data = {
                 "start_0": self.event.start.strftime('%Y-%m-%d'),
                 "start_1": "09:00",
                 "end_0": self.event.end.strftime('%Y-%m-%d'),
                 "end_1": "23:00",
                 "description": "desc",
                 "rule": str(rule.id),
                 "oncall": "foo",
                 "fallback": "bar",
             },
         )
         self.assertEqual(302, response.status_code)
         e = Event.objects.get(id=self.event.id)
         self.assertEqual(rule, e.rule)
     finally:
         rule.delete()
开发者ID:40a,项目名称:openduty,代码行数:35,代码来源:test_events.py

示例8: test_get_calendars_for_object_without_calendars

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
 def test_get_calendars_for_object_without_calendars(self):
     rule = Rule()
     rule.save()
     calendar = Calendar.objects.get_or_create_calendar_for_object(rule, name='My Cal', distinction='owner')
     rule = Rule()
     rule.save()
     calendars = list(Calendar.objects.get_calendars_for_object(rule, distinction='owner'))
     self.assertEqual(len(calendars), 0)
开发者ID:JoshLabs,项目名称:django-scheduler,代码行数:10,代码来源:test_calendar.py

示例9: test_get_calendar_for_object

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
 def test_get_calendar_for_object(self):
     calendar = Calendar(name='My Cal')
     calendar.save()
     rule = Rule()
     rule.save()
     calendar.create_relation(rule)
     result = Calendar.objects.get_calendar_for_object(rule)
     self.assertEqual(result.name, 'My Cal')
开发者ID:JoshLabs,项目名称:django-scheduler,代码行数:10,代码来源:test_calendar.py

示例10: test_get_or_create_calendar_for_object_withouth_name

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
 def test_get_or_create_calendar_for_object_withouth_name(self):
     """
         Test with already created calendar
     """
     rule = Rule()
     rule.save()
     calendar = Calendar.objects.get_or_create_calendar_for_object(rule)
     calendar_from_rule = Calendar.objects.get_calendars_for_object(rule)[0]
     self.assertEqual(calendar, calendar_from_rule)
开发者ID:JoshLabs,项目名称:django-scheduler,代码行数:11,代码来源:test_calendar.py

示例11: test_get_or_create_calendar_for_object_without_calendar

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
 def test_get_or_create_calendar_for_object_without_calendar(self):
     """
         Creation test
     """
     rule = Rule()
     rule.save()
     calendar = Calendar.objects.get_or_create_calendar_for_object(rule, name='My Cal')
     self.assertEqual(calendar.name, 'My Cal')
     calendar_from_rule = Calendar.objects.get_calendars_for_object(rule)[0]
     self.assertEqual(calendar, calendar_from_rule)
开发者ID:JoshLabs,项目名称:django-scheduler,代码行数:12,代码来源:test_calendar.py

示例12: test_get_calendar_for_object_with_more_than_one_calendar

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
 def test_get_calendar_for_object_with_more_than_one_calendar(self):
     calendar_1 = Calendar(name='My Cal 1')
     calendar_1.save()
     calendar_2 = Calendar(name='My Cal 2')
     calendar_2.save()
     rule = Rule()
     rule.save()
     calendar_1.create_relation(rule)
     calendar_2.create_relation(rule)
     with self.assertRaises(AssertionError):
         result = Calendar.objects.get_calendar_for_object(rule)
开发者ID:JoshLabs,项目名称:django-scheduler,代码行数:13,代码来源:test_calendar.py

示例13: test_calendar_absolute_and_event_url

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
    def test_calendar_absolute_and_event_url(self):
        """
            this test seems to not make too much send, just added since an
            url was with wrong reverse name.

        """
        rule = Rule()
        rule.save()
        calendar = Calendar.objects.get_or_create_calendar_for_object(rule, name='My Cal', distinction='owner')
        abs_url = calendar.get_absolute_url()
        calendar.add_event_url()
        relation = CalendarRelation.objects.create_relation(calendar, rule)
开发者ID:Gustavosdo,项目名称:django-scheduler,代码行数:14,代码来源:test_calendar.py

示例14: setUp

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
 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.month = Month(events=Event.objects.all(),
                        date=datetime.datetime(2008, 2, 7, 9, 0))
开发者ID:schacon,项目名称:django-schedule,代码行数:16,代码来源:tests.py

示例15: setUp

# 需要导入模块: from schedule.models import Rule [as 别名]
# 或者: from schedule.models.Rule import save [as 别名]
 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,
     }
     self.recurring_reservation = Reservation(**data)
     self.recurring_reservation.save()
开发者ID:bjdag1234,项目名称:django-schedule-rooms,代码行数:17,代码来源:test_periods.py


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