diff --git a/SocialHelper/homepage/__pycache__/admin.cpython-37.pyc b/SocialHelper/homepage/__pycache__/admin.cpython-37.pyc index f2e69fb..c18d539 100644 Binary files a/SocialHelper/homepage/__pycache__/admin.cpython-37.pyc and b/SocialHelper/homepage/__pycache__/admin.cpython-37.pyc differ diff --git a/SocialHelper/homepage/__pycache__/urls.cpython-37.pyc b/SocialHelper/homepage/__pycache__/urls.cpython-37.pyc index 00e5188..f930713 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 36c4abb..3e3f4eb 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/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))