From 799b05b2a2b4ed21607c2f9bdcccf4ed3d272a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Klepacki?= Date: Fri, 1 Jan 2021 18:42:53 +0100 Subject: [PATCH] wyswietlanie oceny i komentarzy --- .../homepage/__pycache__/admin.cpython-37.pyc | Bin 285 -> 315 bytes .../homepage/__pycache__/urls.cpython-37.pyc | Bin 1049 -> 1114 bytes .../homepage/__pycache__/views.cpython-37.pyc | Bin 9594 -> 10200 bytes SocialHelper/homepage/admin.py | 3 +- .../homepage/templates/homepage/index.html | 12 +- .../templates/homepage/user_profile.html | 216 ++++++++++++++++++ SocialHelper/homepage/urls.py | 1 + SocialHelper/homepage/views.py | 29 ++- 8 files changed, 254 insertions(+), 7 deletions(-) create mode 100644 SocialHelper/homepage/templates/homepage/user_profile.html diff --git a/SocialHelper/homepage/__pycache__/admin.cpython-37.pyc b/SocialHelper/homepage/__pycache__/admin.cpython-37.pyc index f2e69fb3f2d8928970ebb22a4400188615f0e288..c18d5397cd2c3d79f53d34cb8f78b59af4875382 100644 GIT binary patch delta 129 zcmbQsw3~_7iIhdn)rnMmU=ViOo7O zN=}CP7JEQZeoAR_$t|{koW$hR;#;i#$*FmXewrK;d)1kW*d}fiV*^=H#5M7(8xIGN N#ltAV#KXwL2mmYGA7ual delta 117 zcmdnZG?$6jiIgVwRjJ(=GOZ zqWqN7=T!$OWtBB&MZm2#Zi=+o>^RyTC|d(h!bdT5$D90Zd`0Y L77wEU6AvQ*Apjpp diff --git a/SocialHelper/homepage/__pycache__/urls.cpython-37.pyc b/SocialHelper/homepage/__pycache__/urls.cpython-37.pyc index 00e518864983b047a99a1c58a85832d2fc610ea1..f930713ba04aa1e3c24a63a6cc6d115322dcb4e0 100644 GIT binary patch delta 192 zcmbQqaf?IUiIOC zSR^koH`VSI53;N#<1OBl{N&Qy)Vz}TqWt_4KTVm*x0&WJ70FC4Vb)?(0Xm{cW%3ec QS4O?bub6dN_!tG409tr6SO5S3 delta 114 zcmcb`F_S~xiInSTaSn zmr0xL{ Dsbdwo diff --git a/SocialHelper/homepage/__pycache__/views.cpython-37.pyc b/SocialHelper/homepage/__pycache__/views.cpython-37.pyc index 36c4abbcbc3c524444430a50657d1762c7baf8ee..3e3f4eb789e9ec2a4448c2c3d557e8798951c56e 100644 GIT binary patch delta 3161 zcmchZO>7&-6~}j$DN)qd%93KajT1Sl!q}T zT-6^U%b;#4t^1wQCnErRpW>)^&o$#In2)YO`S( z2%84NYlab9U1a3d@S@>GRlXNaGemS~L-Kdha;!hiFQ76l93@F zMbEaBAxx~&s;*wEiX+&Mxqj!)jwKT4guG+@{1YWJpO_z5+NfC0c8!bYs3ZD;Ll_Ro z?O6Y79p{u^pOw4$;N42es#c3#*>y09uyR)ZCU${k+sXJQ>&1p{@NH4MRkwu5$@i)L z7v&Fn#*GE&j>zBk?9F}w&0|0gP%~eqmK)_(eN&WnoDzj*RaSdnAICYlzM^f5r=fcs zcmYtZ9hQIUJ&`*9PlE5h=_FnrMSMKf|t_8Y5BWDUou|8#DW|gc&VjQ`K##fpR^c2 z_Z-j(mh$2P#*`PYq4hFw26!FF0sH46UO^YRD$W8b7Ag$;5jT6qC6!OtpztQp@k%+V zqONl64a}lK#bw|Mp!~avRvzfC`Q^bI>@Ar~jkJF{_$f0~h*sp!hOV*^*+0C_R@zsG zf6WY4peu5A)M_bL<5)*2AMn?!c$#$$>vpN`)Lox#Rh3h2tZq4lonpOyt0uU2(j6DQ zd~*G7Af;EZd=YpX*u;84Ztrf@>M}Z(9#mP{vYbri z_iggB8o|&IB_nKe1wz~GbC}ZwM`_g!d zu@lmnnDP=)eW_Fw)DE|y)ycsCx@x}zr&Ghk4$#Rml(hM{nr~w2F3HyCI4*+btWt?6_87~y)uR}OIBeZA>-45fp<|2}I5oZ!O{4?JQ`!wENoPNW&) zMl;NV&B*PUM&L#5TDlo^qK#Jg9%EV~+=!NALs~Q3i0~lE$j$s^j7G*V7UrP=l1{uq z+SK#TNmULE`S{cCBLV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)W_&x>X0hwBu{~8#Nj=^pNYHyKHDUS;HyI8CO11RBz3#{dlC)SRqT%+99ycRQbUO<`k*=enlr zvTrZJe)O!Y3+5>x56JUn$Y)?WfYZQn;8|b>_iwQT;}|!ylQ~W%jS6= z4wr#uRx(LhV%bo0*gXf#1Lpym-vwwFf!4|$4c{aSjm>b_?vmk;@=v=j5`|}!DKgs7 zl~0IEPU0vZ@73ygeC`9b%heifv1_`t+ohUOGuw2nA`>#bHO*L9Db{MYs*GAs+Dy-C z9Mf?Qy*rBIuL4EjntJqe;#?zfd-gT2^-;eqcQ8* zFunsTro+kdL~LUmeQzJjmarAo~xR*Zu0p|Vh2S`s

=|By8U&Vs>jG=RR6gCG z85qo|>vu0*J~VNdm9TfCQA)%J8RM@c`?t%K-GWyhkniP$ChyzQr4?*cfoAt%uGNPl zjbzy!U>$f7xC_Xlz5tD9Qa!;f&vK8?rp}Xl{N2>+F{``ac~xLejB#t?m;2@~CZ1Y!uoxz3-(P6zu^R%rE!aeENQnT=v6Dc2&SRb{-%RfvfU3K9l{s+knd|NlY z^hU9=T-~#3l=K=4iygC_ivK~3QdwiWa2!rzyMaBxUSJ;}J6ks0G|Vf&0ziQ^;2wbM nTBcD(lM`!Z`=M01N>_Dlf(WyQjJik{2@>za-=JOLjcoc)==Rzu diff --git a/SocialHelper/homepage/admin.py b/SocialHelper/homepage/admin.py index 0699f4d..32076e1 100644 --- a/SocialHelper/homepage/admin.py +++ b/SocialHelper/homepage/admin.py @@ -1,5 +1,6 @@ from django.contrib import admin -from .models import Product, Places +from .models import Product, Places, Ocena admin.site.register(Product) admin.site.register(Places) +admin.site.register(Ocena) diff --git a/SocialHelper/homepage/templates/homepage/index.html b/SocialHelper/homepage/templates/homepage/index.html index 39cccf0..af42210 100644 --- a/SocialHelper/homepage/templates/homepage/index.html +++ b/SocialHelper/homepage/templates/homepage/index.html @@ -47,17 +47,19 @@

{{ product.title }}

+
{{ product.user_iden }}
+
{% if types.0.0 == product.type %} -
Potrzebuje + Potrzebuje {% else %} -
Oddam + Oddam {% endif %} {% if types_o.0.0 == product.offer %} - Usługa
+ Usługa {% else %} - Przedmiot - {% endif %} + Przedmiot + {% endif %}
Z miejscowości: {{ product.place }}

{{ product.description }}

diff --git a/SocialHelper/homepage/templates/homepage/user_profile.html b/SocialHelper/homepage/templates/homepage/user_profile.html new file mode 100644 index 0000000..45eb34a --- /dev/null +++ b/SocialHelper/homepage/templates/homepage/user_profile.html @@ -0,0 +1,216 @@ +{% extends 'base.html' %} +{% load static %} +{% block content %} + + + + + +
+
+
+

Profil użytkownika

+
{{ name }}
+ Neutralne
+ +
+
+
+ + + + + +
+
+ + + +
+
+ +
+
+
+ + +
+ {% if all_product %} + {% for product in all_product %} +
+
+
+
+ +
+
+
+
+

{{ product.title }}

+ {% if types.0.0 == product.type %} +
Potrzebuje + {% else %} +
Oddam + {% endif %} + {% if types_o.0.0 == product.offer %} + Usługa
+ + + {% else %} + Przedmiot + + + {% endif %} +
Z miejscowości: {{ product.place }}
+

{{ product.description }}

+
+
+
+
+ {% endfor %} + {% else %} +

No polls are available.

+ {% endif %} +
+
+ +
+ {% csrf_token %} + + + + +
+
+
+ +
+
+
+
+
+ + +
+ {% if all_oceny %} + {% for ocen_jed in all_oceny %} +
+
+ {{ocen_jed.comm}} + {{ocen_jed.ocena_jedn}} +
+
+ {% endfor %} + {% else %} +

No polls are available.

+ {% endif %} +
+
+ +
+ {% csrf_token %} + + + + +
+
+
+ +
+ + +
+
+ + + + + + + + {% endblock %} diff --git a/SocialHelper/homepage/urls.py b/SocialHelper/homepage/urls.py index d9246cb..83a3868 100644 --- a/SocialHelper/homepage/urls.py +++ b/SocialHelper/homepage/urls.py @@ -25,5 +25,6 @@ urlpatterns = [ path('logout_user', views.logout_user, name='logout_user'), path('/delete_user', views.delete_user, name='delete_user'), path('edit_user', views.edit_user, name='edit_user'), + path('user_profile/', views.user_profile, name='user_profile'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/SocialHelper/homepage/views.py b/SocialHelper/homepage/views.py index 0d132ab..a0bc753 100644 --- a/SocialHelper/homepage/views.py +++ b/SocialHelper/homepage/views.py @@ -7,7 +7,7 @@ from django.template import loader from django.contrib.auth import get_user_model from django.contrib import messages, auth -from .models import Product, TYPE_T, TYPE_O, Places +from .models import Product, TYPE_T, TYPE_O, Places, Ocena from django.utils import timezone from datetime import timedelta @@ -424,3 +424,30 @@ def logout_user(request): auth.logout(request) messages.success(request, 'Zostałeś wylogowany!') return redirect( index) + +def user_profile(request, user_name): + User = get_user_model() + user_prof = User.objects.filter(username=user_name).first() + + all_product = Product.objects.filter(active = True, user_iden = user_prof.id) + oceny = Ocena.objects.filter(user_iden = user_prof.id) + template = loader.get_template('homepage/user_profile.html') + + types = TYPE_T + types_o = TYPE_O + ocena = 5 + suma = 1 + for ocena_j in oceny: + print(ocena) + ocena = ocena + ocena_j.ocena_jedn + suma = suma + 1 + ocena = ocena / suma + ocena = ocena * 10 + ocena = int (ocena) + context = { + 'all_product': all_product, + 'all_oceny': oceny, + 'ocena': ocena, + 'name': user_prof.email, + } + return HttpResponse(template.render(context, request))