def GET(self, app, attachment_check=None): markup.init_theme(app) markup.set_navlink() try: schema = models.schema(scope=app) attribs = schema.attributes except (models.CacheEmptyError, models.ItemBackendUnimplemented) as E: raise web.NotFound(template.errors.generic(E)) attribute = None if attachment_check: attached_items = [] for attr in attribs: if str(attr.id) == attachment_check: attribute = attr break if not attribute: raise web.NotFound( template.errors.generic(attachment_check + ": No such attribute")) for item in schema.processed_items.values(): if attr.id in map(operator.itemgetter("id"), item.get("attrs", [])): attached_items.append(item) return template.attribute_attachments(app, attached_items, attribute) else: return template.schema_attributes(attribs)
def GET(self, app): markup.init_theme(app) markup.set_navlink() try: schema = models.schema(scope=app) particles = schema.particle_systems return template.schema_particles(app, particles) except (models.CacheEmptyError, models.ItemBackendUnimplemented) as E: raise web.NotFound(template.errors.generic(E))
def GET(self, app): query = web.input() schema = models.schema(scope=app) markup.init_theme(app) markup.set_navlink() try: sitems = schema.processed_items items = sitems.values() except (models.CacheEmptyError, models.ItemBackendUnimplemented) as E: raise web.NotFound(template.errors.generic(E)) dropdowns = views.build_dropdowns(items) filter_classes = markup.sorted_class_list( dropdowns["equipable_classes"], app) filter_qualities = markup.get_quality_strings(dropdowns["qualities"], schema) filter_capabilities = markup.get_capability_strings( dropdowns["capabilities"]) filters = views.filtering(items) try: items = filters.byClass( markup.get_class_for_id(query["cls"], app)[0]) except KeyError: pass try: items = filters.byQuality(query["quality"]) except KeyError: pass try: items = filters.byCapability(query["capability"]) except KeyError: pass sorter = views.sorting(items) try: items = sorter.sort(query.get("sort", "SchemaID")) except KeyError: pass item_page = views.item_page(items) stats = item_page.summary price_stats = item_page.build_price_summary(models.assets(scope=app)) return template.schema_items(app, items, sorter.get_sort_methods(), filter_classes, filter_qualities, filter_capabilities, stats, price_stats)
def GET(self, app, user, cid=None): app = models.app_aliases.get(app, app) self._cid = cid markup.init_theme(app) try: userp = models.user(user).load() pack = models.inventory(userp, scope=app).load() items = pack["items"].values() equippeditems = {} classmap = set() slotlist = [] self._app = app markup.set_navlink( markup.generate_root_url("loadout/{0}".format(userp["id64"]), app)) # initial normal items try: sitems = models.schema(scope=app).processed_items.values() normalitems = views.filtering(sitems).byQuality("normal") equippeditems, slotlist, classmap = self.build_loadout( normalitems, equippeditems, slotlist, classmap) except models.CacheEmptyError: pass # Real equipped items equippeditems, slotlist, classmap = self.build_loadout( items, equippeditems, slotlist, classmap) return template.loadout(app, userp, equippeditems, sorted(classmap), self._slots_sorted + sorted(slotlist), cid) except steam.items.InventoryError as E: raise web.NotFound( template.errors.generic("Backpack error: {0}".format(E))) except steam.user.ProfileError as E: raise web.NotFound( template.errors.generic("Profile error: {0}".format(E))) except steam.api.HTTPError as E: raise web.NotFound( template.errors.generic( "Couldn't connect to Steam (HTTP {0})".format(E))) except models.ItemBackendUnimplemented: raise web.NotFound( template.errors.generic( "No backend found to handle loadouts for these items"))
def GET(self, app, iid): user = None markup.init_theme(app) try: sitems = models.schema(scope=app).processed_items item = sitems[iid] if web.input().get("contents"): contents = item.get("contents") if contents: item = contents except steam.api.HTTPError as E: raise web.NotFound( template.errors.generic( "Couldn't connect to Steam (HTTP {0})".format(E))) except steam.items.SchemaError as E: raise web.NotFound( template.errors.generic("Couldn't open schema: {0}".format(E))) except KeyError: raise web.NotFound(template.item_error_notfound(iid)) except models.CacheEmptyError as E: raise web.NotFound(template.errors.generic(E)) except models.ItemBackendUnimplemented: raise web.NotFound( template.errors.generic( "No backend found to handle the given item, this could mean that the item has no available associated schema (yet)" )) caps = markup.get_capability_strings(item.get("caps", [])) try: assets = models.assets(scope=app).price_map price = markup.generate_item_price_string(item, assets) except models.CacheEmptyError: price = None # Strip off quality prefix for possessive name itemname = item["mainname"] if itemname.startswith("The "): item["ownedname"] = itemname[4:] else: item["ownedname"] = itemname return template.item(app, user, item, price=price, caps=caps)
def GET(self, app = None): usestale = True # Until dedicated main homepage is done if not app: app = random.choice(valid_modes) app = models.app_aliases.get(app, app) query = web.input() user = query.get("user") # TODO: Won't be much use in the big restructuring, for now try to extract app from path appfrom = query.get("from", '')[len(markup.virtual_root):].strip('/').split('/')[0] if appfrom not in valid_modes: appfrom = valid_modes[0] profile = profile_search(user) if profile: raise web.seeother(markup.generate_root_url("user/" + str(profile[0]["id64"]), appfrom)) ckey = "scrender" showcase = models.cache.get(ckey) showcase_cell = None try: if not showcase: sitems = models.schema(scope = app).processed_items.values() if len(sitems) > 0: showcase = random.choice(sitems) showcase["app"] = app # May want to add an option for showcase expiration to config later models.cache.set(ckey, showcase, time=60) app = showcase.get("app", app) showcase_cell = markup.generate_item_cell(app, showcase, user=showcase.get("user")) except Exception as E: pass markup.init_theme(app) web.ctx.notopsearch = True # Last packs packs = models.recent_inventories(scope = app) return template.index(app, (packs or []), showcase_cell)
def GET(self, app, user, iid): markup.init_theme(app) try: user, items = models.load_inventory(user, scope=app) except steam.api.HTTPError as E: raise web.NotFound( template.errors.generic( "Couldn't connect to Steam (HTTP {0})".format(E))) except steam.user.ProfileError as E: raise web.NotFound( template.errors.generic( "Can't retrieve user profile data: {0}".format(E))) except steam.items.InventoryError as E: raise web.NotFound( template.errors.generic( "Couldn't open backpack: {0}".format(E))) item = None try: item = items["items"][iid] except KeyError: for cid, bpitem in items["items"].iteritems(): oid = bpitem.get("oid") if oid == long(iid): item = bpitem break if not item: raise web.NotFound(template.item_error_notfound(iid)) if web.input().get("contents"): contents = item.get("contents") if contents: item = contents # Strip off quality prefix for possessive name itemname = item["mainname"] if itemname.startswith("The "): item["ownedname"] = itemname[4:] else: item["ownedname"] = itemname return template.item(app, user, item)
def GET(self, app, sid): app = models.app_aliases.get(app, app) sid = sid.strip('/').split('/') if len(sid) > 0: sid = sid[-1] if not sid: raise web.NotFound(template.errors.generic("Need an ID")) query = web.input() sortby = query.get("sort") filter_class = query.get("cls") filter_quality = query.get("quality") # TODO: Possible custom page sizes via query part dims = markup.get_page_sizes().get(app) try: pagesize = int(dims["width"] * dims["height"]) except TypeError: pagesize = None markup.init_theme(app) markup.set_navlink() try: user, pack = models.load_inventory(sid, app) schema = None try: schema = models.schema(scope=app) except models.ItemBackendUnimplemented: pass cell_count = pack["cells"] items = pack["items"].values() filters = views.filtering(items) dropdowns = views.build_dropdowns(items) filter_classes = markup.sorted_class_list( dropdowns["equipable_classes"], app) filter_qualities = markup.get_quality_strings( dropdowns["qualities"], schema) if len(filter_classes) <= 1: filter_classes = None if len(filter_qualities) <= 1: filter_qualities = None if filter_class: items = filters.byClass( markup.get_class_for_id(filter_class, app)[0]) if filter_quality: items = filters.byQuality(filter_quality) sorter = views.sorting(items) sorted_items = sorter.sort(sortby) item_page = views.item_page(items) stats = item_page.summary baditems = [] items, baditems = item_page.build_page(pagesize=pagesize, ignore_pos=sortby) price_stats = item_page.build_price_summary( models.assets(scope=app)) except steam.items.InventoryError as E: raise web.NotFound( template.errors.generic( "Failed to load backpack ({0})".format(E))) except steam.user.ProfileError as E: raise web.NotFound( template.errors.generic( "Failed to load profile ({0})".format(E))) except steam.api.HTTPError as E: raise web.NotFound( template.errors.generic( "Couldn't connect to Steam (HTTP {0})".format(E))) except models.CacheEmptyError as E: raise web.NotFound(template.errors.generic(E)) except: raise web.NotFound(template.errors.generic("Couldn't load feed")) web.ctx.rss_feeds = [ ("{0}'s Backpack".format(user["persona"].encode("utf-8")), markup.generate_root_url("feed/" + str(user["id64"]), app)) ] return template.inventory(app, user, items, sorter.get_sort_methods(), baditems, filter_classes, filter_qualities, stats, price_stats, cell_count)