|
|
@ -1,5 +1,6 @@ |
|
|
from django.contrib.auth.decorators import login_required |
|
|
from django.contrib.auth.decorators import login_required |
|
|
from django.shortcuts import render, get_object_or_404, redirect |
|
|
from django.shortcuts import render, get_object_or_404, redirect |
|
|
|
|
|
from django.http import JsonResponse |
|
|
|
|
|
|
|
|
# Create your views here. |
|
|
# Create your views here. |
|
|
from .models import Cuenta, Apunte, Tipo |
|
|
from .models import Cuenta, Apunte, Tipo |
|
|
@ -127,3 +128,22 @@ def eliminar_apunte(request, apunte_id): |
|
|
apunte = Apunte.objects.get(pk=apunte_id) |
|
|
apunte = Apunte.objects.get(pk=apunte_id) |
|
|
apunte.delete() |
|
|
apunte.delete() |
|
|
return redirect('lista_apuntes') |
|
|
return redirect('lista_apuntes') |
|
|
|
|
|
|
|
|
|
|
|
@login_required |
|
|
|
|
|
def chart_data(request): |
|
|
|
|
|
datos = Cuenta.objects.all() |
|
|
|
|
|
|
|
|
|
|
|
etiquetas = [item.nombre for item in datos] |
|
|
|
|
|
valores = [item.saldo_actual for item in datos] |
|
|
|
|
|
|
|
|
|
|
|
chart_data = { |
|
|
|
|
|
'label': 'Gráfico', |
|
|
|
|
|
'labels': etiquetas, |
|
|
|
|
|
'values': valores, |
|
|
|
|
|
'chart_type': 'bar' # any chart type line, bar, ects |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return JsonResponse(chart_data) |
|
|
|
|
|
|
|
|
|
|
|
def chart_view(request): |
|
|
|
|
|
return render(request, 'apuntes/chart.html') |