diff --git a/pflaenzli/templates/user/public.html b/pflaenzli/templates/user/public.html new file mode 100644 index 0000000..f3063c7 --- /dev/null +++ b/pflaenzli/templates/user/public.html @@ -0,0 +1,51 @@ +{% extends "base.html" %} +{% load static %} +{% block title %}User {{ username }}{% endblock %} +{% block content %} +
+

{{ user.username }}'s Profile

+
+

Wishlist

+
+ {% if wishes %} + + {% else %} + + {% endif %} +
+
+

Offers

+
+ {% if offers %} +
+ {% for offer in offers %} +
+ +
+ {% endfor %} +
+ {% else %} + + {% endif %} +{% endblock %} diff --git a/pflaenzli/templates/user/public.html.twig b/pflaenzli/templates/user/public.html.twig deleted file mode 100644 index 6b65b83..0000000 --- a/pflaenzli/templates/user/public.html.twig +++ /dev/null @@ -1,63 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}User {{ username }}{% endblock %} - -{% block content %} - {% for message in app.flashes('success') %} - - {% endfor %} - -
-

{{ username }}'s Wishlist

-
- -
- {% if wishes == [] %} - - {% else %} - - {% endif %} -
-
-
-

{{ username }}'s Offers

-
- - {% if offers|length > 0 %} -
- {% for offer in offers %} -
- -
- {% endfor %} -
- {% else %} - - {% endif %} -{% endblock %} \ No newline at end of file diff --git a/pflaenzli/urls.py b/pflaenzli/urls.py index 19c1835..cb6b1e6 100644 --- a/pflaenzli/urls.py +++ b/pflaenzli/urls.py @@ -12,7 +12,8 @@ urlpatterns = [ path("offer//", views.offer_detail, name="offer_detail"), path("offer//delete/", views.offer_delete, name="offer_delete"), path("offer//edit/", views.offer_edit, name="offer_edit"), - path("offer//trade", views.offer_trade, name="offer_trade"), + path("offer//trade/", views.offer_trade, name="offer_trade"), + path("user/", views.user_detail, name="user_detail"), path('accounts/login/', auth_views.LoginView.as_view(template_name='registration/login.html')), path('accounts/profile/', auth_views.LoginView.as_view(template_name='user/detail.html')), path('accounts/', include('django.contrib.auth.urls')), diff --git a/pflaenzli/views.py b/pflaenzli/views.py index cc92d4e..b19d033 100644 --- a/pflaenzli/views.py +++ b/pflaenzli/views.py @@ -78,3 +78,11 @@ def offer_edit(request, offer_id): @ login_required def offer_trade(request, offer_id): return 0 + + +def user_detail(request, user_id): + user = get_object_or_404(User, id=user_id) + offers = Offer.objects.filter(user=user_id) + wishes = Wish.objects.filter(user=user_id) + + return render(request, "user/public.html", {"user": user, "offers": offers, "wishes": wishes})