Skip to content

Commit

Permalink
Changes example to redirect to the graph of latest version of pgraph.
Browse files Browse the repository at this point in the history
Signed-off-by: Kouhei Maeda <mkouhei@palmtb.net>
  • Loading branch information
mkouhei committed Jul 2, 2015
1 parent c9c5274 commit cca7ed8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions pgraph/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ def main(global_config, **settings):
config.add_route('linkdraw', '/api/linkdraw/{pkg}/{version}')
config.add_route('graph', '/graph/{pkg}/{version}')
config.add_route('search', '/search')
config.add_route('example', '/example')
config.scan()
return config.make_wsgi_app()
2 changes: 1 addition & 1 deletion pgraph/templates/layout.pt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<button class="btn btn-default" id="search-addon"><icon class="glyphicon glyphicon-search"/></button>
</form>
<ul class="nav navbar-nav navbar-right">
<li><a href="/graph/pgraph/${version}" title="example">Example</a></li>
<li><a href="/example" title="example">Example</a></li>
</ul>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions pgraph/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,8 @@ def test_config(self):
with open('pgraph/tests/data/config.js') as fobj:
data = fobj.read()
self.assertEqual(data.encode('utf-8'), res.body)

def test_example(self):
"""unit test of example redirect."""
res = self.testapp.get('/example', status=302)
self.assertTrue('/graph/pgraph/' in res.location)
9 changes: 9 additions & 0 deletions pgraph/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""pgraph.views module."""
from pyramid.renderers import get_renderer
from pyramid.view import view_config
import pyramid.httpexceptions as exc
from pgraph import __project__, __version__, __author__, __repo__, READTHEDOCS
from pgraph import tasks

Expand Down Expand Up @@ -91,3 +92,11 @@ def search(self):
self.meta['pkg_name'] = pkg_name
self.meta['results'] = tasks.search(pkg_name)
return self.meta

@view_config(route_name='example', renderer='templates/graph.pt')
def example(self):
"""drawing example graph."""
raise exc.HTTPFound(
self.request.route_url('graph',
pkg=self.meta.get('project'),
version=self.meta.get('version')))

0 comments on commit cca7ed8

Please sign in to comment.