本文整理汇总了Python中schedule.models.Calendar类的典型用法代码示例。如果您正苦于以下问题:Python Calendar类的具体用法?Python Calendar怎么用?Python Calendar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Calendar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: create
def create(request, form_class=TribeForm, template_name="tribes/create.html"):
if request.user.is_authenticated() and request.method == "POST":
if request.POST["action"] == "create":
tribe_form = form_class(request.POST)
if tribe_form.is_valid():
tribe = tribe_form.save(commit=False)
tribe.creator = request.user
tribe.save()
tribe.members.add(request.user)
tribe.save()
# @@@ this is just temporary to give tribes a single calendar -- will revisit during whole
# tribe/project merge effort
calendar = Calendar(name = "%s Calendar" % tribe.name)
calendar.save()
CalendarRelation.objects.create_relation(calendar, tribe, distinction="default", inheritable=True)
if notification:
# @@@ might be worth having a shortcut for sending to all users
notification.send(User.objects.all(), "tribes_new_tribe", {"tribe": tribe}, queue=True)
if friends: # @@@ might be worth having a shortcut for sending to all friends
notification.send((x['friend'] for x in Friendship.objects.friends_for_user(tribe.creator)), "tribes_friend_tribe", {"tribe": tribe})
#return render_to_response("base.html", {
#}, context_instance=RequestContext(request))
return HttpResponseRedirect(tribe.get_absolute_url())
else:
tribe_form = form_class()
else:
tribe_form = form_class()
return render_to_response(template_name, {
"tribe_form": tribe_form,
}, context_instance=RequestContext(request))
开发者ID:bikeshkumar,项目名称:pinax,代码行数:31,代码来源:views.py
示例2: test_recurring_event_with_moved_get_occurrences_after
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,代码行数:27,代码来源:test_event.py
示例3: setUp
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,代码行数:31,代码来源:test_occurrence.py
示例4: test_recurring_event_get_occurrence_in_timezone
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,代码行数:26,代码来源:test_event.py
示例5: 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
示例6: 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
示例7: test_get_calendar_for_object
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,代码行数:8,代码来源:test_calendar.py
示例8: save
def save(self, force_insert=False, force_update=False):
super(CircleEvent, self).save(force_insert, force_update)
try:
cal = Calendar.objects.get(pk=1)
except Calendar.DoesNotExist:
cal = Calendar(name="Community Calendar")
cal.save()
cal.events.add(self)
开发者ID:TheProjecter,项目名称:pinax-cohousing,代码行数:8,代码来源:models.py
示例9: 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
示例10: test_occurrences_after_with_events_before_returns_empty
def test_occurrences_after_with_events_before_returns_empty(self):
calendar = Calendar()
calendar.save()
start_after = timezone.now() + datetime.timedelta(days=-1)
end_after = start_after + datetime.timedelta(hours=1)
event = self.__create_event(start_after, end_after)
calendar.events.add(event)
occurrences = list(calendar.occurrences_after(timezone.now()))
self.assertEqual(occurrences, [])
开发者ID:JoshLabs,项目名称:django-scheduler,代码行数:9,代码来源:test_calendar.py
示例11: test_get_calendar_for_object_with_more_than_one_calendar
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,代码行数:11,代码来源:test_calendar.py
示例12: test_occurrences_after_with_events_after_returns_events
def test_occurrences_after_with_events_after_returns_events(self):
calendar = Calendar()
calendar.save()
start_after = timezone.now() + datetime.timedelta(days=1)
end_after = start_after + datetime.timedelta(hours=1)
event = self.__create_event(start_after, end_after)
calendar.events.add(event)
occurrences = list(calendar.occurrences_after(timezone.now()))
self.assertEquals(len(occurrences), 1)
self.assertEquals(occurrences[0].start, start_after)
self.assertEquals(occurrences[0].end, end_after)
开发者ID:AltSchool,项目名称:django-scheduler,代码行数:11,代码来源:test_calendar.py
示例13: test_event_get_ocurrence
def test_event_get_ocurrence(self):
cal = Calendar(name='MyCal')
cal.save()
start = timezone.now() + datetime.timedelta(days=1)
event = self.__create_event(
'Non recurring event test get_occurrence',
start,
start + datetime.timedelta(hours=1),
cal)
event.save()
occurrence = event.get_occurrence(start)
self.assertEqual(occurrence.start, start)
开发者ID:nwaxiomatic,项目名称:django-scheduler,代码行数:13,代码来源:test_event.py
示例14: optionnal_calendar_new
def optionnal_calendar_new(sender, **kwargs):
event = kwargs.pop('instance')
if not isinstance(event, Event):
return True
if not event.calendar:
try:
calendar = Calendar._default_manager.get(name='defaulter')
except Calendar.DoesNotExist:
calendar = Calendar(name='defaulter', slug='defaulter')
calendar.save()
event.calendar = calendar
return True
开发者ID:gitter-badger,项目名称:brownstonetutors,代码行数:14,代码来源:models.py
示例15: 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, 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()
开发者ID:RossLote,项目名称:fuzzy-ninja,代码行数:15,代码来源:test_periods.py
示例16: test_occurences_after_with_no_params
def test_occurences_after_with_no_params(self):
cal = Calendar(name='MyCal')
cal.save()
start = timezone.now() + datetime.timedelta(days=1)
event = self.__create_event(
'Non recurring event test get_occurrence',
start,
start + datetime.timedelta(hours=1),
cal)
event.save()
occurrences = list(event.occurrences_after())
self.assertEqual(len(occurrences), 1)
self.assertEqual(occurrences[0].start, start)
self.assertEqual(occurrences[0].end, start + datetime.timedelta(hours=1))
开发者ID:nwaxiomatic,项目名称:django-scheduler,代码行数:15,代码来源:test_event.py
示例17: 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, 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()
开发者ID:Gustavosdo,项目名称:django-scheduler,代码行数:15,代码来源:test_periods.py
示例18: test_get_absolute
def test_get_absolute(self):
cal = Calendar(name='MyCal')
cal.save()
rule = Rule(frequency="DAILY")
rule.save()
start = timezone.now() + datetime.timedelta(days=1)
event = self.__create_recurring_event(
'Non recurring event test get_occurrence',
start,
start + datetime.timedelta(hours=1),
start + datetime.timedelta(days=10),
rule,
cal)
event.save()
url = event.get_absolute_url()
self.assertEqual(reverse('event', kwargs={'event_id': event.id}), url)
开发者ID:nwaxiomatic,项目名称:django-scheduler,代码行数:16,代码来源:test_event.py
示例19: test_recurring_event_get_occurrences_after
def test_recurring_event_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()
开发者ID:nwaxiomatic,项目名称:django-scheduler,代码行数:16,代码来源:test_event.py
示例20: setUp
def setUp(self):
super(TestSchedulesViews, self).setUp()
self.cal = Calendar(
name=random_string(),
slug=random_string(),
)
self.cal.save()
开发者ID:40a,项目名称:openduty,代码行数:7,代码来源:test_schedules.py
注:本文中的schedule.models.Calendar类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论