From 8444d95979bd1560da2fdd5d2569ce15a7561a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Klepacki?= Date: Thu, 10 Dec 2020 20:45:01 +0100 Subject: [PATCH] dodawanie ogloszen backend --- .../__pycache__/settings.cpython-37.pyc | Bin 2512 -> 2512 bytes .../__pycache__/urls.cpython-37.pyc | Bin 982 -> 489 bytes SocialHelper/SocialHelper/settings.py | 9 +- SocialHelper/SocialHelper/urls.py | 20 +---- .../homepage/__pycache__/forms.cpython-37.pyc | Bin 0 -> 435 bytes .../__pycache__/models.cpython-37.pyc | Bin 743 -> 816 bytes .../homepage/__pycache__/urls.cpython-37.pyc | Bin 298 -> 541 bytes .../homepage/__pycache__/views.cpython-37.pyc | Bin 1381 -> 2589 bytes SocialHelper/homepage/forms.py | 7 ++ .../migrations/0002_product_picture.py | 18 ++++ .../migrations/0003_auto_20201210_2008.py | 18 ++++ .../0002_product_picture.cpython-37.pyc | Bin 0 -> 599 bytes .../0003_auto_20201210_2008.cpython-37.pyc | Bin 0 -> 602 bytes SocialHelper/homepage/models.py | 1 + .../templates/homepage/Dodawanie.html | 77 ++++++++++-------- .../templates/homepage/Mojeogloszenia.html | 2 +- SocialHelper/homepage/urls.py | 10 ++- SocialHelper/homepage/views.py | 41 +++++++++- 18 files changed, 144 insertions(+), 59 deletions(-) create mode 100644 SocialHelper/homepage/__pycache__/forms.cpython-37.pyc create mode 100644 SocialHelper/homepage/forms.py create mode 100644 SocialHelper/homepage/migrations/0002_product_picture.py create mode 100644 SocialHelper/homepage/migrations/0003_auto_20201210_2008.py create mode 100644 SocialHelper/homepage/migrations/__pycache__/0002_product_picture.cpython-37.pyc create mode 100644 SocialHelper/homepage/migrations/__pycache__/0003_auto_20201210_2008.cpython-37.pyc diff --git a/SocialHelper/SocialHelper/__pycache__/settings.cpython-37.pyc b/SocialHelper/SocialHelper/__pycache__/settings.cpython-37.pyc index dcd951fa98684826e13b7c63642bd7dfd590270b..8cc1645092a82344c23ac8df94e3e6e5b42a5c8c 100644 GIT binary patch delta 167 zcmca0d_kDkiI8P{ppFo0^iDs2{}&rYBEhS6_UVol%C<*VV<-F+McN=N3y=erDb+ oE{H&ozkkT&OB~vhMK~8qbFwjmAQuM<6BM$sF!C|+F|sfL02`VqcK`qY delta 168 zcmca0d_kDkiID9z2r41!!7EKE?y#>dFQB*4PQ2mshcDu@68 diff --git a/SocialHelper/SocialHelper/__pycache__/urls.cpython-37.pyc b/SocialHelper/SocialHelper/__pycache__/urls.cpython-37.pyc index 7d29b8250191e8fd1bd3da7b4dbce4acfe7bd9d9..b19e165e72206a19d77f7b8c11a823cfbe1accbe 100644 GIT binary patch delta 335 zcmYk2u};G<5Qcqr;wEjp&J>08kM^0*VSOUZSctB~hFp+g-XKl$j|{!Rs(E zc!h7NrB1hd6m?ze>D&nGb#)tFpHD7NvxnK0?Qd~5o!;AlYd+775vtPfNF{De XCG9Jj?72T79k~?24vruq5e(rMAE#0k literal 982 zcma)5-EPw`6n4_|XW0rog74BuCDAHz6Tt+VHmwrkg2DySq|A-oG*xUzwgarU9Hfo3VzadggizVEZo<#g%-y}m7eB$opKewstK938yYpEMf=F~AnK z3ya#ZZJBsb45$-3bQljUK!(^M4jvw?gRSEcv3H~0_+V#tJi+4?@F%FU0a)=gN5w5E zN+RIL_iy19XPZ2$1X4L?uKQt2;C&^E5-CLlllQR5rGkQ2ibzu+q2lm!PQJ(h-f#ga z7X;>P!v$?1U|A3(36z9HF4SwQR4Jn{#5|P&-XWIpQt%x~RgiKT5*99k^HA|JPi1J5 zL)~76?)6thHI|Irn~J4|-LY*0dLFKhPD?IS1mQ+-3h6_F%Ci00%U`tljbtsL zr%;z_vD=yF&0AetPRSfHM9C}9#Gdb76-dhGYb^}-Q2)h(t1S_RNYEJ7(Ye)F4f{v3 zG5G-Tt(DQyuH$tC#_*10 zn>%kzc{JN~!Lv{s*md&Ej|SKCefO7szreTZA;L6gzFm*oyxK9=?@x@&CCW&+pLStW zydO0c;XD7N9w&)@LP-)oX<2KrO5|&yUp1&tds2iRBp}T6)Q-#*sU0J*KJ8ulcOcB% sHQVnO*U{bT)AFuA8~-^Nu%LXXCod_-RY5MEY9u+)n`50>&jx4KA4ESf>i_@% diff --git a/SocialHelper/SocialHelper/settings.py b/SocialHelper/SocialHelper/settings.py index fafb346..70f48eb 100644 --- a/SocialHelper/SocialHelper/settings.py +++ b/SocialHelper/SocialHelper/settings.py @@ -84,8 +84,6 @@ DATABASES = { } } - - # Password validation # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators @@ -122,12 +120,11 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.1/howto/static-files/ +MEDIA_URL = '/media/' +MEDIA_ROOT = os.path.join(BASE_DIR, 'media') + STATIC_ROOT = os.path.join(BASE_DIR,'static') STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR,'SocialHelper/static') ] - -# Media Folder Settings -MEDIA_ROOT = os.path.join(BASE_DIR, 'media' ) -MEDIA_URL = '/media/' diff --git a/SocialHelper/SocialHelper/urls.py b/SocialHelper/SocialHelper/urls.py index 5f16db5..37e56e3 100644 --- a/SocialHelper/SocialHelper/urls.py +++ b/SocialHelper/SocialHelper/urls.py @@ -1,22 +1,10 @@ -"""SocialHelper URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/2.1/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" from django.contrib import admin from django.urls import include, path +from django.conf import settings +from django.conf.urls.static import static + urlpatterns = [ path('homepage/', include('homepage.urls')), path('admin/', admin.site.urls), -] +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/SocialHelper/homepage/__pycache__/forms.cpython-37.pyc b/SocialHelper/homepage/__pycache__/forms.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..daf3ba0c78e0286e3ab8315043ace8892ba3a26e GIT binary patch literal 435 zcmY*Vy-ve05VoD9w51(bnIg6<9V#Y-5JFI3>5_@4lI6zNG?iVKBt>mkSa}e{+c0`% z;uV-UCn|`O?tH)Bcjv2qze`Y_&pCX|v}BAN7Fi1dIi z*t3^-(vL|Ld|@Ans10VO&}HhPz5HSwV+KeBM$86EOhMVs9MpPfqj@8R`<2>!4{y#U@x%QjHfb)@9dbbNKbRX0 zE0MvZK6|j*79LJJEn8^X)TfNrxpCy%mRyKsW*Tze9a)$D7#r^pCvE$@+5Cb!Ft=`x F{Qyh9YbpQ$ literal 0 HcmV?d00001 diff --git a/SocialHelper/homepage/__pycache__/models.cpython-37.pyc b/SocialHelper/homepage/__pycache__/models.cpython-37.pyc index c6a53e566e7fdb2829731a392f72af7c61529e1e..43a919c086ed05891256104712006b8af25aff80 100644 GIT binary patch delta 355 zcmaFPx`B2%)QJ}tUx|n z3QH<`7DpCm3TrP@6cU}k|h1B0KY$m9k_EfFqHkdbbgsW~Z8 z>;;+0C8b5FlUFi!vB`nVkeh7DSc=J z0E%#?FsHDju%@u}GDmR%`P`{IU_LvL&xSTM6doPohlQ)u!gMy<&o z89UjeK{C>l8Czd>BIb diff --git a/SocialHelper/homepage/__pycache__/urls.cpython-37.pyc b/SocialHelper/homepage/__pycache__/urls.cpython-37.pyc index aac91339febabf3245795d00b94611ab97741e1c..a6d2c825c506f177a54c9fb5078481e7c824194f 100644 GIT binary patch literal 541 zcmY+A%W4}j6o#d_d9IEZg*<~dhHOhIZAqYkq=7hHbTAk(=VT(Ii_wgmrt5C=AbpU& zK$qHfl~?F0M~PdAgg*ZNa1Q#V4^2}tTJ7EM^)JrYpJ4v2oWwgi!w&*5;EHM9avil1 zXAnWGVx6=JX$FZ(b=GE2I#m;$w>f9XA;V--zy$L9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ZAiz?!n_1Ohw~s!{nL z&*!6BzeN!Nj02><4V!V)9&OnQwFQ@r04`v%)P1m5tAgp;kbDMfeR;Z=C{}>1{O){T zz!vJ8AdFL#p@xXp!RvMrj}ip_#Yi|L;s(s`@IIHB?n2MYVxi7YHsmK8@{@foKRGM& zle_s6kY3C4Ep4xeFl~x@9skkiL&=JOwbJnY^F$_Kon@9;ZCmjvj2NxQLpDu{-EyPe zD}|iQWGygu>J$k#qV3y*Z;&?JIndWVo{6j$n48pKIj~EiI{mtN37-~q8(lFhsc1QF zCR2E>d8Ziu@he0`_+HF?E#l~Ty~#7N5>v0hfT`$BSbUc8FY&9T#_&5NLlR+>G(i$- K(II`GUi}YOvsBvv delta 355 zcmbO$@|26uiIEws(Vv}PTpX&1f_1xkpNzEpIpdf z$H+c;1Ct`7r$Bqazkk1Z`T2WV9hJ4i$r zERvgAl98WMBt1EUMaESGBn~!76vRSxO%!`oZf0s;ULwRAF^~#zI3WRIDFF%b$tPJ% z*+DEnP5#NYoVm6|k}x?W^NxBQb*vf9_#2OBzWKhroiUOf`y?MZW6wU=NJ!2hY5S23FyNY1Jm*!A z2b>)<2teF15Xe{JR^$T0Ih#Z;l*=Z8%PO^OicVS6y124{x-C7lk%XK>(so7$S|t+w>6v14x}=wQ-yY; zy0Org9XYD(`UZdAd;nYa6`HP{jxVRm$G#4WKC%woO38y5t+ck+0DRAErl2 z;}E;d*0?6^fi=5?4(9dj$LGcT@^mq`C5?50n$rFcHUuo*XcyghpFk}q$QfAzz(e!v~^52Dkf Ar2qf` literal 0 HcmV?d00001 diff --git a/SocialHelper/homepage/migrations/__pycache__/0003_auto_20201210_2008.cpython-37.pyc b/SocialHelper/homepage/migrations/__pycache__/0003_auto_20201210_2008.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fb7dcb87698dd07cb733ff4ccb5fc17d65c6af75 GIT binary patch literal 602 zcmY*Wv2NTj43#X~=QA3hLzDhNfm>4Nx)eoGBmvqqL(}29#5h1uO!n%lY&o($q-(S0 zL$dZ$I%@6IU&s_nmqQQ=B*;gKdZdnbc5+6tYyZkWoUwmC*h);!A!+}L3^3rDHN50a zR7RYgFo-~0GZ4tv;j}hk5=d_ZOl|~aGsx(fshfV;_NT|PAEv=htA0hiL{Qc~Thk^E;;UXDupS|0&+*aEgyjlGR%QkNg;0qrN>#fku&dLjXEx#{p> zX}8SoQ978ruOHtn7w4zTg{f+#Kcl9yr@?js%g41ZX%%mz8V4ii#k@F}9~9&iZ}+<^ z>%TT7?fvg(B8_7n(Fyq3EOt{^t9E7f;UcgOOhfXK)W&;B_g(gWGyexaQ18clF75%P Ch@+4I literal 0 HcmV?d00001 diff --git a/SocialHelper/homepage/models.py b/SocialHelper/homepage/models.py index 5fc349e..f3a9e9c 100644 --- a/SocialHelper/homepage/models.py +++ b/SocialHelper/homepage/models.py @@ -7,6 +7,7 @@ TYPE_T = ( ) class Product(models.Model): + picture = models.ImageField(null=True, blank=True, upload_to="images/") create_date = models.DateField(("Date"), default=datetime.date.today) user_owner = models.TextField(max_length=40, blank=False, default="") type = models.IntegerField(choices = TYPE_T, blank=False, default="") diff --git a/SocialHelper/homepage/templates/homepage/Dodawanie.html b/SocialHelper/homepage/templates/homepage/Dodawanie.html index 5eafb6e..ef6180a 100644 --- a/SocialHelper/homepage/templates/homepage/Dodawanie.html +++ b/SocialHelper/homepage/templates/homepage/Dodawanie.html @@ -16,38 +16,51 @@ -
-
-
-
-
- - -
-
- - -
-
- - -
-
-
- Wybierz zdjęcie - -
-
-
- -
-
-
-
-
+
+ {% csrf_token %} + {{ form.media }} + {{ form.as_p }} +
+
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+ Wybierz zdjęcie + +
+
+
+ +
+ +
+
+
+ diff --git a/SocialHelper/homepage/templates/homepage/Mojeogloszenia.html b/SocialHelper/homepage/templates/homepage/Mojeogloszenia.html index 2e98fa4..381af48 100644 --- a/SocialHelper/homepage/templates/homepage/Mojeogloszenia.html +++ b/SocialHelper/homepage/templates/homepage/Mojeogloszenia.html @@ -30,7 +30,7 @@
- +
diff --git a/SocialHelper/homepage/urls.py b/SocialHelper/homepage/urls.py index 903f398..8d0ddc5 100644 --- a/SocialHelper/homepage/urls.py +++ b/SocialHelper/homepage/urls.py @@ -1,9 +1,13 @@ -from django.urls import path +from django.urls import path, include from . import views +from django.conf import settings +from django.conf.urls.static import static + urlpatterns = [ path('', views.index, name='index'), path('filter', views.filter, name='filter'), path('Dodawanie', views.Dodawanie, name='Dodawanie'), - path('Mojeogloszenia', views.Mojeogloszenia, name='Mojeogloszenia'), -] + path('Mojeogloszenia', views.Mojeogloszenia, name='Mojeogloszenia'), + +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/SocialHelper/homepage/views.py b/SocialHelper/homepage/views.py index 3f1de00..29f189d 100644 --- a/SocialHelper/homepage/views.py +++ b/SocialHelper/homepage/views.py @@ -2,8 +2,14 @@ from django.shortcuts import get_object_or_404, render from django.http import HttpResponse, HttpResponseRedirect from django.urls import reverse from django.template import loader + from .models import Product, TYPE_T +from django.utils import timezone +from datetime import timedelta +import datetime + + def index(request): all_product = Product.objects.all template = loader.get_template('homepage/index.html') @@ -53,10 +59,43 @@ def filter(request): return HttpResponse(template.render(context, request)) def Dodawanie(request): + if request.method == 'POST': + place_local = request.POST['place'] + type_local = request.POST['type'] + script_local = request.POST['script'] + title_local = request.POST['title'] + data_local = timezone.now() + pic_local = request.FILES['file'] + + product = Product( + picture = pic_local, + create_date = data_local, + user_owner = "jedrzejklepacki@wp.pl", + type = int(type_local), + title = title_local, + description = script_local, + place = place_local, + 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 render(request , 'homepage/Dodawanie.html') def Mojeogloszenia(request): - all_product = Product.objects.all + all_product = Product.objects.filter(user_owner = "jedrzejklepacki@wp.pl") template = loader.get_template('homepage/Mojeogloszenia.html') types = TYPE_T place_local = ""