edycja ogłoszeń
This commit is contained in:
parent
ef2b52d9ae
commit
e0bbcad689
Binary file not shown.
Binary file not shown.
@ -44,11 +44,11 @@
|
||||
{% if types_o.0.0 == product.offer %}
|
||||
Usługa</h5>
|
||||
<a href="{{ product.id }}/delete_offer"><button type="button" class="btn btn-danger pull-right">Zakończ</button></a>
|
||||
<a href="/homepage/"><button type="button" class="btn btn-primary pull-right">Edytuj</button></a>
|
||||
<a href="{{ product.id }}/edit_offer"><button type="button" class="btn btn-primary pull-right">Edytuj</button></a>
|
||||
{% else %}
|
||||
Przedmiot</h5>
|
||||
<button type="button" class="btn btn-danger pull-right">Zakończ</button>
|
||||
<button type="button" class="btn btn-primary pull-right">Edytuj</button>
|
||||
<a href="{{ product.id }}/delete_offer"><button type="button" class="btn btn-danger pull-right">Zakończ</button></a>
|
||||
<a href="{{ product.id }}/edit_offer"><button type="button" class="btn btn-primary pull-right">Edytuj</button></a>
|
||||
{% endif %}
|
||||
<h6>Z miejscowości: <span>{{ product.place }}</span></h6>
|
||||
<p>{{ product.description }}</p>
|
||||
|
@ -0,0 +1,178 @@
|
||||
{% 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 'edit_offer' offer.id %}" 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">Rodzaj ogłoszenia<span>*</span></label>
|
||||
<select id="cun" name="offer">
|
||||
{% if offer.type == types.0.0 %}
|
||||
<option value="1">Usługa</option>
|
||||
<option selected value="2">Przedmiot</option>
|
||||
{% else %}
|
||||
<option selected value="1">Usługa</option>
|
||||
<option value="2">Przedmiot</option>
|
||||
{% endif %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 form-group">
|
||||
<label for="cun">Typ ogłoszenia <span>*</span></label>
|
||||
<select id="cun" name="type">
|
||||
{% if offer.offer == types_o.0.0 %}
|
||||
<option selected value="1">Oddam</option>
|
||||
<option value="2">Potrzebuję</option>
|
||||
{% else %}
|
||||
<option value="1">Oddam</option>
|
||||
<option selected value="2">Potrzebuję</option>
|
||||
{% endif %}
|
||||
</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" value={{ offer.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" value={{ offer.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" >{{ offer.description }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4 col-md-6">
|
||||
<div class="c_product_img">
|
||||
<img class="img-fluid" src="{{ offer.picture.url }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 form-group">
|
||||
<div class="file-field">
|
||||
<span>Wybierz zdjęcie</span>
|
||||
<input name="file" type="file" accept="image/*" value={{ offer.picture.url }}>
|
||||
</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 ©<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 %}
|
@ -10,5 +10,6 @@ urlpatterns = [
|
||||
path('Dodawanie', views.Dodawanie, name='Dodawanie'),
|
||||
path('Mojeogloszenia', views.Mojeogloszenia, name='Mojeogloszenia'),
|
||||
path('<int:offer_id>/delete_offer', views.delete_offer, name='delete_offer'),
|
||||
path('<int:offer_id>/edit_offer', views.edit_offer, name='edit_offer'),
|
||||
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
@ -33,7 +33,7 @@ def index(request):
|
||||
return HttpResponse(template.render(context, request))
|
||||
|
||||
def Mojeogloszenia(request):
|
||||
all_product = Product.objects.filter(user_owner = "jedrzejklepacki@wp.pl", active = True)
|
||||
all_product = Product.objects.filter(user_owner = "jedrzejklepacki@wp.pl", active = True).order_by('create_date')
|
||||
template = loader.get_template('homepage/Mojeogloszenia.html')
|
||||
types = TYPE_T
|
||||
types_o = TYPE_O
|
||||
@ -128,11 +128,40 @@ def Dodawanie(request):
|
||||
return redirect(Mojeogloszenia)
|
||||
return render(request , 'homepage/Dodawanie.html')
|
||||
|
||||
|
||||
|
||||
def delete_offer(request, offer_id):
|
||||
instance = Product.objects.get(id=offer_id)
|
||||
instance.active = False
|
||||
instance.save()
|
||||
|
||||
return redirect(Mojeogloszenia)
|
||||
|
||||
def edit_offer(request, offer_id):
|
||||
instance = Product.objects.get(id=offer_id)
|
||||
types = TYPE_T
|
||||
types_o = TYPE_O
|
||||
context = {
|
||||
'offer': instance,
|
||||
'types': types,
|
||||
'types_o': types_o,
|
||||
}
|
||||
if request.method == 'POST':
|
||||
place_local = request.POST['place']
|
||||
type_local = request.POST['type']
|
||||
script_local = request.POST['script']
|
||||
title_local = request.POST['title']
|
||||
if request.FILES:
|
||||
pic_local = request.FILES['file']
|
||||
instance.picture = pic_local
|
||||
|
||||
offer_local = request.POST['offer']
|
||||
|
||||
instance.type = int(type_local)
|
||||
instance.offer = int(offer_local)
|
||||
instance.title = title_local
|
||||
instance.description = script_local
|
||||
instance.place= place_local
|
||||
instance.keywords = ""
|
||||
|
||||
instance.save()
|
||||
return redirect(Mojeogloszenia)
|
||||
return render(request , 'homepage/edycja_ogloszenia.html', context)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 60 KiB |
Binary file not shown.
Before Width: | Height: | Size: 60 KiB |
Binary file not shown.
Before Width: | Height: | Size: 60 KiB |
Binary file not shown.
Before Width: | Height: | Size: 214 KiB |
Loading…
Reference in New Issue
Block a user