diff --git a/SocialHelper/SocialHelper/__pycache__/settings.cpython-37.pyc b/SocialHelper/SocialHelper/__pycache__/settings.cpython-37.pyc index 8cc1645..66f78c3 100644 Binary files a/SocialHelper/SocialHelper/__pycache__/settings.cpython-37.pyc and b/SocialHelper/SocialHelper/__pycache__/settings.cpython-37.pyc differ diff --git a/SocialHelper/SocialHelper/__pycache__/urls.cpython-37.pyc b/SocialHelper/SocialHelper/__pycache__/urls.cpython-37.pyc index b19e165..57c8608 100644 Binary files a/SocialHelper/SocialHelper/__pycache__/urls.cpython-37.pyc and b/SocialHelper/SocialHelper/__pycache__/urls.cpython-37.pyc differ diff --git a/SocialHelper/homepage/__pycache__/models.cpython-37.pyc b/SocialHelper/homepage/__pycache__/models.cpython-37.pyc index 9a1f377..79a2af1 100644 Binary files a/SocialHelper/homepage/__pycache__/models.cpython-37.pyc and b/SocialHelper/homepage/__pycache__/models.cpython-37.pyc differ diff --git a/SocialHelper/homepage/__pycache__/views.cpython-37.pyc b/SocialHelper/homepage/__pycache__/views.cpython-37.pyc index e425882..b336f01 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/migrations/0002_product_wolontatriat.py b/SocialHelper/homepage/migrations/0002_product_wolontatriat.py new file mode 100644 index 0000000..cbeedca --- /dev/null +++ b/SocialHelper/homepage/migrations/0002_product_wolontatriat.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2020-12-30 21:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('homepage', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='product', + name='Wolontatriat', + field=models.BooleanField(default=False), + ), + ] diff --git a/SocialHelper/homepage/migrations/__pycache__/0002_product_wolontatriat.cpython-37.pyc b/SocialHelper/homepage/migrations/__pycache__/0002_product_wolontatriat.cpython-37.pyc new file mode 100644 index 0000000..e04abaa Binary files /dev/null and b/SocialHelper/homepage/migrations/__pycache__/0002_product_wolontatriat.cpython-37.pyc differ diff --git a/SocialHelper/homepage/templates/homepage/add_offer.html b/SocialHelper/homepage/templates/homepage/add_offer.html index 206ebb4..75a3f39 100644 --- a/SocialHelper/homepage/templates/homepage/add_offer.html +++ b/SocialHelper/homepage/templates/homepage/add_offer.html @@ -35,7 +35,7 @@ - +
@@ -49,6 +49,18 @@
+
+
+
+ + +
+
+
+
diff --git a/SocialHelper/homepage/templates/homepage/create_user.html b/SocialHelper/homepage/templates/homepage/create_user.html index d86980a..574a9f1 100644 --- a/SocialHelper/homepage/templates/homepage/create_user.html +++ b/SocialHelper/homepage/templates/homepage/create_user.html @@ -3,6 +3,92 @@ {% block content %} + + + + @@ -32,7 +118,7 @@
-
+
@@ -43,6 +129,61 @@
+
+
+
+ + + + +
+
+
+ +
@@ -142,6 +283,33 @@ Copyright © All r
+ {% endblock %} diff --git a/SocialHelper/homepage/templates/homepage/edycja_ogloszenia.html b/SocialHelper/homepage/templates/homepage/edycja_ogloszenia.html index d19f9fa..92163d3 100644 --- a/SocialHelper/homepage/templates/homepage/edycja_ogloszenia.html +++ b/SocialHelper/homepage/templates/homepage/edycja_ogloszenia.html @@ -59,6 +59,18 @@
+
+
+
+ + +
+
+
+
diff --git a/SocialHelper/homepage/views.py b/SocialHelper/homepage/views.py index 8b52b2c..f84b88a 100644 --- a/SocialHelper/homepage/views.py +++ b/SocialHelper/homepage/views.py @@ -80,7 +80,6 @@ def index_offer(request): } return HttpResponse(template.render(context, request)) - def contact(request): return render(request , 'homepage/contact.html') @@ -168,6 +167,14 @@ def add_offer(request): type_local = request.POST['type'] script_local = request.POST['script'] title_local = request.POST['title'] + + + wol_local = request.POST['wol'] + if wol_local == "1": + wol = False + else: + wol = True + data_local = timezone.now() if request.FILES: pic_local = request.FILES['file'] @@ -176,6 +183,7 @@ def add_offer(request): offer_local = request.POST['offer'] product = Product( picture = pic_local, + Wolontatriat = wol, create_date = data_local, user_iden = request.user, type = int(type_local), @@ -186,6 +194,7 @@ def add_offer(request): keywords = "", ) product.save() + messages.success(request, 'Ogłoszenie dodane!') return redirect(my_offer) return render(request , 'homepage/add_offer.html') else: @@ -195,6 +204,7 @@ def delete_offer(request, offer_id): instance = Product.objects.get(id=offer_id) instance.active = False instance.save() + messages.success(request, 'Ogłoszenie usunięte!') return redirect(my_offer) @@ -212,12 +222,20 @@ def edit_offer(request, offer_id): type_local = request.POST['type'] script_local = request.POST['script'] title_local = request.POST['title'] + + wol_local = request.POST['wol'] + if wol_local == "1": + wol = False + else: + wol = True + if request.FILES: pic_local = request.FILES['file'] instance.picture = pic_local offer_local = request.POST['offer'] + instance.Wolontatriat = wol, instance.type = int(type_local) instance.offer = int(offer_local) instance.title = title_local @@ -226,6 +244,7 @@ def edit_offer(request, offer_id): instance.keywords = "" instance.save() + messages.success(request, 'Ogłoszenie edytowane!') return redirect(my_offer) return render(request , 'homepage/edycja_ogloszenia.html', context) @@ -234,6 +253,18 @@ def create_user(request): User = get_user_model() email = request.POST['email'] password = request.POST['password'] + if email == "": + messages.error(request,'Pole email jest puste!') + return redirect('create_user') + + if "@" not in email: + messages.error(request,'Wprowadzony email jest niepoprawny!') + return redirect('create_user') + + if password == "": + messages.error(request,'Pole hasło jest puste!') + return redirect('create_user') + if User.objects.filter(email=email).exists(): messages.error(request,'Ten adres e-mail jest już używany') return redirect('create_user') @@ -255,7 +286,14 @@ def delete_user(request): User = get_user_model() instant = User.objects.filter(id=request.user.id).first() instant.is_active = False + instant.email = str(instant.id) + instant.username = str(instant.id) + instant_offer = Product.objects.filter(user_iden = instant) + for offer in instant_offer: + offer.active = False + offer.save() instant.save() + messages.success(request,'Konto skasowane!') return redirect(index)