Add public user page
This commit is contained in:
parent
13e4e0fabc
commit
79b29d0d95
51
pflaenzli/templates/user/public.html
Normal file
51
pflaenzli/templates/user/public.html
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
{% block title %}User {{ username }}{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="mb-3">
|
||||||
|
<h1>{{ user.username }}'s Profile</h1>
|
||||||
|
</div>
|
||||||
|
<h2 class="h3">Wishlist</h2>
|
||||||
|
<div class="mb-4">
|
||||||
|
{% if wishes %}
|
||||||
|
<ul class="list-group">
|
||||||
|
{% for wish in wishes %}<li class="list-group-item">{{ wish.title }}</li>{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<div class="alert alert-warning" role="alert">{{ user.username }} has currently no wishes!</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<h2 class="h3">Offers</h2>
|
||||||
|
</div>
|
||||||
|
{% if offers %}
|
||||||
|
<div class="card-deck d-flex justify-content-around justify-content-sm-around justify-content-md-between flex-wrap">
|
||||||
|
{% for offer in offers %}
|
||||||
|
<div class="col">
|
||||||
|
<div class="card h-100 p-0 flex-column justify-content-between">
|
||||||
|
<a href="{% url 'offer_detail' offer.id %}">
|
||||||
|
{% if offer.image %}
|
||||||
|
<img class="card-img-top offer-img" src="{{ offer.image.url }}"/>
|
||||||
|
{% else %}
|
||||||
|
<img class="card-img-top offer-img" src="{% static 'placeholder.jpg' %}" />
|
||||||
|
{% endif %}
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="h5">{{ offer.title }}</h5>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div class="card-footer d-flex justify-content-between">
|
||||||
|
<a href="#">
|
||||||
|
<i class="fas fa-user mt-3"></i> {{ offer.user.username }}
|
||||||
|
</a>
|
||||||
|
<p class="zip">
|
||||||
|
<i class="fas fa-map-marker-alt mt-3"></i> {{ offer.zipcode }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="alert alert-warning" role="alert">There are currently no active offers.</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
|
@ -1,63 +0,0 @@
|
||||||
{% extends 'base.html.twig' %}
|
|
||||||
|
|
||||||
{% block title %}User {{ username }}{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
{% for message in app.flashes('success') %}
|
|
||||||
<div class="alert alert-success" role="alert">
|
|
||||||
{{ message }}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<h1>{{ username }}'s Wishlist</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-4">
|
|
||||||
{% if wishes == [] %}
|
|
||||||
<div class="alert alert-warning" role="alert">
|
|
||||||
There are currently no wishes!
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<ul class="list-group">
|
|
||||||
{% for wish in wishes %}
|
|
||||||
<li class="list-group-item"> {{ wish.title }}</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
<div class="mb-3">
|
|
||||||
<h1>{{ username }}'s Offers</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if offers|length > 0 %}
|
|
||||||
<div class="card-deck d-flex justify-content-around justify-content-sm-around justify-content-md-between flex-wrap">
|
|
||||||
{% for offer in offers %}
|
|
||||||
<div class="mb-5">
|
|
||||||
<div class="card offer h-100">
|
|
||||||
<a href="{{ path('show_offer', {'urlId': offer.urlId }) }}">
|
|
||||||
{% if offer.photoFilename %}
|
|
||||||
<img class="card-img-top offer-img" src="{{ asset('uploads/photos/' ~ offer.photofilename) }}" />
|
|
||||||
{% else %}
|
|
||||||
<img class="card-img-top offer-img" src="{{ asset('placeholder.jpg') }}" />
|
|
||||||
{% endif %}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">{{ offer.title }}</h5>
|
|
||||||
<p class="card-text">{{ offer.description }}</p>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
<div class="card-footer offer-footer">
|
|
||||||
<a class="user-link" href="{{ path('user_public', { 'urlId': offer.byuser.id }) }}">
|
|
||||||
<p class="username"><i class="fas fa-user mt-3"></i> {{ offer.byUser }}</p>
|
|
||||||
</a>
|
|
||||||
<p class="zip"><i class="fas fa-map-marker-alt mt-3"></i> {{ offer.zipCode }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<div class="alert alert-warning" role="alert">There are currently no active offers.</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
|
@ -12,7 +12,8 @@ urlpatterns = [
|
||||||
path("offer/<int:offer_id>/", views.offer_detail, name="offer_detail"),
|
path("offer/<int:offer_id>/", views.offer_detail, name="offer_detail"),
|
||||||
path("offer/<int:offer_id>/delete/", views.offer_delete, name="offer_delete"),
|
path("offer/<int:offer_id>/delete/", views.offer_delete, name="offer_delete"),
|
||||||
path("offer/<int:offer_id>/edit/", views.offer_edit, name="offer_edit"),
|
path("offer/<int:offer_id>/edit/", views.offer_edit, name="offer_edit"),
|
||||||
path("offer/<int:offer_id>/trade", views.offer_trade, name="offer_trade"),
|
path("offer/<int:offer_id>/trade/", views.offer_trade, name="offer_trade"),
|
||||||
|
path("user/<int:user_id>", views.user_detail, name="user_detail"),
|
||||||
path('accounts/login/', auth_views.LoginView.as_view(template_name='registration/login.html')),
|
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/profile/', auth_views.LoginView.as_view(template_name='user/detail.html')),
|
||||||
path('accounts/', include('django.contrib.auth.urls')),
|
path('accounts/', include('django.contrib.auth.urls')),
|
||||||
|
|
|
@ -78,3 +78,11 @@ def offer_edit(request, offer_id):
|
||||||
@ login_required
|
@ login_required
|
||||||
def offer_trade(request, offer_id):
|
def offer_trade(request, offer_id):
|
||||||
return 0
|
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})
|
||||||
|
|
Loading…
Reference in a new issue