Skip to content

Commit

Permalink
add page for viewing tags
Browse files Browse the repository at this point in the history
  • Loading branch information
bradjc committed Jun 26, 2016
1 parent c0d7e75 commit f5b38ed
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions chezbetty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def debug(request):
config.add_route('admin_item_barcode_pdf', '/admin/item/barcode/{item_id}.pdf')
config.add_route('admin_item_delete', '/admin/item/delete/{item_id}')

config.add_route('admin_tags_list', '/admin/tags/list')

config.add_route('admin_box_add', '/admin/box/add')
config.add_route('admin_box_add_submit', '/admin/box/add/submit')
config.add_route('admin_boxes_edit', '/admin/boxes/edit')
Expand Down
1 change: 1 addition & 0 deletions chezbetty/templates/admin/sidebar.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<li {% if active_page == 'items_list' %}class="active"{% endif %}><a href="/admin/items/list">List Items<span class="badge pull-right">{{ counts["items"] }}</span></a></li>
<li {% if active_page == 'boxes_add' %}class="active"{% endif %}><a href="/admin/box/add">Add Boxes</a></li>
<li {% if active_page == 'boxes_edit' %}class="active"{% endif %}><a href="/admin/boxes/edit">Edit Boxes<span class="badge pull-right">{{ counts["boxes"] }}</span></a></li>
<li {% if active_page == 'tags_list' %}class="active"{% endif %}><a href="/admin/tags/list">List Tags<span class="badge pull-right">{{ counts["tags"] }}</span></a></li>
</ul>
<ul class="nav nav-sidebar">
<li><span>Manage Vendors</span></li>
Expand Down
47 changes: 47 additions & 0 deletions chezbetty/templates/admin/tags_list.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends "base.jinja2" %}
{% set active_page = 'tags_list' %}
{% block title %}List Tags{% endblock %}

{% block top %}
<h1 class="page-header">Tags ({{ tags|length }})</h1>
{% endblock %}

{% block content %}


<div id="list-tags">

{% for tag in tags %}
<h3>{{ tag.name }}</h3>


<table class="table sortable sticky">

<thead>
<tr>
<th style="width: 70%">Item</th>
<th style="width: 15%">Item Price</th>
<th style="width: 15%">In Stock</th>
</tr>
</thead>

<tbody>

{% for itemtag in tag.items %}
{% set item = itemtag.item %}
<tr id="item-{{ item.id }}">
<td>{{ item|make_link|safe }}</td>
<td>{{ item.price|format_currency|safe }}</td>
<td>{{ item.in_stock }}</td>
</tr>
{% endfor %}

</tbody>

</table>
{% endfor %}

</div>

{% endblock %}

10 changes: 10 additions & 0 deletions chezbetty/views_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def add_counts(event):
event['renderer_name'].startswith('templates/admin'):
count = {}
count['items'] = Item.count()
count['tags'] = Tag.count()
count['boxes'] = Box.count()
count['vendors'] = Vendor.count()
count['users'] = User.count()
Expand Down Expand Up @@ -1531,6 +1532,15 @@ def admin_item_delete(request):
return HTTPFound(location=request.route_url('admin_items_edit'))


@view_config(route_name='admin_tags_list',
renderer='templates/admin/tags_list.jinja2',
permission='manage')
def admin_tags_list(request):
tags = Tag.all()

return {'tags': tags}


@view_config(route_name='admin_box_add',
renderer='templates/admin/boxes_add.jinja2',
permission='manage')
Expand Down

0 comments on commit f5b38ed

Please sign in to comment.