usuwanie ogloszenia

This commit is contained in:
Jędrzej Klepacki 2020-12-11 22:23:54 +01:00
parent d63c08271b
commit ef2b52d9ae
5 changed files with 34 additions and 37 deletions

View File

@ -43,7 +43,7 @@
{% endif %} {% endif %}
{% if types_o.0.0 == product.offer %} {% if types_o.0.0 == product.offer %}
Usługa</h5> Usługa</h5>
<a href="/homepage/"><button type="button" class="btn btn-danger pull-right">Zakończ</button></a> <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="/homepage/"><button type="button" class="btn btn-primary pull-right">Edytuj</button></a>
{% else %} {% else %}
Przedmiot</h5> Przedmiot</h5>

View File

@ -9,5 +9,6 @@ urlpatterns = [
path('filter', views.filter, name='filter'), path('filter', views.filter, name='filter'),
path('Dodawanie', views.Dodawanie, name='Dodawanie'), path('Dodawanie', views.Dodawanie, name='Dodawanie'),
path('Mojeogloszenia', views.Mojeogloszenia, name='Mojeogloszenia'), path('Mojeogloszenia', views.Mojeogloszenia, name='Mojeogloszenia'),
path('<int:offer_id>/delete_offer', views.delete_offer, name='delete_offer'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View File

@ -1,4 +1,4 @@
from django.shortcuts import get_object_or_404, render from django.shortcuts import get_object_or_404, render, redirect
from django.http import HttpResponse, HttpResponseRedirect from django.http import HttpResponse, HttpResponseRedirect
from django.urls import reverse from django.urls import reverse
from django.template import loader from django.template import loader
@ -32,6 +32,28 @@ def index(request):
} }
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def Mojeogloszenia(request):
all_product = Product.objects.filter(user_owner = "jedrzejklepacki@wp.pl", active = True)
template = loader.get_template('homepage/Mojeogloszenia.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): def filter(request):
all_product = Product.objects.filter(active = True) all_product = Product.objects.filter(active = True)
@ -103,40 +125,14 @@ def Dodawanie(request):
keywords = "", keywords = "",
) )
product.save() product.save()
all_product = Product.objects.filter(user_owner = "jedrzejklepacki@wp.pl") return redirect(Mojeogloszenia)
template = loader.get_template('homepage/Mojeogloszenia.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))
return render(request , 'homepage/Dodawanie.html') return render(request , 'homepage/Dodawanie.html')
def Mojeogloszenia(request):
all_product = Product.objects.filter(user_owner = "jedrzejklepacki@wp.pl")
template = loader.get_template('homepage/Mojeogloszenia.html') def delete_offer(request, offer_id):
types = TYPE_T instance = Product.objects.get(id=offer_id)
types_o = TYPE_O instance.active = False
place_local = "" instance.save()
oddam_local = ""
potrzebuje_local = "" return redirect(Mojeogloszenia)
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))