本文整理汇总了Python中models.event.Event.all方法的典型用法代码示例。如果您正苦于以下问题:Python Event.all方法的具体用法?Python Event.all怎么用?Python Event.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.event.Event
的用法示例。
在下文中一共展示了Event.all方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import all [as 别名]
def get(self):
events = Event.all()
path = os.path.join(os.path.dirname(__file__), 'templates/administration/event-list.html')
template_values = {
'events': events
}
self.response.out.write(template.render(path, template_values))
示例2: lis
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import all [as 别名]
def lis(self, user):
all_events = Event.all()
result = all_events.fetch(20)
# self.response.write(result.list_index())
context = []
for r in all_events:
context.append({'name':r.name, 'venue': r.venue,'id': r.key().id()})
self.render_api_response(context)
示例3: get
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import all [as 别名]
def get(self, arg):
event = Event.get_by_id(int(arg))
notifications = []
events = Event.all()
path = os.path.join(os.path.dirname(__file__), '../templates/administration/event-list.html')
template_values = {
'notifications': notifications,
'events': events,
'logoutlink': users.create_logout_url("/")
}
if not event:
notifications.append('Het event bestaat niet.')
self.response.out.write(template.render(path, template_values))
return
self.createGuardianPasses(event)
notifications.append('De sleutels zijn aangemaakt')
self.response.out.write(template.render(path, template_values))
return
示例4: api_list
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import all [as 别名]
def api_list(self, user):
events = Event.all()
context = []
for event in events:
context.append({'name':event.name, 'id': event.key().id(), 'venue': event.venue })
self.render_api_response(context)
示例5: myevents
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import all [as 别名]
def myevents(self):
my_events = Event.all().filter('profile =', self.get_current_profile())
context = {'events': my_events}
self.render_template('event_list.html', context)
示例6: list
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import all [as 别名]
def list(self):
all_events = Event.all()
context = {'events': all_events}
self.render_template('event_list.html', context)
示例7: get
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import all [as 别名]
def get(self):
print ""
print "<html><body style='font-family: Helvetica; font-size: 0.9em;'>"
print time.strftime("%H:%M:%S", time.localtime()) + ": Start<br>"
logging.info("Fetching all info")
# if arg != None:
# event = Event.get_by_id(int(arg))
# else:
event = Event.all().filter("event_name", "paasrapport").get()
days = Day.all().filter("event", event).fetch(999)
days.sort(key=lambda day: day.date)
max_requests = 0
max_timepref = 0
max_rank = 0
allguardians = Guardian.all().fetch(9999)
guardians = []
requests = []
for guardian in allguardians:
requests = Request.all().filter("guardian", guardian).filter("event", event).fetch(999)
if len(requests) > 0:
max_requests = max([max_requests, len(requests)])
guardian.requests = requests
guardian.day_prefs = []
for day in days:
guardian.day_prefs.append(DayPreference.all().filter("guardian", guardian).filter("day", day).get())
guardian.day_prefs.sort(key=lambda day: day.rank)
max_rank = max([max_rank, max([day.rank for day in guardian.day_prefs])])
guardian.time_pref = TimePreference.all().filter("guardian", guardian).filter("event", event).get()
max_timepref = max([max_timepref, guardian.time_pref.preference])
if len(requests) > 5:
guardianCopy = copy.deepcopy(guardian)
guardian.requests = guardian.requests[: int(len(requests) / 2)]
guardianCopy.requests = guardianCopy.requests[int(len(requests) / 2) :]
guardianCopy.day_prefs[0].rank = 999
guardians.append(guardianCopy)
guardians.append(guardian)
timepref_options = range(max_timepref + 1)
timepref_options = [1, 2, 0]
planning = Planning(event, days)
logging.info("All guardians/requests collected")
for length in range(max_requests, 0, -1):
for timepref in timepref_options:
for rank in range(0, max_rank + 1):
for day_num, day in enumerate(days):
for guardian in filter(
lambda guardian: (len(guardian.requests) == length)
and (guardian.time_pref.preference == timepref)
and (
filter(lambda day_pref: day_pref.day.date == day.date, guardian.day_prefs)[0].rank
== rank
),
guardians,
):
# try to place these requests
placed = planning.place(guardian, day_num)
# on succes, remove guardian from guardian
# on fail, the guardian will return on a less preferable round
if placed:
guardians.remove(guardian)
logging.info("Placed")
for dayIndex, day in enumerate(planning.days):
start = time.clock()
lowestValue = 0
for i, slot in enumerate(day[0]):
lowestValue += len(planning.conflictedTeachers(day, i))
logging.info("conflicts: " + str(lowestValue))
# <--- Build a list of all regions
logging.info("Building regions")
regions = []
for tableIndex, table in enumerate(day):
region = [tableIndex, 0, -1]
previousGuardian = ""
for slotIndex, slot in enumerate(table):
guardianId = planning.getGuardianIdFromRequest(slot)
block = table[region[1] : region[2] + 1]
if guardianId == "":
if len(block) == 0:
region = [tableIndex, slotIndex, slotIndex]
elif block.count(None) == 0:
if previousGuardian != "":
#.........这里部分代码省略.........