def load_from_db(self):
   sessions = Session.all().filter('event_key =', str(self.id))
   # I have to manually sort them, sorry...
   try:
     self.entity_collection = sorted(sessions, key=lambda x: CSlot(x.slot_key).get().start)
   except:
     self.entity_collection = sessions
Esempio n. 2
0
  def load_from_db(self):
    self.entity_collection = {} 
    sessions = Session.all().filter('event =', CEvent(self.event_id).get())    
            
    # list of all rooms per day
    room_list = {}
    # list of all sessions, first per day, then organized by slot
    by_slot = {}
    # list of all sessions, first per day, then organized by room
    by_room = {}
    # list of all sessions, first by day, then by slot then by room
    by_slot_room = {}
    
    for session in sessions:
      # empty room? make a " " out of it.
      if not session.room:
        session.room = " "
      # get the day for the session
      day = session.slot.day.date
      # is day known?
      if not day in room_list:
        room_list[day] = []
        by_slot[day] = {}
        by_room[day] = {}
        by_slot_room[day] = {}
      # is the slot already known?
      session.slot_key = self.key_for_slot(session.slot)
      if session.slot_key not in by_slot[day]:
        by_slot[day][session.slot_key] = []
        by_slot_room[day][session.slot_key] = {}
      # is the room already known?
      if session.room and (session.room not in room_list[day]):
        room_list[day].append(session.room)
        by_room[day][session.room] = []
      # append the session to the three lists
      by_slot[day][session.slot_key].append(session)
      by_room[day][session.room].append(session)
      # we want only one session at one time in one room
      by_slot_room[day][session.slot_key][session.room] = session
      
    # list of all slots - even empty ones. we add an element count
    # for the number of sessions
    slot_list = {}
    date_list = []
    for s in CSlotList(self.event_id).get():
      s.date = s.day.date
      s.slot_key = self.key_for_slot(s)
      if by_slot.has_key(s.date):
        if s.slot_key in by_slot[s.date]:
          s.sessioncount = len(by_slot[s.date][s.slot_key])
        else:
          s.sessioncount = 0
      else :
          s.sessioncount = 0
      if s.date not in date_list:
        date_list.append(s.date)
        slot_list[s.date] = []
      slot_list[s.date].append(s)

    # store the data!
    self.entity_collection['room_list'] = room_list
    self.entity_collection['slot_list'] = slot_list
    self.entity_collection['date_list'] = date_list
    self.entity_collection['by_slot'] = by_slot
    self.entity_collection['by_room'] = by_room
    self.entity_collection['by_slot_room'] = by_slot_room
Esempio n. 3
0
 def load_from_db(self):
   sessions = Session.all().filter('event =', CEvent(self.id).get())
   # I have to manually sort them, sorry...
   self.entity_collection = sorted(sessions, key=lambda x: x.slot.start)
  def load_from_db(self):
    self.entity_collection = {} 
    sessions = Session.all().filter('event_key =', str(self.event_id))    
            
    # list of all rooms per day
    room_list = {}
    # list of all sessions, first per day, then organized by slot
    by_slot = {}
    # list of all sessions, first per day, then organized by room
    by_room = {}
    # list of all sessions, first by day, then by slot then by room
    by_slot_room = {}
    
    for session in sessions:
      # empty room? make a " " out of it.
      if not session.room:
        session.room = " "
      # get the slot from the slot_key
      try:
        slot = CSlot(session.slot_key).get()
        if not slot:
          continue
      except:
        # we won't be able to display this session anyway
        continue
      # get the day for the session
      day = slot.day.date
      # is day known?
      if not day in room_list:
        room_list[day] = []
        by_slot[day] = {}
        by_room[day] = {}
        by_slot_room[day] = {}
      # is the slot already known?
      session.slot_txtkey = self.txtkey_for_slot(session.slot_key)
      if session.slot_txtkey not in by_slot[day]:
        by_slot[day][session.slot_txtkey] = []
        by_slot_room[day][session.slot_txtkey] = {}
      # is the room already known?
      if session.room and (session.room not in room_list[day]):
        room_list[day].append(session.room)
        by_room[day][session.room] = []
      # append the session to the three lists
      by_slot[day][session.slot_txtkey].append(session)
      by_room[day][session.room].append(session)
      # we want only one session at one time in one room
      by_slot_room[day][session.slot_txtkey][session.room] = session
      
    # list of all slots - even empty ones. we add an element count
    # for the number of sessions
    slot_list = {}
    date_list = []
    for s in CSlotList(self.event_id).get():
      s.date = s.day.date
      s.slot_txtkey = self.txtkey_for_slot(str(s.key()))
      if by_slot.has_key(s.date):
        if s.slot_txtkey in by_slot[s.date]:
          s.sessioncount = len(by_slot[s.date][s.slot_txtkey])
        else:
          s.sessioncount = 0
      else:
          s.sessioncount = 0
      date_entry = {"date":s.date, "description":s.day.description}
      if date_entry not in date_list:
        date_list.append(date_entry)
        slot_list[s.date] = []
      slot_list[s.date].append(s)

    # store the data!
    self.entity_collection['room_list'] = room_list
    self.entity_collection['slot_list'] = slot_list
    self.entity_collection['date_list'] = date_list
    self.entity_collection['by_slot'] = by_slot
    self.entity_collection['by_room'] = by_room
    self.entity_collection['by_slot_room'] = by_slot_room