本文整理匯總了Python中Event.planning方法的典型用法代碼示例。如果您正苦於以下問題:Python Event.planning方法的具體用法?Python Event.planning怎麽用?Python Event.planning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Event
的用法示例。
在下文中一共展示了Event.planning方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: fill_insert
# 需要導入模塊: import Event [as 別名]
# 或者: from Event import planning [as 別名]
def fill_insert(classe, i):
classe.name = "C"+str(i)
classe.planning = Planning()
# XXX fill planning with normal events ?
#classe.planning.cb_fill(number)
# XXX fill planning with course events
cursus = db.session.query(Cursus).get(i+1)
if cursus:
periods = cursus.periods
import Event
Event.fill_date = cursus.start
else:
periods = []
for period in periods:
for course in period.courses:
from Event import Event
# XXX move fill event in class
event = Event()
event.planning = classe.planning
event.course = course
course.c_elearning_rest = course.c_elearning
course.c_classroom_rest = course.c_classroom
course.c_practice_rest = course.c_practice
course.e_oral_rest = course.e_oral
course.e_practice_rest = course.e_practice
hours = course.c_elearning
hours += course.c_classroom
hours += course.c_practice
hours += course.e_oral
hours += course.e_practice
event.cb_fill(hours / 2)
if len(period.classes) == 0:
for course in period.courses:
event = Event()
event.planning = period.planning
event.course = course
event.cb_fill(event.course.e_exam / 2 + 1)
import Event
Event.fill_date = period.end
classe.periods = periods
user = User()
user.manager_class = [classe]
user.cb_fill(randint(1, number),
classe.campus.name + '_' + classe.name +
'_manager_user' + str(i))
user = User()
user.student_class = classe
user.cb_fill(randint(10, 30), classe.campus.name+'_'+classe.name+'_student_user'+str(i))
db.session.add(classe)
示例2: cb_fill
# 需要導入模塊: import Event [as 別名]
# 或者: from Event import planning [as 別名]
def cb_fill(self, number):
"""callback for fill the db"""
def fill_insert(event, i, number):
import Event
if Event.fill_time.hour >= 18 or i == 0:
#print "time go out of day range : " + str(Event.fill_time.hour) + " >= 19"
#print "fill_date actual : " + str(Event.fill_date)
if event.planning.type_univ:
Event.fill_date += timedelta(
days = randint(7, 28))
elif event.planning.type_period and not event.course:
Event.fill_date += timedelta(
days = randint(7, 28))
elif event.planning.type_campus:
Event.fill_date += timedelta(
days = randint(7, 14))
elif event.planning.type_class and not event.course:
Event.fill_date += timedelta(
days = randint(7, 28))
elif event.planning.type_user:
Event.fill_date += timedelta(
days = randint(3, 6))
wd = Event.fill_date.weekday()
if event.course and wd > 3:
delta = timedelta(days = 7 - wd)
elif wd == 5:
delta = timedelta(days = 2)
else:
delta = timedelta(days = 1)
Event.fill_date += delta
Event.fill_time = time(7, 00)
#print "fill_time before : " + str(Event.fill_time)
#print "fill_date before : " + str(Event.fill_date)
event.name = "Event"+str(i)
event.description = "description"
event.modality = 'none'
if event.course:
event_rest = number - i
event.required_event = True
event.time_length = 2
if event.planning.type_period:
event.modality = 'evaluation_exam'
elif event.course.e_practice > (event_rest * 2):
event.modality = 'evaluation_practice'
if event.course.e_oral_rest == 1:
event.time_length = 1
event.course.e_oral_rest -= event.time_length
elif ((event.course.e_practice +
event.course.e_oral) > (event_rest * 2)):
event.modality = 'evaluation_oral'
if event.course.e_oral_rest == 1:
event.time_length = 1
event.course.e_oral_rest -= event.time_length
else:
modalities = []
if (event.course.c_elearning_rest > 0):
modalities.append('lesson_elearning')
if (event.course.c_classroom_rest > 0):
modalities.append('lesson_classroom')
if (event.course.c_practice_rest > 0):
modalities.append('lesson_practice')
l = len(modalities)
if l:
event.modality = modalities[
randint(0, l - 1)]
else:
event.modality = 'lesson_practice'
if event.modality == 'lesson_elearning':
if event.course.c_elearning_rest == 1:
event.time_length = 1
event.course.c_elearning_rest -= event.time_length
elif event.modality == 'lesson_classroom':
if event.course.c_classroom_rest == 1:
event.time_length = 1
event.course.c_classroom_rest -= event.time_length
elif event.modality == 'lesson_practice':
if event.course.c_practice_rest == 1:
event.time_length = 1
event.course.c_practice_rest -= event.time_length
#print "fill beetween 9-13 and 14-20"
h = Event.fill_time.hour
if h < 9:
Event.fill_time = time(9, 00)
elif (h + event.time_length) > 13 and h < 14:
Event.fill_time = time(14, 00)
else:
#print "fill an event in the rest of the space"
h = Event.fill_time.hour
#print "from " + str(h) + " to 19"
Event.fill_time = time(randint(h, 19), 00)
h = Event.fill_time.hour
#print "find one at " + str(h)
event.time_length = (randint(1, 20 - h) % 4) + 1
if not i % 2:
event.required_event = True
else:
event.required_event = False
#.........這裏部分代碼省略.........