Skip to content
Snippets Groups Projects
Commit 66b70e69 authored by shirenn's avatar shirenn 🌊
Browse files

Add transaction history list on the user

parent a456468a
No related branches found
No related tags found
1 merge request!4Transaction history
Pipeline #7662 passed with stage
in 3 minutes and 29 seconds
......@@ -9,9 +9,11 @@ from django.views.generic import CreateView, ListView, DetailView
from django.http import HttpResponseRedirect
from django.contrib.auth.forms import UserCreationForm
from django.urls import reverse_lazy
from django.db.models import Q
from .models import Profile, Club
from .forms import ProfileForm, ClubForm
from note.models.transactions import Transaction
class UserCreateView(CreateView):
"""
......@@ -39,9 +41,16 @@ class UserCreateView(CreateView):
return super().form_valid(form)
class UserDetailView(LoginRequiredMixin,DetailView):
model = Profile
def get_context_data(slef,**kwargs):
context = super().get_context_data(**kwargs)
user = context['object'].user.note
user_transactions = \
Transaction.objects.all().filter(Q(source=user) | Q(destination=user))
context['history_list'] = user_transactions
return context
class ClubCreateView(LoginRequiredMixin,CreateView):
......
{% extends "base.html" %}
{% load i18n static pretty_money %}
{% load i18n static pretty_money django_tables2 %}
{% block content %}
<h3>Compte n° {{ object.pk }}</h3>
......@@ -24,4 +24,6 @@
</dl>
<a href="{% url "password_change" %}">{% trans 'Change password' %}</a>
{% render_table history_list %}
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment