diff --git a/SocialHelper/homepage/__pycache__/urls.cpython-37.pyc b/SocialHelper/homepage/__pycache__/urls.cpython-37.pyc
index a6d2c82..8260bbd 100644
Binary files a/SocialHelper/homepage/__pycache__/urls.cpython-37.pyc and b/SocialHelper/homepage/__pycache__/urls.cpython-37.pyc differ
diff --git a/SocialHelper/homepage/__pycache__/views.cpython-37.pyc b/SocialHelper/homepage/__pycache__/views.cpython-37.pyc
index f5f6c4f..2c09c47 100644
Binary files a/SocialHelper/homepage/__pycache__/views.cpython-37.pyc and b/SocialHelper/homepage/__pycache__/views.cpython-37.pyc differ
diff --git a/SocialHelper/homepage/templates/homepage/Mojeogloszenia.html b/SocialHelper/homepage/templates/homepage/Mojeogloszenia.html
index 853d4fa..8010198 100644
--- a/SocialHelper/homepage/templates/homepage/Mojeogloszenia.html
+++ b/SocialHelper/homepage/templates/homepage/Mojeogloszenia.html
@@ -43,7 +43,7 @@
{% endif %}
{% if types_o.0.0 == product.offer %}
Usługa
-
+
{% else %}
Przedmiot
diff --git a/SocialHelper/homepage/urls.py b/SocialHelper/homepage/urls.py
index 8d0ddc5..9d9b7ef 100644
--- a/SocialHelper/homepage/urls.py
+++ b/SocialHelper/homepage/urls.py
@@ -9,5 +9,6 @@ urlpatterns = [
path('filter', views.filter, name='filter'),
path('Dodawanie', views.Dodawanie, name='Dodawanie'),
path('Mojeogloszenia', views.Mojeogloszenia, name='Mojeogloszenia'),
+ path('/delete_offer', views.delete_offer, name='delete_offer'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
diff --git a/SocialHelper/homepage/views.py b/SocialHelper/homepage/views.py
index 761e14a..c7c229d 100644
--- a/SocialHelper/homepage/views.py
+++ b/SocialHelper/homepage/views.py
@@ -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.urls import reverse
from django.template import loader
@@ -32,6 +32,28 @@ def index(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):
all_product = Product.objects.filter(active = True)
@@ -103,40 +125,14 @@ def Dodawanie(request):
keywords = "",
)
product.save()
- all_product = Product.objects.filter(user_owner = "jedrzejklepacki@wp.pl")
- 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 redirect(Mojeogloszenia)
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')
- 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 delete_offer(request, offer_id):
+ instance = Product.objects.get(id=offer_id)
+ instance.active = False
+ instance.save()
+
+ return redirect(Mojeogloszenia)