Add view for not refunded payments

This commit is contained in:
Gabriel Augendre 2016-06-04 01:49:24 +02:00
parent 8caa7ed902
commit c128e5b524
No known key found for this signature in database
GPG key ID: D2B6A5B41FC438B1
7 changed files with 45 additions and 3 deletions

View file

@ -0,0 +1,22 @@
{% extends 'base.html' %}
{% load l10n %}
{% block content %}
<h1>{% block title %}Payments to refund{% endblock %}</h1>
{% if payments %}
<p>
Total : {{ sum }}€
</p>
<div class="list-group">
{% for payment in payments %}
<div class="list-group-item">
{{ payment.title }} le {{ payment.date|date:"SHORT_DATE_FORMAT" }} : {{ payment.eur_value }}€
</div>
{% endfor %}
</div>
{% else %}
<p>
{% firstof default_nothing "Nothing here..." %}
</p>
{% endif %}
{% endblock %}

6
refunding/urls.py Normal file
View file

@ -0,0 +1,6 @@
from django.conf.urls import url
from refunding.views import not_refunded_payments
urlpatterns = [
url(r'^payments/$', not_refunded_payments, name='not_refunded_payments'),
]

View file

@ -1,3 +1,16 @@
from django.contrib.auth.decorators import login_required
from django.db.models import Sum
from django.shortcuts import render from django.shortcuts import render
from refunding.models import Payment
# Create your views here.
@login_required
def not_refunded_payments(request):
payments = Payment.objects.filter(refund=None)
sum = payments.aggregate(Sum('value')).get('value__sum') / 100
context = {
'payments': payments,
'sum': sum,
'default_nothing': 'No payment to be refunded.'
}
return render(request, "refunding/payments_list.html", context)

View file

@ -22,4 +22,5 @@ urlpatterns = [
url(r'^auth/', include('authentication.urls')), url(r'^auth/', include('authentication.urls')),
url(r'^$', home, name='home'), url(r'^$', home, name='home'),
url(r'^about/$', about, name='about'), url(r'^about/$', about, name='about'),
url(r'^', include('refunding.urls'))
] ]

View file

@ -2,8 +2,8 @@ from django.shortcuts import render
def home(request): def home(request):
return render(request, "blog/home.html") return render(request, "refunds/home.html")
def about(request): def about(request):
return render(request, "blog/about.html") return render(request, "refunds/about.html")