Skip to content
Browse files

The begginings of a product search feature.

  • Loading branch information...
1 parent 9152fb0 commit c37d5276e51099b33a429e343df93fda70452593 @maxolasersquad committed Feb 21, 2014
View
3 inventory/models.py
@@ -23,6 +23,9 @@ class Vendor(models.Model):
def __unicode__(self):
return self.name
+ def natural_key(self):
+ return (self.name)
+
class Meta:
ordering = ['name']
View
1 register/urls.py
@@ -6,4 +6,5 @@
url(r'process_upc/', views.process_upc, name='process_upc'),
url(r'tender_transaction/', views.tender_transaction, name='tender_transaction'),
url(r'end_shift/', views.end_shift, name='end_shift'),
+ url(r'product_search/', views.product_search, name='product_search'),
)
View
7 register/views.py
@@ -1,4 +1,5 @@
from django.shortcuts import render
+from django.core import serializers
from register.models import *
from inventory.models import *
@@ -39,3 +40,9 @@ def end_shift(request):
shift.end_shift()
context_instance = { 'shift': shift.get_totals() }
return render(request, 'register/end_shift.json', context_instance)
+
+def product_search(request):
+ search = request.GET['search']
+ results = Item.objects.filter(name__contains=search) | Item.objects.select_related('vendor').filter(name__contains=search).order_by('name')
+ context_instance = { 'search': search, 'results': results}
+ return render(request, 'register/product_search.html', context_instance)
View
17 static/css/register.css
@@ -38,6 +38,23 @@
margin: 5px;
}
+#product_search {
+ width: 70%;
+ height: 75%;
+ border: solid 2px;
+ margin-top: 5px;
+ position: fixed;
+ display: inline;
+ overflow-y: scroll;
+ overflow-x: hidden;
+}
+
+#product_search > table {
+ width: 100%;
+ margin: 5px;
+ cursor: pointer;
+}
+
#numpad {
float: right;
width: 25%;
View
13 static/js/input.js
@@ -90,6 +90,9 @@ Orthosie.input = {
}
});
break;
+ case 'product-search':
+ Orthosie.input.product_search($('#register_input').html());
+ break;
}
$('#register_input').html('');
},
@@ -116,5 +119,15 @@ Orthosie.input = {
alert('An error was encountered while trying to end the shift.')
}
});
+ },
+ product_search: function(search) {
+ $('#product_search').load('/register/product_search/?search=' + search + '&csrfmiddlewaretoken=' + $('#csrf_token>input').attr('value'), function() {
+ $('#transactions').addClass('hidden');
+ $('#product_search').removeClass('hidden');
+ });
+ },
+ disable_product_search: function() {
+ $('#product_search').addClass('hidden');
+ $('#transactions').removeClass('hidden');
}
}
View
11 templates/register/index.html
@@ -49,17 +49,20 @@
}
}
</script>
- <div id='input'>
+ <div id="input">
{% include "register/input.html" %}
</div>
- <div id='transactions' class="container" data-status="ring">
+ <div id="transactions" class="container" data-status="ring">
{% include "register/transactions.html" %}
</div>
- <div id='totals'>
+ <div id="product_search" class="container hidden">
+{% include "register/product_search.html" %}
+ </div>
+ <div id="totals">
{% include "register/totals.html" %}
</div>
{% include "register/numpad.html" %}
- <div id='confirm_endshift'>
+ <div id="confirm_endshift">
{% include "register/confirm_endshift.html" %}
</div>
<form id="csrf_token">
View
1 templates/register/input.html
@@ -22,6 +22,7 @@
<ul class='dropdown-menu'>
<li id='ringtype-upc'><a href='#' onclick="Orthosie.input.set_inputtype('upc');">UPC</a></li>
<li id='ringtype-tender'><a href='#' onclick="Orthosie.input.set_inputtype('tender');">Tender</a></li>
+ <li id='ringtype-product-search'><a href='#' onclick="Orthosie.input.set_inputtype('product-search');">Product Search</a></li>
<li id='ringtype-endshift' data-toggle='modal' data-target='#confirm_endshift > div'><a href='#' onclick="Orthosie.input.set_inputtype('endshift');">End Shift</a></li>
</ul>
</div>
View
37 templates/register/product_search.html
@@ -0,0 +1,37 @@
+{% comment %}
+ Copyright 2013 Jack David Baucum
+
+ This file is part of Orthosie.
+
+ Orthosie is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Orthosie is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Orthosie. If not, see <http://www.gnu.org/licenses/>.
+{% endcomment %}
+<table class="table table-striped table-hover table-condensed table-responsive">
+ <thead>
+ <tr>
+ <th>UPC</th>
+ <th>Name</th>
+ <th>Scalable</th>
+ <th>Price</th>
+ </thead>
+ <tbody>
+{% for item in results %}
+ <tr>
+ <td>{{ item.upc }}</td>
+ <td>{{ item.name }}</td>
+ <td>{{ item.scalable }}</td>
+ <td>{{ item.price }}</td>
+ </tr>
+{% endfor %}
+ </tbody>
+</table>

0 comments on commit c37d527

Please sign in to comment.
Something went wrong with that request. Please try again.