diff --git a/src/humulus/designs/recipes.json b/src/humulus/designs/recipes.json index 7ea1b59..28aca01 100644 --- a/src/humulus/designs/recipes.json +++ b/src/humulus/designs/recipes.json @@ -10,6 +10,9 @@ }, "by-volume": { "map": "function (doc) {\n if (doc.$type == \"recipe\" && doc.volume && doc.name) {\n emit(doc.volume, doc.name)\n }\n}" + }, + "by-type": { + "map": "function (doc) {\n if (doc.$type == \"recipe\" && doc.type && doc.name) {\n emit(doc.type, doc.name)\n }\n}" } }, "lists": {}, diff --git a/src/humulus/recipes.py b/src/humulus/recipes.py index 7aeefd3..cda4a3d 100644 --- a/src/humulus/recipes.py +++ b/src/humulus/recipes.py @@ -262,12 +262,7 @@ def index(): ['true', 'yes'] ) sort_by = request.args.get('sort_by', default='name', type=str) - if sort_by == 'date': - view = get_view('_design/recipes', 'by-date') - elif sort_by == 'volume': - view = get_view('_design/recipes', 'by-volume') - else: - view = get_view('_design/recipes', 'by-name') + view = get_view('_design/recipes', 'by-{}'.format(sort_by)) return render_template( 'recipes/index.html', diff --git a/src/humulus/templates/recipes/index.html b/src/humulus/templates/recipes/index.html index 495e0b9..23647f8 100644 --- a/src/humulus/templates/recipes/index.html +++ b/src/humulus/templates/recipes/index.html @@ -49,6 +49,15 @@ Batch Size {% endif %} +