diff options
Diffstat (limited to 'frontend/grumpy.py')
-rw-r--r-- | frontend/grumpy.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/frontend/grumpy.py b/frontend/grumpy.py index 62ce9b1..8d106a6 100644 --- a/frontend/grumpy.py +++ b/frontend/grumpy.py @@ -1,4 +1,4 @@ -from flask import current_app, redirect, render_template, request, url_for +from flask import abort, current_app, redirect, render_template, request, url_for from flask_classy import FlaskView, route from sqlalchemy.sql import collate from flask_wtf import FlaskForm @@ -22,6 +22,16 @@ class GrumpyView(FlaskView): categories = models.Category.query.all() return render_template("index.html", categories=categories) + @route('/category/<categoryname>', methods=['GET']) + def category(self, categoryname): + category = models.Category.query.filter_by(name=categoryname).first() + + if category: + packages = models.Package.query.filter_by(category=category) + return render_template('category.html', category=category, packages=packages) + else: + abort(404) + class SetupView(FlaskView): @route('/', methods=['GET', 'POST']) # FIXME: Can we enable POST without giving a rule override from the automatic, or handle this some other better way with wtforms setup? def index(self): |