09a398be0f60bc155023327f6b4266b804047021
[zzz-spline-gts.git] / splinext / gts / controllers / gts_browse.py
1 # encoding: utf8
2 from __future__ import absolute_import, division
3
4 import logging
5
6 import pokedex.db
7 import pokedex.db.tables as tables
8 from pokedex.struct import SaveFilePokemon
9 from pylons import config, request, response, session, tmpl_context as c, url
10 from pylons.controllers.util import abort, redirect_to
11 from sqlalchemy.orm.exc import NoResultFound
12
13 from spline.model import meta
14 from spline.lib.base import BaseController, render
15 from spline.lib import helpers as h
16 from splinext.gts import model as gts_model
17
18 log = logging.getLogger(__name__)
19
20 class GTSBrowseController(BaseController):
21
22 def list(self):
23 u"""Show a list of all Pokémon currently uploaded to the GTS."""
24
25 gts_pokemons = meta.Session.query(gts_model.GTSPokemon).all()
26
27 c.savefiles = []
28 for gts_pokemon in gts_pokemons:
29 savefile = SaveFilePokemon(gts_pokemon.pokemon_blob)
30 c.savefiles.append(savefile)
31
32 return render('/gts/list.mako')