acd6d15387d73d9730a66c1ef4cfad8eaede159a
[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 from splinext.pokedex.db import pokedex_session
18
19 log = logging.getLogger(__name__)
20
21 class GTSBrowseController(BaseController):
22
23 def list(self):
24 u"""Show a list of all Pokémon currently uploaded to the GTS."""
25
26 gts_pokemons = meta.Session.query(gts_model.GTSPokemon).all()
27
28 c.savefiles = []
29 for gts_pokemon in gts_pokemons:
30 savefile = SaveFilePokemon(gts_pokemon.pokemon_blob)
31 savefile.use_database_session(pokedex_session)
32 c.savefiles.append(savefile)
33
34 return render('/gts/list.mako')