Skip to content

Commit

Permalink
Show discontinued items with request link on items page
Browse files Browse the repository at this point in the history
Closes #83
  • Loading branch information
ppannuto committed Aug 1, 2014
1 parent bbeee46 commit c69349f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions chezbetty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def debug(request):
config.add_route('item', '/item/{barcode}/json')
config.add_route('item_request', '/item/request')
config.add_route('item_request_new', '/item/request/new')
config.add_route('item_request_by_id', '/item/request/by_id/{id}')

config.add_route('shame', '/shame')
config.add_route('user', '/user/{umid}')
Expand Down
21 changes: 21 additions & 0 deletions chezbetty/templates/items.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,27 @@ Betty stops selling something you would like back, feel free to
</tbody>

</table>

<h4>Discontinued Items:</h4>

<table class="table table-bordered table-striped sortable">
<thead>
<tr>
<th>Item</th>
<th style="width: 15%"></th>
</tr>
</thead>

<tbody>
{% for item in disabled_items %}
<tr>
<td class="item-name">{{ item.name }}</td>
<td><a href="/item/request/by_id/{{ item.id }}" class="btn btn-default">Request Return</a></td>
</tr>
{% endfor %}
</tbody>

</table>
</div>
</div>
</div>
Expand Down
11 changes: 10 additions & 1 deletion chezbetty/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def items(request):
items = DBSession.query(Item)\
.filter(Item.enabled==True)\
.order_by(Item.name).all()
return {'items': items}
disabled_items = DBSession.query(Item)\
.filter(Item.enabled==False)\
.order_by(Item.name).all()
return {'items': items, 'disabled_items': disabled_items}


@view_config(route_name='item_request', renderer='templates/item_request.jinja2')
Expand Down Expand Up @@ -293,6 +296,12 @@ def item_request_new(request):
request.session.flash('Error adding request.', 'error')
return HTTPFound(location=request.route_url('index'))

@view_config(route_name='item_request_by_id')
def item_request_by_id(request):
item = Item.from_id(request.matchdict['id'])
datalayer.new_request(None, item.name)
request.session.flash('Request for {} added successfully'.format(item.name), 'success')
return HTTPFound(location=request.route_url('index'))

@view_config(route_name='purchase_new', request_method='POST', renderer='json', permission='service')
def purchase_new(request):
Expand Down

0 comments on commit c69349f

Please sign in to comment.