mirror of https://gitlab.crans.org/bde/nk20
Merge branch 'transaction_history' into 'master'
Transaction history See merge request bde/nk20!4
This commit is contained in:
commit
55884f013a
|
@ -9,9 +9,11 @@ from django.views.generic import CreateView, ListView, DetailView
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.contrib.auth.forms import UserCreationForm
|
from django.contrib.auth.forms import UserCreationForm
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
|
from django.db.models import Q
|
||||||
|
|
||||||
from .models import Profile, Club
|
from .models import Profile, Club
|
||||||
from .forms import ProfileForm, ClubForm
|
from .forms import ProfileForm, ClubForm
|
||||||
|
from note.models.transactions import Transaction
|
||||||
|
|
||||||
class UserCreateView(CreateView):
|
class UserCreateView(CreateView):
|
||||||
"""
|
"""
|
||||||
|
@ -39,10 +41,17 @@ class UserCreateView(CreateView):
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class UserDetailView(LoginRequiredMixin,DetailView):
|
class UserDetailView(LoginRequiredMixin,DetailView):
|
||||||
model = Profile
|
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):
|
class ClubCreateView(LoginRequiredMixin,CreateView):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
|
||||||
|
def pretty_money(value):
|
||||||
|
if value%100 == 0:
|
||||||
|
return str(value//100) + '€'
|
||||||
|
else:
|
||||||
|
return str(value//100) + '€ ' + str(value%100)
|
||||||
|
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
register.filter('pretty_money', pretty_money)
|
|
@ -1,5 +1,5 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load i18n static %}
|
{% load i18n static pretty_money django_tables2 %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h3>Compte n° {{ object.pk }}</h3>
|
<h3>Compte n° {{ object.pk }}</h3>
|
||||||
|
@ -20,8 +20,10 @@
|
||||||
<dt class="col-6 col-md-3">{% trans 'address'|capfirst %}</dt>
|
<dt class="col-6 col-md-3">{% trans 'address'|capfirst %}</dt>
|
||||||
<dd class="col-6 col-md-3">{{ object.address }}</dd>
|
<dd class="col-6 col-md-3">{{ object.address }}</dd>
|
||||||
<dt class="col-6 col-md-3">{% trans 'balance'|capfirst %}</dt>
|
<dt class="col-6 col-md-3">{% trans 'balance'|capfirst %}</dt>
|
||||||
<dd class="col-6 col-md-3">{{ object.user.note.balance }}</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 href="{% url "password_change" %}">{% trans 'Change password' %}</a>
|
||||||
|
|
||||||
|
{% render_table history_list %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue