filtrowanie
This commit is contained in:
parent
e92fb3ecf3
commit
5d72299c24
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -119,6 +119,14 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<form action="{% url 'filter' %}" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
|
||||||
|
<input type="hidden" name="place" value="">
|
||||||
|
<input type="hidden" name="Oddam" value="">
|
||||||
|
<input type="hidden" name="Potrzebuje" value="">
|
||||||
|
|
||||||
<div class="col-lg-3 float-md-right">
|
<div class="col-lg-3 float-md-right">
|
||||||
<div class="categories_sidebar">
|
<div class="categories_sidebar">
|
||||||
<aside class="l_widgest l_p_categories_widget">
|
<aside class="l_widgest l_p_categories_widget">
|
||||||
@ -128,7 +136,11 @@
|
|||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<h3 class="cart_single_title">Miejscowość </h3>
|
<h3 class="cart_single_title">Miejscowość </h3>
|
||||||
<input type="text" placeholder="Miejscowość">
|
{% if place_local %}
|
||||||
|
<input type="text" name="place" placeholder="Miejscowość" value={{ place_local }}>
|
||||||
|
{% else %}
|
||||||
|
<input type="text" name="place" placeholder="Miejscowość" >
|
||||||
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
@ -137,16 +149,27 @@
|
|||||||
<h3>Typ</h3>
|
<h3>Typ</h3>
|
||||||
</div>
|
</div>
|
||||||
<ul>
|
<ul>
|
||||||
<input type="checkbox" id="Oddam" name="Oddam">
|
{% if oddam_local %}
|
||||||
|
<input type="checkbox" id="Oddam" name="Oddam" Checked>
|
||||||
|
{% else %}
|
||||||
|
<input type="checkbox" id="Oddam" name="Oddam" >
|
||||||
|
{% endif %}
|
||||||
<label for="Oddam">Oddam</label>
|
<label for="Oddam">Oddam</label>
|
||||||
<p></p>
|
<p></p>
|
||||||
<input type="checkbox" id="Potrzebuje" name="Potrzebuje">
|
{% if potrzebuje_local %}
|
||||||
|
<input type="checkbox" id="Potrzebuje" name="Potrzebuje" Checked>
|
||||||
|
{% else %}
|
||||||
|
<input type="checkbox" id="Potrzebuje" name="Potrzebuje" >
|
||||||
|
{% endif %}
|
||||||
<label for="scales">Potrzebuje</label>
|
<label for="scales">Potrzebuje</label>
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
<button type="submit" class="btn btn-primary update_btn">Zastosuj</button>
|
<input type="submit" class="btn btn-primary update_btn" value="Zastosuj">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,4 +3,5 @@ from . import views
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.index, name='index'),
|
path('', views.index, name='index'),
|
||||||
|
path('filter', views.filter, name='filter'),
|
||||||
]
|
]
|
||||||
|
@ -1,15 +1,53 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import get_object_or_404, render
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
|
from django.urls import reverse
|
||||||
from django.template import loader
|
from django.template import loader
|
||||||
from .models import Product, TYPE_T
|
from .models import Product, TYPE_T
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
all_product = Product.objects.all
|
all_product = Product.objects.all
|
||||||
template = loader.get_template('homepage/index.html')
|
template = loader.get_template('homepage/index.html')
|
||||||
|
types = TYPE_T
|
||||||
|
place_local = ""
|
||||||
|
oddam_local = ""
|
||||||
|
potrzebuje_local = ""
|
||||||
|
context = {
|
||||||
|
'all_product': all_product,
|
||||||
|
'types': types,
|
||||||
|
'place_local': place_local,
|
||||||
|
'oddam_local': oddam_local,
|
||||||
|
'potrzebuje_local': potrzebuje_local,
|
||||||
|
}
|
||||||
|
return HttpResponse(template.render(context, request))
|
||||||
|
|
||||||
|
def filter(request):
|
||||||
|
|
||||||
|
all_product = Product.objects.filter(create_date__contains = "2")
|
||||||
|
template = loader.get_template('homepage/index.html')
|
||||||
|
if request.method == 'POST':
|
||||||
|
place_local = request.POST['place']
|
||||||
|
oddam_local = request.POST['Oddam']
|
||||||
|
potrzebuje_local = request.POST['Potrzebuje']
|
||||||
|
|
||||||
|
if place_local != "":
|
||||||
|
all_product = all_product.filter(place=place_local)
|
||||||
|
|
||||||
|
if oddam_local == "on" and potrzebuje_local != "on":
|
||||||
|
zmienna = 2
|
||||||
|
all_product = all_product.filter(type=zmienna)
|
||||||
|
|
||||||
|
if oddam_local != "on" and potrzebuje_local == "on":
|
||||||
|
zmienna = 1
|
||||||
|
all_product = all_product.filter(type=zmienna)
|
||||||
|
|
||||||
|
|
||||||
types = TYPE_T
|
types = TYPE_T
|
||||||
print(types)
|
print(types)
|
||||||
context = {
|
context = {
|
||||||
'all_product': all_product,
|
'all_product': all_product,
|
||||||
'types': types,
|
'types': types,
|
||||||
|
'place_local': place_local,
|
||||||
|
'oddam_local': oddam_local,
|
||||||
|
'potrzebuje_local': potrzebuje_local,
|
||||||
}
|
}
|
||||||
return HttpResponse(template.render(context, request))
|
return HttpResponse(template.render(context, request))
|
||||||
|
Loading…
Reference in New Issue
Block a user