diff --git a/apps/transactions/templates/show.html b/apps/transactions/templates/show.html index 71566fc..feb139b 100644 --- a/apps/transactions/templates/show.html +++ b/apps/transactions/templates/show.html @@ -8,7 +8,7 @@
Import from Bitcoin.de

-
Export Transactions
+
Export Transactions

diff --git a/apps/transactions/views.py b/apps/transactions/views.py index 421f11b..58f2d75 100644 --- a/apps/transactions/views.py +++ b/apps/transactions/views.py @@ -47,7 +47,12 @@ def importbtcde(request): @login_required def show(request): if 'crypto' in request.GET: - transactions = Transaction.objects.filter(owner=request.user, crypto_currency=request.GET['crypto']).order_by('-date_valid').annotate(crypto_total=Value(0.0), fiat_total=Value(0.0)) + crypto = request.GET['crypto'] + else: + crypto = None + + if crypto: + transactions = Transaction.objects.filter(owner=request.user, crypto_currency=crypto).order_by('-date_valid').annotate(crypto_total=Value(0.0), fiat_total=Value(0.0)) else: transactions = Transaction.objects.filter(owner=request.user).order_by('-date_valid').annotate(crypto_total=Value(0.0), fiat_total=Value(0.0)) for tr in transactions: @@ -61,14 +66,19 @@ def show(request): tr.fiat_total += float(tr.fiat_amount) if tr.fiat_fee: tr.fiat_total += float(tr.fiat_fee) - return render(request,"show.html",{'transactions':transactions}) + return render(request,"show.html",{'transactions':transactions, 'crypto': crypto}) @login_required def export(request): if 'crypto' in request.GET: - filename="transactions-"+request.GET['crypto']+".xls" - transactions = Transaction.objects.filter(owner=request.user, crypto_currency=request.GET['crypto']).order_by('-date_valid') + crypto = request.GET['crypto'] + else: + crypto = None + + if crypto: + filename="transactions-"+crypto+".xls" + transactions = Transaction.objects.filter(owner=request.user, crypto_currency=crypto).order_by('-date_valid') else: transactions = Transaction.objects.filter(owner=request.user).order_by('-date_valid') filename="transactions.xls"