From: Ant Zucaro Date: Thu, 5 May 2011 16:43:41 +0000 (-0400) Subject: Add map_info view and template. X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonstat.git;a=commitdiff_plain;h=e853e9533e3edfa7402d70cb641b715d35a19b89 Add map_info view and template. --- diff --git a/xonstat/__init__.py b/xonstat/__init__.py index 43a1c51..7c3bf23 100755 --- a/xonstat/__init__.py +++ b/xonstat/__init__.py @@ -34,6 +34,9 @@ def main(global_config, **settings): config.add_route(name="server_info", pattern="/server/{id}", view=server_info, renderer='server_info.mako') + config.add_route(name="map_info", pattern="/map/{id}", view=map_info, + renderer='map_info.mako') + config.add_route(name="stats_submit", pattern="stats/submit", view=stats_submit, renderer='index.jinja2') diff --git a/xonstat/templates/map_info.mako b/xonstat/templates/map_info.mako new file mode 100755 index 0000000..7cdd52c --- /dev/null +++ b/xonstat/templates/map_info.mako @@ -0,0 +1,23 @@ +<%inherit file="base.mako"/> + +<%block name="title"> +% if gmap: +Map Information for ${gmap.name} - +% endif + +${parent.title()} + + + +% if gmap is None: +

Sorry, that map wasn't found!

+ +% else: +

Map Detail

+ +% endif diff --git a/xonstat/views.py b/xonstat/views.py index 21f4e79..f9574ab 100755 --- a/xonstat/views.py +++ b/xonstat/views.py @@ -64,6 +64,19 @@ def server_info(request): return {'server':server} +########################################################################## +# This is the map views area - only views pertaining to Xonotic +# maps and their related information goes here +########################################################################## +def map_info(request): + map_id = request.matchdict['id'] + try: + gmap = DBSession.query(Map).filter_by(map_id=map_id).one() + except: + gmap = None + return {'gmap':gmap} + + ########################################################################## # This is the stats views area - only views pertaining to Xonotic # statistics and its related information goes here @@ -312,7 +325,7 @@ def stats_submit(request): 'S' not in game_meta: log.debug("Required game meta fields (T, G, M, or S) missing. "\ "Can't continue.") - return {'msg':'Error processing the request.'} + raise Exception server = get_or_create_server(session=session, name=game_meta['S']) gmap = get_or_create_map(session=session, name=game_meta['M'])