本文整理汇总了Python中schedule.periods.Period类的典型用法代码示例。如果您正苦于以下问题:Python Period类的具体用法?Python Period怎么用?Python Period使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Period类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: site_index
def site_index(request, template_name='index.html'):
# most future office hours to show
MAX_FUTURE_OFFICE_HOURS = 30
# furthest into the future to display office hours
MAX_FUTURE_DAYS = 30
users_available_now = User.objects.filter(profile__is_available=True)
events = Event.objects.all()
now = Period(events=events, start=datetime.now(),
end=datetime.now() + timedelta(minutes=1))
occurences = now.get_occurrences()
users_holding_office_hours_now = map(lambda x: x.event.creator, occurences)
users = set(list(users_available_now) + users_holding_office_hours_now)
future = Period(events=events, start=datetime.now(),
end=datetime.now() + timedelta(days=MAX_FUTURE_DAYS))
upcoming_office_hours = []
already_saw = {}
for i in future.get_occurrences():
if len(upcoming_office_hours) >= MAX_FUTURE_OFFICE_HOURS:
break
if already_saw.get(i.event.creator):
continue
upcoming_office_hours.append(i)
already_saw[i.event.creator] = 1
upcoming_office_hours = upcoming_office_hours[:MAX_FUTURE_OFFICE_HOURS]
return direct_to_template(request, template_name, locals())
开发者ID:apenwarr,项目名称:hnofficehours,代码行数:25,代码来源:views.py
示例2: venue_event_feed
def venue_event_feed(request, pk):
venue = get_object_or_404(Venue, pk=pk)
if request.is_ajax() and request.method == 'GET':
if 'start' in request.GET and 'end' in request.GET:
fro = timezone.make_aware(
datetime.fromtimestamp(float(request.GET['start'])), timezone.get_current_timezone())
to = timezone.make_aware(
datetime.fromtimestamp(float(request.GET['end'])), timezone.get_current_timezone())
period = Period(Event.objects.exclude(appointment=None).filter(
appointment__customer=request.user.userprofile.customer).filter(appointment__venue=venue), fro, to)
data = [{'id': x.event.appointment_set.first().pk,
'title': "{}".format(x.event.appointment_set.first().venue_display_name),
'userId': [x.event.appointment_set.first().venue.pk],
'start': x.start.isoformat(),
'end': x.end.isoformat(),
'clientId': x.event.appointment_set.first().clientId,
'status': x.event.appointment_set.first().status,
'tag': getattr(x.event.appointment_set.first().tag, 'html_name', ""),
'body': x.event.description
}
for x in period.get_occurrences()
if x.event.appointment_set.first()]
return HttpResponse(json.dumps(data), content_type="application/json")
# if all fails
raise Http404
开发者ID:Avatazjoe,项目名称:apr,代码行数:25,代码来源:ajax.py
示例3: task_hour_to_reminder
def task_hour_to_reminder():
"""
tries to send a reminder approximately one hour before an appointment
given a time, say 7AM
we look for appointments that are happening
between 46 minutes and 1 hour from the given time
in our case 7:46AM and 8AM
if time now i6 7:45 we get fro=8:31 and to = 8:45
we use 46 minutes to avoid cases where events happening at
exactly *:15, *:30, *:45, or *:00 dont get multiple reminders
The idea is to catch any appointments happening soon that have NOT been notified
"""
t = timezone.localtime(timezone.now())
fro = t + timedelta(minutes=46)
to = t + timedelta(hours=1)
period = Period(Event.objects.exclude(appointment=None).exclude(
appointment__client=None).exclude(
appointment__status=Appointment.NOTIFIED).exclude(
appointment__status=Appointment.CANCELED).exclude(
appointment__status=Appointment.CONFIRMED), fro, to)
event_objects = period.get_occurrences()
event_ids = list(set([x.event.id for x in event_objects]))
send_period_reminders(event_ids, sendsms=True, turn_off_reminders=True, mailgun_campaign_id="fi0bd")
开发者ID:Avatazjoe,项目名称:apr,代码行数:26,代码来源:tasks.py
示例4: json_period
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,代码行数:29,代码来源:views.py
示例5: view_profile
def view_profile(request, username, template_name="profiles/view_profile.html"):
user = get_object_or_404(User, username=username)
display_full_profile = _can_view_full_profile(request.user)
events = Event.objects.filter(creator=user)
start = datetime.now()
end = start + timedelta(days=30)
period = Period(events=events, start=start, end=end)
office_hours = period.get_occurrences()
return render_to_response(template_name, locals(), context_instance=RequestContext(request))
开发者ID:jdunck,项目名称:hnofficehours,代码行数:9,代码来源:views.py
示例6: testPeriodFromPool
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,代码行数:10,代码来源:test_periods.py
示例7: render
def render(self, context):
try:
true_cal = self.calendar.resolve(context)
if type(true_cal) != Calendar:
true_cal = Calendar.objects.get(slug=true_cal)
period = Period(events=true_cal.events, start=datetime.datetime.now(), end=(datetime.datetime.now()+datetime.timedelta(days=365)))
context[self.varname] = period.get_occurrences()[0:self.length]
except template.VariableDoesNotExist:
context[self.varname] = ''
return ''
开发者ID:powellc,项目名称:django-schedule,代码行数:10,代码来源:scheduletags.py
示例8: json_events
def json_events(request):
ret = ''
if request.user.is_authenticated():
pcal = get_personal_calendar(request.user)
start = request.GET['start']
end = request.GET['end']
allowed_objects = set([])
perms = ['viewer', 'manager', 'creator']
ao = {}
for p in perms:
ao[p] = get_user_calendars(request.user, [p])
allowed_objects = allowed_objects.union(set(ao[p]))
for obj in allowed_objects:
evt = EventRelation.objects.get_events_for_object(
obj.content_object)
if obj.pk == pcal.pk or obj in ao['manager']:
manager = True
else:
manager = False
if obj.pk == pcal.pk or obj in ao['creator']:
creator = True
else:
creator = False
period = Period(events=evt, start=datetime.datetime.fromtimestamp(
float(start)), end=datetime.datetime.fromtimestamp(float(end)))
occurrences = []
for o in period.occurrences:
if period.classify_occurrence(o):
o.calendar_id = obj.pk
o.calendar_name = obj.calendar.name
if o.event.calendar_id == obj.calendar.pk:
o.manager = manager
o.creator = creator
else:
o.manager = False
o.creator = False
if o.id:
o.details = EventDetails.objects.get_eventdetails_for_object(
o)
else:
o.details = EventDetails.objects.get_eventdetails_for_object(
o.event)
if o.details.privacy == 2 and request.user != obj.owner: # Private event
continue
else:
occurrences.append(o)
if len(occurrences):
ret += '"' + obj.calendar.slug + '": ' + \
jsondump_occurences(occurrences, request.user) + ','
ret = ret[:-1]
ret = '{' + ret + '}'
# json_data = simplejson.dumps(ret)
return HttpResponse(ret)
开发者ID:KuwaitNET,项目名称:zorna,代码行数:54,代码来源:views.py
示例9: get_queryset
def get_queryset(self):
pacific = pytz.timezone('US/Pacific')
my_events = Event.objects.all()
my_today = pacific.localize(
datetime.datetime.now().replace(hour=0, minute=0) \
)
upcoming = Period(
my_events, my_today, my_today+datetime.timedelta(days=30)
)
event_id_list = [occurrence.event_id for occurrence in upcoming.get_occurrences()]
return EventRelation.objects.filter(event_id__in=event_id_list)
开发者ID:registerguard,项目名称:civic_calendar,代码行数:11,代码来源:views.py
示例10: TestPeriod
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,代码行数:54,代码来源:test_periods.py
示例11: TestPeriod
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,代码行数:53,代码来源:test_periods.py
示例12: test_occurrences_sub_period_with_TZ
def test_occurrences_sub_period_with_TZ(self):
start = self.MVD.localize(datetime.datetime(2017, 1, 13))
end = self.MVD.localize(datetime.datetime(2017, 1, 23))
period = Period(Event.objects.all(), start, end, tzinfo=self.MVD)
sub_start = self.MVD.localize(datetime.datetime(2017, 1, 13))
sub_end = self.MVD.localize(datetime.datetime(2017, 1, 15))
sub_period = period.get_time_slot(sub_start, sub_end)
self.assertEqual(
["%s to %s" % (o.start, o.end) for o in sub_period.occurrences],
['2017-01-14 22:00:00-03:00 to 2017-01-14 23:00:00-03:00'])
开发者ID:Alcolo47,项目名称:django-scheduler,代码行数:12,代码来源:test_periods.py
示例13: TestPeriod
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,代码行数:51,代码来源:test_periods.py
示例14: test_moved_occurrences
def test_moved_occurrences(self):
occurrences = self.recurring_event.get_occurrences(start=self.start,
end=self.end)
moved_occurrence = occurrences[1]
span_pre = (moved_occurrence.start, moved_occurrence.end)
span_post = [x + datetime.timedelta(hours=2) for x in span_pre]
# check has_occurrence on both periods
period_pre = Period([self.recurring_event], span_pre[0], span_pre[1])
period_post = Period([self.recurring_event], span_post[0], span_post[1])
self.assertTrue(period_pre.has_occurrences())
self.assertFalse(period_post.has_occurrences())
# move occurrence
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)
# check has_occurrence on both periods (the result should be reversed)
period_pre = Period([self.recurring_event], span_pre[0], span_pre[1])
period_post = Period([self.recurring_event], span_post[0], span_post[1])
self.assertFalse(period_pre.has_occurrences())
self.assertTrue(period_post.has_occurrences())
# trigger bug discovered by gautamadude - modifying recurring event
# breaks link between a persistent occurrence and the occurrence chain
# leaving an "orphaned" occurrence
occurrences = self.recurring_event.get_occurrences(start=self.start,
end=self.end)
self.assertTrue(len(occurrences) == 3)
self.recurring_event.start = datetime.datetime(2008, 1, 5, 8, 15)
self.recurring_event.save()
occurrences_later = self.recurring_event.get_occurrences(start=self.start,
end=self.end)
self.assertEquals(len(occurrences_later), len(occurrences))
开发者ID:ATOM49,项目名称:django-voip,代码行数:33,代码来源:test_models.py
示例15: 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.objects.create(frequency='WEEKLY')
self.cal = Calendar.objects.create(name='MyCal', slug='MyCalSlug')
Event.objects.create(
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,
)
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:Alcolo47,项目名称:django-scheduler,代码行数:25,代码来源:test_templatetags.py
示例16: 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
示例17: task_morning_reminders
def task_morning_reminders():
"""
Sends a reminder to all the appointments happening today
currently sends at 7am
"""
t = timezone.now().date()
fro = datetime(year=t.year, month=t.month, day=t.day, hour=7,
tzinfo=timezone.get_current_timezone())
to = fro + timedelta(1)
period = Period(Event.objects.exclude(appointment=None).exclude(
appointment__client=None).exclude(
appointment__status=Appointment.CANCELED).exclude(
appointment__status=Appointment.CONFIRMED), fro, to)
event_objects = period.get_occurrences()
event_ids = list(set([x.event.id for x in event_objects]))
send_period_reminders(event_ids, sendsms=True, mailgun_campaign_id="ffz23")
开发者ID:Avatazjoe,项目名称:apr,代码行数:17,代码来源:tasks.py
示例18: month_cal
def month_cal(context, year, month):
request = context['request']
ret = []
if request.user.is_authenticated():
evt = EventRelation.objects.get_events_for_object(request.user)
period = Period(events=evt, start=datetime.datetime(year, month, 1),
end=datetime.datetime(year, month, 30))
occurrences = []
for o in period.occurrences:
if period.classify_occurrence(o):
occurrences.append(o)
first_day_of_month = datetime.date(year, month, 1)
last_day_of_month = get_last_day_of_month(year, month)
first_day_of_calendar = first_day_of_month - \
datetime.timedelta(first_day_of_month.weekday())
last_day_of_calendar = last_day_of_month + \
datetime.timedelta(7 - last_day_of_month.weekday())
month_cal = []
week = []
week_headers = []
i = 0
day = first_day_of_calendar
while day <= last_day_of_calendar:
if i < 7:
week_headers.append(day)
cal_day = {}
cal_day['day'] = day
cal_day['event'] = False
for occ in ret:
if day >= occ.start.date() and day <= occ.end.date():
cal_day['event'] = True
if day.month == month:
cal_day['in_month'] = True
else:
cal_day['in_month'] = False
week.append(cal_day)
if day.weekday() == 6:
month_cal.append(week)
week = []
i += 1
day += datetime.timedelta(1)
return {'calendar': month_cal, 'headers': week_headers}
开发者ID:KuwaitNET,项目名称:zorna,代码行数:46,代码来源:calendars_tags.py
示例19: site_index
def site_index(request, template_name='index.html'):
# most future office hours to show
MAX_FUTURE_OFFICE_HOURS = 30
# furthest into the future to display office hours
MAX_FUTURE_DAYS = 30
users_available_now = User.objects.filter(profile__is_available=True)
events = Event.objects.all()
now = Period(events=events, start=datetime.now(),
end=datetime.now() + timedelta(minutes=1))
occurences = now.get_occurrences()
users_holding_office_hours_now = map(lambda x: x.event.creator, occurences)
users = set(list(users_available_now) + users_holding_office_hours_now)
future = Period(events=events, start=datetime.now(),
end=datetime.now() + timedelta(days=MAX_FUTURE_DAYS))
upcoming_office_hours = future.get_occurrences()
upcoming_office_hours = upcoming_office_hours[:MAX_FUTURE_OFFICE_HOURS]
return render_to_response(template_name, locals(),
context_instance=RequestContext(request))
开发者ID:agentultra,项目名称:hnofficehours,代码行数:18,代码来源:views.py
示例20: task_immediate_reminder
def task_immediate_reminder():
"""
tries to send a reminder for appointments happening in the next 45 minutes that have NOT been notified
probably these were created very soon before the appointment start and thus were not caught by any other task
The idea is to catch any appointments happening very soon that have NOT been notified
"""
t = timezone.localtime(timezone.now())
fro = t
to = t + timedelta(minutes=45)
period = Period(Event.objects.exclude(appointment=None).exclude(
appointment__client=None).exclude(
appointment__status=Appointment.NOTIFIED).exclude(
appointment__status=Appointment.CANCELED).exclude(
appointment__status=Appointment.CONFIRMED), fro, to)
event_objects = period.get_occurrences()
event_ids = list(set([x.event.id for x in event_objects]))
send_period_reminders(event_ids, sendsms=True, turn_off_reminders=True, mailgun_campaign_id="fi0cz")
开发者ID:Avatazjoe,项目名称:apr,代码行数:19,代码来源:tasks.py
注:本文中的schedule.periods.Period类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论