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


Python models.Event类代码示例

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


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


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