on exception return empty graph

This commit is contained in:
2022-07-05 16:40:01 +02:00
parent d7ad61557b
commit b21d794b87
+5
View File
@@ -1,6 +1,7 @@
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.conf import settings from django.conf import settings
from django.http import HttpResponse
import pytz import pytz
from apps.transactions.models import Transaction from apps.transactions.models import Transaction
from apps.rates.models import ExchangeRate from apps.rates.models import ExchangeRate
@@ -45,6 +46,7 @@ def graph(request):
Crypto = request.GET['crypto'] Crypto = request.GET['crypto']
Fiat = request.GET['fiat'] Fiat = request.GET['fiat']
try:
if Crypto == "WALLET": if Crypto == "WALLET":
if 'number_of_days' in request.GET: if 'number_of_days' in request.GET:
return Graph().wallet_graph_days(request.user.id, Fiat, request.GET['number_of_days']) return Graph().wallet_graph_days(request.user.id, Fiat, request.GET['number_of_days'])
@@ -53,3 +55,6 @@ def graph(request):
return Graph().graph_days(Crypto, Fiat, request.GET['number_of_days']) return Graph().graph_days(Crypto, Fiat, request.GET['number_of_days'])
if 'number_of_hours' in request.GET: if 'number_of_hours' in request.GET:
return Graph().graph_hours(Crypto, Fiat, request.GET['number_of_hours']) return Graph().graph_hours(Crypto, Fiat, request.GET['number_of_hours'])
except:
response = HttpResponse(content_type = 'image/png')
return response