Add view for not refunded payments
This commit is contained in:
parent
8caa7ed902
commit
c128e5b524
7 changed files with 45 additions and 3 deletions
22
refunding/templates/refunding/payments_list.html
Normal file
22
refunding/templates/refunding/payments_list.html
Normal 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
6
refunding/urls.py
Normal 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'),
|
||||
]
|
|
@ -1,3 +1,16 @@
|
|||
from django.contrib.auth.decorators import login_required
|
||||
from django.db.models import Sum
|
||||
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)
|
||||
|
|
|
@ -22,4 +22,5 @@ urlpatterns = [
|
|||
url(r'^auth/', include('authentication.urls')),
|
||||
url(r'^$', home, name='home'),
|
||||
url(r'^about/$', about, name='about'),
|
||||
url(r'^', include('refunding.urls'))
|
||||
]
|
||||
|
|
|
@ -2,8 +2,8 @@ from django.shortcuts import render
|
|||
|
||||
|
||||
def home(request):
|
||||
return render(request, "blog/home.html")
|
||||
return render(request, "refunds/home.html")
|
||||
|
||||
|
||||
def about(request):
|
||||
return render(request, "blog/about.html")
|
||||
return render(request, "refunds/about.html")
|
||||
|
|
Loading…
Reference in a new issue