use accordion + history table for profil view

This commit is contained in:
Pierre-antoine Comby 2019-08-15 23:11:16 +02:00
parent a84031405e
commit be8f2dc35b
2 changed files with 46 additions and 8 deletions

View File

@ -47,13 +47,17 @@ class UserCreateView(CreateView):
class UserDetailView(LoginRequiredMixin,DetailView): class UserDetailView(LoginRequiredMixin,DetailView):
model = Profile model = Profile
context_object_name = "profile"
def get_context_data(slef,**kwargs): def get_context_data(slef,**kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
user = context['object'].user.note user = context['profile'].user
user_transactions = \
Transaction.objects.all().filter(Q(source=user) | Q(destination=user)) history_list = \
context['history_list'] = user_transactions Transaction.objects.all().filter(Q(source=user.note) | Q(destination=user.note))
context['history_list'] = HistoryTable(history_list)
club_list = \
Membership.objects.all().filter(user=user).only("club")
context['club_list'] = ClubTable(club_list)
return context return context

View File

@ -23,7 +23,41 @@
<dd class="col-6 col-md-3">{{ object.user.note.balance | pretty_money }}</dd> <dd class="col-6 col-md-3">{{ object.user.note.balance | pretty_money }}</dd>
</dl> </dl>
<a href="{% url "password_change" %}">{% trans 'Change password' %}</a> <a class="btn btn-primary" href="{% url 'password_change' %}">{% trans 'Change password' %}</a>
<div class="accordion" id="accordionExample">
<div class="card">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
<i class="fa fa-users"></i> {% trans "View my memberships" %}
</button>
</h5>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample">
<div class="card-body">
{% render_table club_list %}
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingTwo">
<h5 class="mb-0">
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
<i class="fa fa-euro"></i> Historique des transactions
</button>
</h5>
</div>
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionExample">
<div class="card-body">
{% render_table history_list %} {% render_table history_list %}
</div>
</div>
</div>
</div>
{% endblock %} {% endblock %}