add available items button on item list page

pull/3/head
lance 5 years ago
parent a7b0450316
commit db2c617e84

@ -14,6 +14,7 @@ from sales.models import ItemSale
def list_items(request):
page_query = request.GET.get('page', 1)
mine_query = request.GET.get('mine')
avail_query = request.GET.get('avail')
search_form = SearchItemForm(request.GET or None)
# If the 'mine_query' query string is present, show the user's items
@ -25,10 +26,13 @@ def list_items(request):
Q(name__icontains=search_form.cleaned_data.get('search')) |
Q(whereabouts__icontains=search_form.cleaned_data.get('search')) |
Q(description__icontains=search_form.cleaned_data.get('search'))
)
).order_by('-list_date')
else:
item_list = Item.objects.all().order_by('-list_date')
if avail_query:
item_list = item_list.filter(available=True).order_by('-list_date')
paginator = Paginator(item_list, 20)
try:

@ -8,6 +8,7 @@
<h2>View Items</h2>
{% if request.user.is_authenticated %}
<a href="{% url 'list_items' %}?mine=true" class="button">Your Items</a>
<a href="{% url 'list_items' %}?{{ request.GET.urlencode }}&avail=true" class="button alt">Available Items</a>
<a href="{% url 'list_items' %}" class="button alt">All Items</a>
{% endif %}
<form method="GET" enctype="multipart/form-data" action="">