def team_skills(self): ''' Returns team details in JSON form ''' uuid = self.get_argument('uuid', '') if uuid == '': user = self.get_current_user() if user: team = user.team else: team = Team.by_uuid(uuid) if team is not None: categories = Category.all() catlist = {} for cat in categories: catbox = Box.by_category(cat.id) if (len(catbox) > 0): catlist[int(cat.id)] = 0 for flag in team.flags: box = flag.box if box and box.category_id is not None: catlist[int(box.category_id)] += 1 skillvalues = [] for val in catlist: skillvalues.append(catlist[val]) self.write(str(skillvalues)) else: self.write({'error': 'Team does not exist'}) self.finish()
def export_game_objects(self, root): """ Exports the game objects to an XML doc. For the record, I hate XML with a passion. """ levels_elem = ET.SubElement(root, "gamelevels") levels_elem.set("count", "%s" % str(GameLevel.count())) for level in GameLevel.all()[1:]: level.to_xml(levels_elem) category_elem = ET.SubElement(root, "categories") category_elem.set("count", "%s" % str(Category.count())) for category in Category.all(): category.to_xml(category_elem) corps_elem = ET.SubElement(root, "corporations") corps_elem.set("count", "%s" % str(Corporation.count())) for corp in Corporation.all(): corp.to_xml(corps_elem)