• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Event类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setUp

    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,代码行数:26,代码来源:test_utils.py


示例2: TestOccurrencePool

class TestOccurrencePool(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, 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.recurring_event = Event(**data)
        self.recurring_event.save()

    def testPeriodFromPool(self):
        """
            Test that period initiated with occurrence_pool returns the same occurrences as "straigh" period
            in a corner case whereby a period's start date is equal to the occurrence's end date
        """
        start = datetime.datetime(2008, 1, 5, 9, 0, tzinfo=pytz.utc)
        end = datetime.datetime(2008, 1, 5, 10, 0, tzinfo=pytz.utc)
        parent_period = Period(Event.objects.all(), start, end)
        period = Period(parent_period.events, start, end, parent_period.get_persisted_occurrences(), parent_period.occurrences)
        self.assertEqual(parent_period.occurrences, period.occurrences)
开发者ID:Gustavosdo,项目名称:django-scheduler,代码行数:28,代码来源:test_periods.py


示例3: setUp

    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,代码行数:26,代码来源:test_templatetags.py


示例4: add_new

    def add_new(self, user):
        try:
            client = Client.objects.get(pk=self.cleaned_data["client"])

            if client.phone:
                event_title = "{name} {phone} {id}".format(
                    name=client.get_full_name(), phone=client.phone, id=client.client_id
                )
            else:
                event_title = "{name} {id}".format(name=client.get_full_name(), id=client.client_id)

            event = Event(
                start=parser.parse(self.cleaned_data["start_datetime"]),
                end=parser.parse(self.cleaned_data["end_datetime"]),
                title=event_title,
                creator=user,
            )
            event.save()
            appointment = Appointment(
                client=client,
                venue=Venue.objects.get(pk=self.cleaned_data["venue_id"]),
                event=event,
                creator=user,
                customer=user.userprofile.customer,
            )
            appointment.save()
            return appointment
        except Client.DoesNotExist:
            return False
开发者ID:Avatazjoe,项目名称:apr,代码行数:29,代码来源:forms.py


示例5: TestAwareDay

class TestAwareDay(TestCase):
    def setUp(self):
        self.timezone = pytz.timezone('Europe/Amsterdam')

        start = self.timezone.localize(datetime.datetime(2008, 2, 7, 0, 20))
        end = self.timezone.localize(datetime.datetime(2008, 2, 7, 0, 21))
        self.event = Event(
            title='One minute long event on january seventh 2008 at 00:20 in Amsterdam.',
            start=start,
            end=end,
        )
        self.event.save()

        self.day = Day(
            events=Event.objects.all(),
            date=self.timezone.localize(datetime.datetime(2008, 2, 7, 9, 0)),
            tzinfo=self.timezone,
        )

    def test_day_range(self):
        start = datetime.datetime(2008, 2, 6, 23, 0, tzinfo=pytz.utc)
        end = datetime.datetime(2008, 2, 7, 23, 0, tzinfo=pytz.utc)

        self.assertEqual(start, self.day.start)
        self.assertEqual(end, self.day.end)

    def test_occurence(self):
        self.assertEqual(self.event in [o.event for o in self.day.occurrences], True)
开发者ID:Gustavosdo,项目名称:django-scheduler,代码行数:28,代码来源:test_periods.py


示例6: test_recurring_event_get_occurrences

 def test_recurring_event_get_occurrences(self):
     recurring_event = Event(**self.recurring_data)
     recurring_event.save()
     occurrences = recurring_event.get_occurrences(start=datetime.datetime(2008, 1, 12, 0, 0),
                                 end=datetime.datetime(2008, 1, 20, 0, 0))
     self.assertEquals(["%s to %s" %(o.start, o.end) for o in occurrences],
         ['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'])
开发者ID:schacon,项目名称:django-schedule,代码行数:7,代码来源:tests.py


示例7: test_event_get_occurrences_after

 def test_event_get_occurrences_after(self):
     recurring_event=Event(**self.recurring_data)
     recurring_event.save()
     occurrences = recurring_event.get_occurrences(start=datetime.datetime(2008, 1, 5),
         end = datetime.datetime(2008, 1, 6))
     occurrence = occurrences[0]
     occurrence2 = recurring_event.occurrences_after(datetime.datetime(2008,1,5)).next()
     self.assertEqual(occurrence, occurrence2)
开发者ID:CKiilu,项目名称:django-schedule,代码行数:8,代码来源:test_models.py


示例8: test_get_occurrence

 def test_get_occurrence(self):
     event = Event(**self.recurring_data)
     event.save()
     occurrence = event.get_occurrence(datetime.datetime(2008, 1, 5, 8, 0))
     self.assertEqual(occurrence.start, datetime.datetime(2008,1,5,8))
     occurrence.save()
     occurrence = event.get_occurrence(datetime.datetime(2008, 1, 5, 8, 0))
     self.assertTrue(occurrence.pk is not None)
开发者ID:CKiilu,项目名称:django-schedule,代码行数:8,代码来源:test_models.py


示例9: test_event_get_occurrences

    def test_event_get_occurrences(self):
        event= Event(**self.data)
        event.save()
        occurrences = event.get_occurrences(start=datetime.datetime(2008, 1, 12, 0, 0),
                                    end=datetime.datetime(2008, 1, 20, 0, 0))

        self.assertEquals(["%s to %s" %(o.start, o.end) for o in occurrences],
            [])
开发者ID:schacon,项目名称:django-schedule,代码行数:8,代码来源:tests.py


示例10: TestEventViews

class TestEventViews(LoggedInTestCase):

    def setUp(self):
        super(TestEventViews, self).setUp()
        self.cal = Calendar(
            name=random_string(),
            slug=random_string(),
        )
        self.cal.save()
        self.event = Event(
            start=timezone.now(),
            end=timezone.now() + timedelta(weeks=6),
            title=random_string(),
            calendar=self.cal,
        )
        self.event.save()

    def tearDown(self):
        super(TestEventViews, self).tearDown()
        try:
            self.cal.delete()
            self.event.delete()
        except:
            pass

    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,代码行数:58,代码来源:test_events.py


示例11: test_recurring_event_get_occurrences

 def test_recurring_event_get_occurrences(self):
     recurring_event = Event(**self.recurring_data)
     start = datetime.datetime(2008, 1, 12, 0, 0)
     end = datetime.datetime(2008, 1, 20, 0, 0)
     occurrences = recurring_event.get_occurrences(start=start, end=end)
     expected = [
         '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.assertEquals(["%s to %s" % (o.start, o.end) for o in occurrences], expected)
开发者ID:macanhhuy,项目名称:django-schedule,代码行数:10,代码来源:test_models.py


示例12: create_event

 def create_event(self, user):
     start = parser.parse(self.cleaned_data["start_datetime"])
     end = parser.parse(self.cleaned_data["end_datetime"])
     new_event = Event(
         start=start,
         end=end,
         title=self.cleaned_data["title"],
         description=self.cleaned_data["description"],
         creator=user,
     )
     new_event.save()
     return new_event
开发者ID:Avatazjoe,项目名称:apr,代码行数:12,代码来源:forms.py


示例13: test_get_escalation_fails_with_no_recurrence_after_event_end

 def test_get_escalation_fails_with_no_recurrence_after_event_end(self):
     event = Event(
         start = timezone.now() - timedelta(days=2),
         end = timezone.now() - timedelta(days=1),
         title = '{username},{username}'.format(username=self.username),
         calendar = self.cal,
     )
     event.save()
     try:
         events = get_escalation_for_service(self.service)
         self.assertEqual(0, len(events))
     finally:
         event.delete()
开发者ID:40a,项目名称:openduty,代码行数:13,代码来源:test_escalation_helper.py


示例14: test_edge_case_events

    def test_edge_case_events(self):
        cal = Calendar(name="MyCal")
        cal.save()
        data_1 = {
            'title': 'Edge case event test one',
            'start': datetime.datetime(2013, 1, 5, 8, 0, tzinfo=pytz.utc),
            'end': datetime.datetime(2013, 1, 5, 9, 0, tzinfo=pytz.utc),
            'calendar': cal
        }
        data_2 = {
            'title': 'Edge case event test two',
            'start': datetime.datetime(2013, 1, 5, 9, 0, tzinfo=pytz.utc),
            'end': datetime.datetime(2013, 1, 5, 12, 0, tzinfo=pytz.utc),
            'calendar': cal
        }
        event_one = Event(**data_1)
        event_two = Event(**data_2)
        event_one.save()
        event_two.save()
        occurrences_two = event_two.get_occurrences(datetime.datetime(2013, 1, 5, 9, 0, tzinfo=pytz.utc),
                                                    datetime.datetime(2013, 1, 5, 12, 0, tzinfo=pytz.utc))
        self.assertEqual(1, len(occurrences_two))

        occurrences_one = event_one.get_occurrences(datetime.datetime(2013, 1, 5, 9, 0, tzinfo=pytz.utc),
                                                    datetime.datetime(2013, 1, 5, 12, 0, tzinfo=pytz.utc))
        self.assertEqual(0, len(occurrences_one))
开发者ID:nwaxiomatic,项目名称:django-scheduler,代码行数:26,代码来源:test_event.py


示例15: test_get_escalation_returns_empty_for_muted_services

 def test_get_escalation_returns_empty_for_muted_services(self):
     event = Event(
         start = timezone.now() - timedelta(days=1),
         end = timezone.now() + timedelta(days=1),
         title = '{username},{username}'.format(username=self.username),
         calendar = self.cal,
     )
     event.save()
     self.service.notifications_disabled = True
     try:
         events = get_escalation_for_service(self.service)
         self.assertEqual(0, len(events))
     finally:
         event.delete()
开发者ID:40a,项目名称:openduty,代码行数:14,代码来源:test_escalation_helper.py


示例16: setUp

 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,代码行数:14,代码来源:tests.py


示例17: make_occurrences

 def make_occurrences(self, rule):
     cal = Calendar.objects.get(name="MyCal")
     recurring_data = {
             'title': 'Recent Event',
             'start': datetime.datetime(2010, 1, 1, 8, 0),
             'end': datetime.datetime(2010, 1, 1, 9, 0),
             'end_recurring_period' : datetime.datetime(2010, 2, 1, 0, 0),
             'rule': rule,
             'calendar': cal
            }
     recurring_event = Event(**recurring_data)
     occurrences = recurring_event.get_occurrences(start=datetime.datetime(2010, 1, 1, 0, 0),
                                 end=datetime.datetime(2010, 2, 1, 0, 0))
     return [o.start.day for o in occurrences]
开发者ID:ATOM49,项目名称:django-voip,代码行数:14,代码来源:test_rule.py


示例18: TestOccurrence

class TestOccurrence(TestCase):
    def setUp(self):
        rule = Rule(frequency = "WEEKLY")
        rule.save()
        self.recurring_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,
               }
        self.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),
               }
        self.recurring_event = Event(**self.recurring_data)
        self.recurring_event.save()
        self.start = datetime.datetime(2008, 1, 12, 0, 0)
        self.end = datetime.datetime(2008, 1, 27, 0, 0)
    
    def test_presisted_occurrences(self):
        occurrences = self.recurring_event.get_occurrences(start=self.start,
                                    end=self.end)
        persisted_occurrence = occurrences[0]
        persisted_occurrence.save()
        occurrences = self.recurring_event.get_occurrences(start=self.start,
                                    end=self.end)
        self.assertTrue(occurrences[0].pk)
        self.assertFalse(occurrences[1].pk)
    
    def test_moved_occurrences(self):
        occurrences = self.recurring_event.get_occurrences(start=self.start,
                                    end=self.end)
        moved_occurrence = occurrences[1]
        moved_occurrence.move(moved_occurrence.start+datetime.timedelta(hours=2),
                              moved_occurrence.end+datetime.timedelta(hours=2))
        occurrences = self.recurring_event.get_occurrences(start=self.start,
                                    end=self.end)
        self.assertTrue(occurrences[1].moved)
    
    def test_cancelled_occurrences(self):
        occurrences = self.recurring_event.get_occurrences(start=self.start,
                                    end=self.end)
        cancelled_occurrence = occurrences[2]
        cancelled_occurrence.cancel()
        occurrences = self.recurring_event.get_occurrences(start=self.start,
                                    end=self.end)
        self.assertTrue(occurrences[2].cancelled)
        cancelled_occurrence.uncancel()
        occurrences = self.recurring_event.get_occurrences(start=self.start,
                                    end=self.end)
        self.assertFalse(occurrences[2].cancelled)
开发者ID:RockHoward,项目名称:django-schedule,代码行数:54,代码来源:test_models.py


示例19: form_valid

 def form_valid(self, form):
     meeting = form.save()
     end = meeting.start + datetime.timedelta(minutes=119)
     event = Event(
         start=meeting.start,
         end=end,
         title='{0} meeting'.format(meeting.entity.name),
         description=meeting.agenda,
         creator=self.request.user,
     )
     event.save()
     er = EventRelation.objects.create_relation(event, meeting)
     cal = Calendar.objects.get(name='civic')
     cal.events.add(event)
     return super(SchedulerSavingMixin, self).form_valid(form)
开发者ID:registerguard,项目名称:civic_calendar,代码行数:15,代码来源:views.py


示例20: setUp

 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.month = Month(events=Event.objects.all(), date=datetime.datetime(2008, 2, 7, 9, 0))
开发者ID:senyai,项目名称:django-schedule,代码行数:16,代码来源:test_periods.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Rule类代码示例发布时间:2022-05-27
下一篇:
Python models.Calendar类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap