This commit is contained in:
Jędrzej Klepacki 2020-12-10 21:23:53 +01:00
parent 2dca3cd033
commit e245332681
14 changed files with 73 additions and 197 deletions

View File

@ -1,4 +1,4 @@
# Generated by Django 2.1.5 on 2020-12-03 18:24
# Generated by Django 2.1.5 on 2020-12-10 20:03
import datetime
from django.db import migrations, models
@ -16,9 +16,12 @@ class Migration(migrations.Migration):
name='Product',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('active', models.BooleanField(default=True)),
('picture', models.ImageField(blank=True, null=True, upload_to='images/')),
('create_date', models.DateField(default=datetime.date.today, verbose_name='Date')),
('user_owner', models.TextField(default='', max_length=40)),
('type', models.IntegerField(choices=[(1, 'Potrzebuje'), (2, 'Oddam')], default='')),
('offer', models.IntegerField(choices=[(1, 'Usługa'), (2, 'Przedmiot')], default='')),
('title', models.TextField(default='', max_length=40)),
('description', models.TextField(default='', max_length=6000)),
('place', models.TextField(default='', max_length=40)),

View File

@ -1,18 +0,0 @@
# Generated by Django 2.1.5 on 2020-12-10 18:55
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='product',
name='picture',
field=models.FileField(blank=True, null=True, upload_to='documents/%Y/%m/%d'),
),
]

View File

@ -1,18 +0,0 @@
# Generated by Django 2.1.5 on 2020-12-10 19:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0002_product_picture'),
]
operations = [
migrations.AlterField(
model_name='product',
name='picture',
field=models.ImageField(blank=True, null=True, upload_to='images/'),
),
]

View File

@ -24,6 +24,15 @@
<div class="container">
<div class="track_inner">
<form class="track_form row">
<div class="col-lg-12 form-group">
<label for="cun">Rodzaj ogłoszenia <span>*</span></label>
<select id="cun" name="offer">
<option value="1">Usługa</option>
<option value="2">Przedmiot</option>
</select>
</div>
<div class="col-lg-12 form-group">
<label for="cun">Typ ogłoszenia <span>*</span></label>
<select id="cun" name="type">

View File

@ -1,153 +0,0 @@
{% extends 'base.html' %}
{% load static %}
{% block content %}
<!DOCTYPE html>
<html lang="en">
<body>
<!--================Categories Banner Area =================-->
<section class="solid_banner_area">
<div class="container">
<div class="solid_banner_inner">
<h3>Dodaj nowe ogłoszenie</h3>
</div>
</div>
</section>
<!--================End Categories Banner Area =================-->
<!--================Register Area =================-->
<form action="{% url 'Dodawanie' %}" method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.media }}
{{ form.as_p }}
<section class="track_area p_100">
<div class="container">
<div class="track_inner">
<form class="track_form row">
<div class="col-lg-12 form-group">
<label for="cun">Typ ogłoszenia <span>*</span></label>
<select id="cun" name="type">
<option value="2">Oddam</option>
<option value="1">Potrzebuję</option>
</select>
</div>
<div class="col-lg-12 form-group">
<label for="name">Tytył <span>*</span></label>
<input type="text" class="form-control" id="name" aria-describedby="name" placeholder="" name="title">
</div>
<div class="col-lg-12 form-group">
<label for="name">Miejscowość <span>*</span></label>
<input type="text" class="form-control" id="name" aria-describedby="name" placeholder="" name="place">
</div>
<div class="col-lg-12 form-group">
<label for="order">Opis <span>*</span></label>
<textarea class="form-control" id="order" rows="3" name="script"></textarea>
</div>
<div class="col-lg-12 form-group">
<div class="file-field">
<span>Wybierz zdjęcie</span>
<input name="file" type="file" accept="image/*">
</div>
</div>
<div class="col-lg-12 form-group">
<input type="submit" class="btn btn-primary update_btn" value="Dodaj">
</div>
</form>
</div>
</div>
</section>
</form>
<!--================End Track Area =================-->
<!--================End Register Area =================-->
<!--================Footer Area =================-->
<footer class="footer_area">
<div class="container">
<div class="footer_widgets">
<div class="row">
<div class="col-lg-4 col-md-4 col-6">
<aside class="f_widget f_about_widget">
<img src="img/logo.png" alt="">
<p>Persuit is a Premium PSD Template. Best choice for your online store. Let purchase it to enjoy now</p>
<h6>Social:</h6>
<ul>
<li><a href="#"><i class="social_facebook"></i></a></li>
<li><a href="#"><i class="social_twitter"></i></a></li>
<li><a href="#"><i class="social_pinterest"></i></a></li>
<li><a href="#"><i class="social_instagram"></i></a></li>
<li><a href="#"><i class="social_youtube"></i></a></li>
</ul>
</aside>
</div>
<div class="col-lg-2 col-md-4 col-6">
<aside class="f_widget link_widget f_info_widget">
<div class="f_w_title">
<h3>Information</h3>
</div>
<ul>
<li><a href="#">About us</a></li>
<li><a href="#">Delivery information</a></li>
<li><a href="#">Terms & Conditions</a></li>
<li><a href="#">Help Center</a></li>
<li><a href="#">Returns & Refunds</a></li>
</ul>
</aside>
</div>
<div class="col-lg-2 col-md-4 col-6">
<aside class="f_widget link_widget f_service_widget">
<div class="f_w_title">
<h3>Customer Service</h3>
</div>
<ul>
<li><a href="#">My account</a></li>
<li><a href="#">Ordr History</a></li>
<li><a href="#">Wish List</a></li>
<li><a href="#">Newsletter</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</aside>
</div>
<div class="col-lg-2 col-md-4 col-6">
<aside class="f_widget link_widget f_extra_widget">
<div class="f_w_title">
<h3>Extras</h3>
</div>
<ul>
<li><a href="#">Brands</a></li>
<li><a href="#">Gift Vouchers</a></li>
<li><a href="#">Affiliates</a></li>
<li><a href="#">Specials</a></li>
</ul>
</aside>
</div>
<div class="col-lg-2 col-md-4 col-6">
<aside class="f_widget link_widget f_account_widget">
<div class="f_w_title">
<h3>My Account</h3>
</div>
<ul>
<li><a href="#">My account</a></li>
<li><a href="#">Ordr History</a></li>
<li><a href="#">Wish List</a></li>
<li><a href="#">Newsletter</a></li>
</ul>
</aside>
</div>
</div>
</div>
<div class="footer_copyright">
<h5>© <script>document.write(new Date().getFullYear());</script> <!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
Copyright &copy;<script>document.write(new Date().getFullYear());</script> All rights reserved | This template is made with <i class="fa fa-heart-o" aria-hidden="true"></i> by <a href="https://colorlib.com" target="_blank">Colorlib</a>. Downloaded from <a href="https://themeslab.org/" target="_blank">Themeslab</a>
<!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
</h5>
</div>
</div>
</footer>
<!--================End Footer Area =================-->
</body>
</html>
{% endblock %}

View File

@ -41,7 +41,7 @@
<div class="row">
<div class="col-lg-4 col-md-6">
<div class="c_product_img">
<img class="img-fluid" src="{% static "img/product/l-product-2.jpg" %}">
<img class="img-fluid" src="{{ product.picture.url }}">
</div>
</div>
<div class="col-lg-8 col-md-6">
@ -52,6 +52,13 @@
{% else %}
<h5>Oddam</h5>
{% endif %}
{% if types_o.0.0 == product.offer %}
<h5>Usługa</h5>
{% else %}
<h5>Przedmiot</h5>
{% endif %}
<h6>Z miejscowości: <span>{{ product.place }}</span></h6>
<p>{{ product.description }}</p>
</div>
@ -82,6 +89,8 @@
<input type="hidden" name="place" value="">
<input type="hidden" name="Oddam" value="">
<input type="hidden" name="Potrzebuje" value="">
<input type="hidden" name="usluga" value="">
<input type="hidden" name="przedmiot" value="">
<div class="col-lg-3 float-md-right">
<div class="categories_sidebar">
@ -120,6 +129,28 @@
<label for="scales">Potrzebuje</label>
</ul>
</aside>
<aside class="l_widgest l_menufacture_widget">
<div class="l_w_title">
<h3>Rodzaj</h3>
</div>
<ul>
{% if usluga_local %}
<input type="checkbox" id="usluga" name="usluga" Checked>
{% else %}
<input type="checkbox" id="usluga" name="usluga" >
{% endif %}
<label for="Oddam">Usługa</label>
<p></p>
{% if przedmiot_local %}
<input type="checkbox" id="przedmiot" name="przedmiot" Checked>
{% else %}
<input type="checkbox" id="przedmiot" name="przedmiot" >
{% endif %}
<label for="scales">Przedmiot</label>
</ul>
</aside>
<input type="submit" class="btn btn-primary update_btn" value="Zastosuj">
</div>
</div>

View File

@ -3,7 +3,7 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.urls import reverse
from django.template import loader
from .models import Product, TYPE_T
from .models import Product, TYPE_T, TYPE_O
from django.utils import timezone
from datetime import timedelta
@ -14,26 +14,34 @@ def index(request):
all_product = Product.objects.all
template = loader.get_template('homepage/index.html')
types = TYPE_T
types_o = TYPE_O
place_local = ""
oddam_local = ""
potrzebuje_local = ""
usluga_local = ""
przedmiot_local = ""
context = {
'all_product': all_product,
'types': types,
'place_local': place_local,
'oddam_local': oddam_local,
'potrzebuje_local': potrzebuje_local,
'types_o': types_o,
'usluga_local': usluga_local,
'przedmiot_local': przedmiot_local,
}
return HttpResponse(template.render(context, request))
def filter(request):
all_product = Product.objects.filter(create_date__contains = "2")
all_product = Product.objects.filter(active = True)
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']
usluga_local = request.POST['usluga']
przedmiot_local = request.POST['przedmiot']
if place_local != "":
all_product = all_product.filter(place=place_local)
@ -46,15 +54,28 @@ def filter(request):
zmienna = 1
all_product = all_product.filter(type=zmienna)
if usluga_local == "on" and przedmiot_local != "on":
zmienna = 1
all_product = all_product.filter(type=zmienna)
if usluga_local != "on" and przedmiot_local == "on":
zmienna = 2
all_product = all_product.filter(type=zmienna)
types = TYPE_T
types_o = TYPE_O
print(types)
context = {
'all_product': all_product,
'types': types,
'types_o': types_o,
'place_local': place_local,
'oddam_local': oddam_local,
'potrzebuje_local': potrzebuje_local,
'usluga_local': usluga_local,
'przedmiot_local': przedmiot_local,
}
return HttpResponse(template.render(context, request))
@ -66,12 +87,13 @@ def Dodawanie(request):
title_local = request.POST['title']
data_local = timezone.now()
pic_local = request.FILES['file']
offer_local = request.POST['offer']
product = Product(
picture = pic_local,
create_date = data_local,
user_owner = "jedrzejklepacki@wp.pl",
type = int(type_local),
offer = int(offer_local),
title = title_local,
description = script_local,
place = place_local,

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB