Commit 94cf427a authored by rexxnor's avatar rexxnor

moved reports to admin site

parent 4178be06
......@@ -3,7 +3,10 @@ Settings for the Admin interface
"""
from django.contrib import admin
from django.urls import path
from django.conf.urls import url
from .models import Card, Transaction, Charge, Report
from prepaid import views
# Register your models here.
class CardAdmin(admin.ModelAdmin):
......@@ -30,7 +33,31 @@ class ReportAdmin(admin.ModelAdmin):
"""
Customize the Charge Listing in Admin interface
"""
list_display = ('report_id', 'date_time', 'previous_date_time', 'totalspent', 'totalcharged', 'currentcharge')
readonly_fields = ('report_id',)
list_display = ('report_id',
'date_time',
'previous_date_time',
'totalspent',
'totalcharged',
'currentcharge')
def get_urls(self):
"""
Overwrite the general urls for this model
"""
urls = super().get_urls()
my_urls = [
url('currentreport/',
self.admin_site.admin_view(views.CurrentReport.as_view())),
path('monthlyreport/<int:year>/<int:month>/',
self.admin_site.admin_view(views.MonthView.as_view())),
path('yearlyreport/<int:year>/',
self.admin_site.admin_view(views.YearView.as_view())),
path('periodreport/<int:report_id>/',
self.admin_site.admin_view(views.PeriodReport.as_view())),
]
return my_urls + urls
admin.site.register(Card, CardAdmin)
admin.site.register(Transaction, TransactionAdmin)
......
<!doctype html>
<html lang="en">
<head>
<title>Charge Archive</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="../static/css/bootstrap.css " >
<script charset="utf-8" src="../static/js/search2json.js" defer></script>
<script charset="utf-8" src="../static/js/failure.js" defer></script>
</head>
<body>
<div class="container col-md-8">
<br />
<h1>Report of all charges ever</h1>
<div class="row">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Date Time</th>
<th>Card</th>
<th>Amount</th>
<th>Currency</th>
</tr>
</thead>
<tbody>
{% for charge in latest %}
<tr>
<td>{{ charge.date_time|date:"Y-m-d H:i"}}</td>
<td>{{ charge.owner_id.owner_id }}</td>
<td>{{ charge.amount.amount }}</td>
<td>{{ charge.amount.currency }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<title>Report Archive</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="../static/css/bootstrap.css " >
<script charset="utf-8" src="../static/js/search2json.js" defer></script>
<script charset="utf-8" src="../static/js/failure.js" defer></script>
</head>
<body>
<div class="container col-md-8">
<br />
<h1>Report of all transactions ever</h1>
<div class="row">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Report ID</th>
<th>Date Time</th>
<th>Total Charge</th>
<th>Currency</th>
<th>Total Transactions</th>
<th>Currency</th>
<th>Total Balance on all Cards</th>
<th>Currency</th>
</tr>
</thead>
<tbody>
{% for report in latest %}
<tr onclick="window.location='../periodreport/{{report.report_id}}'">
<td>{{ report.report_id }}</td>
<td>{{ report.date_time|date:"Y-m-d H:i"}}</td>
<td>{{ report.totalcharged.amount }}</td>
<td>{{ report.totalcharged.currency }}</td>
<td>{{ report.totalspent.amount }}</td>
<td>{{ report.totalspent.currency }}</td>
<td>{{ report.currentcharge.amount }}</td>
<td>{{ report.currentcharge.currency }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<title>Transaction Archive</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="../static/css/bootstrap.css " >
<script charset="utf-8" src="../static/js/search2json.js" defer></script>
<script charset="utf-8" src="../static/js/failure.js" defer></script>
</head>
<body>
<div class="container col-md-8">
<br />
<h1>Report of all transactions ever</h1>
<div class="row">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Date Time</th>
<th>Card</th>
<th>Amount</th>
<th>Currency</th>
</tr>
</thead>
<tbody>
{% for transaction in latest %}
<tr>
<td>{{ transaction.date_time|date:"Y-m-d H:i"}}</td>
<td>{{ transaction.owner_id.owner_id }}</td>
<td>{{ transaction.amount.amount }}</td>
<td>{{ transaction.amount.currency }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</body>
</html>
......@@ -8,7 +8,6 @@ from django.views.generic.dates import ArchiveIndexView
from prepaid import views
from prepaid.models import Transaction, Charge, Card, Report
urlpatterns = [
url(r'^chargecard/$', views.chargecard),
url(r'^checkbalance/$', views.checkbalance),
......@@ -22,22 +21,5 @@ urlpatterns = [
url(r'^error/$', views.error),
url(r'^priceentry/$', views.priceentry),
url(r'^checkbal/$', views.checkbal),
# reports
url(r'^currentreport/$', views.CurrentReport.as_view()),
path('monthlyreport/<int:year>/<int:month>/',
views.MonthView.as_view(month_format='%B', year_format='%Y')),
path('yearlyreport/<int:year>/',
views.YearView.as_view(year_format='%Y')),
path('periodreport/<int:report_id>/',
views.PeriodReport.as_view()),
# archives which are probably unnecessary as already viewable in admin
path('transactionarchive/',
ArchiveIndexView.as_view(model=Transaction, date_field="date_time"),
name="transaction_archive"),
path('chargearchive/',
ArchiveIndexView.as_view(model=Charge, date_field="date_time"),
name="charge_archive"),
path('reportarchive/',
ArchiveIndexView.as_view(model=Report, date_field="date_time"),
name="report_archive"),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
......@@ -136,4 +136,3 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment