Merge branch 'qwann/k-fet/stats' of git.eleves.ens.fr:cof-geek/gestioCOF into qwann/k-fet/stats

This commit is contained in:
Qwann 2017-01-27 11:56:39 +01:00
commit 5ee188e4df

View file

@ -1,9 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division,
print_function, unicode_literals)
from builtins import *
from django.shortcuts import render, get_object_or_404, redirect
from django.core.exceptions import PermissionDenied, ValidationError
from django.core.cache import cache
@ -1990,8 +1986,8 @@ class HybridDetailView(JSONResponseMixin,
SingleObjectTemplateResponseMixin,
BaseDetailView):
"""
Returns a DetailView as an html page except if a JSON is requested
file by the GET method in which case it returns a JSON response.
Returns a DetailView as an html page except if a JSON file is requested
by the GET method in which case it returns a JSON response.
"""
def render_to_response(self, context):
# Look for a 'format=json' GET argument
@ -2001,14 +1997,12 @@ class HybridDetailView(JSONResponseMixin,
return super(HybridDetailView, self).render_to_response(context)
# Rend un ListView en html sauf si on lui précise dans
# l'appel à get que l'on veut un json auquel cas il en rend un
class HybridListView(JSONResponseMixin,
MultipleObjectTemplateResponseMixin,
BaseListView):
"""
Returns a ListView as an html page except if a JSON is requested
file by the GET method in which case it returns a JSON response.
Returns a ListView as an html page except if a JSON file is requested
by the GET method in which case it returns a JSON response.
"""
def render_to_response(self, context):
# Look for a 'format=json' GET argument
@ -2024,7 +2018,7 @@ class ObjectResumeStat(DetailView):
DOES NOT RETURN A JSON RESPONSE
"""
template_name = 'kfet/object_stat_resume.html'
context_object_name = 'lul'
context_object_name = ''
id_prefix = 'id_a_definir'
# nombre de vues à résumer
nb_stat = 2
@ -2043,7 +2037,7 @@ class ObjectResumeStat(DetailView):
return [{}] * self.nb_stat
def get_context_data(self, **kwargs):
# On hérite pas
# On n'hérite pas
object_id = self.object.id
url_kwargs = self.url_kwargs()
context = {}
@ -2074,11 +2068,6 @@ class ObjectResumeStat(DetailView):
# Evolution Balance perso
# -----------------------
ID_PREFIX_ACC_BALANCE = "balance_acc"
# ID_PREFIX_ACC_BALANCE_MONTH = "balance_month_acc"
# ID_PREFIX_ACC_BALANCE_THREE_MONTHS = "balance_three_months_acc"
# ID_PREFIX_ACC_BALANCE_SIX_MONTHS = "balance_six_months_acc"
# ID_PREFIX_ACC_BALANCE_YEAR = "balance_year_acc"
# ID_PREFIX_ACC_BALANCE_ANYTIME = "balance_anytime_acc"
# Un résumé de toutes les vues ArticleStatBalance
@ -2118,17 +2107,17 @@ class AccountStatBalanceAll(ObjectResumeStat):
class AccountStatBalance(HybridDetailView):
"""
Returns a graph (or a JSON Response) of the evolution a the personnal
balance of a trigramm between timezone.now() and `nb_days`
balance of a trigramme between timezone.now() and `nb_days`
ago (specified to the view as an argument)
takes intto account the Operations and the Transfers
does not takes intto account the balance offset
takes into account the Operations and the Transfers
does not takes into account the balance offset
"""
model = Account
trigramme_url_kwarg = 'trigramme'
nb_date_url_kwargs = 'nb_date'
template_name = 'kfet/account_stat_balance.html'
context_object_name = 'account'
id_prefix = "lol"
id_prefix = ""
def get_object(self, **kwargs):
trigramme = self.kwargs.get(self.trigramme_url_kwarg)
@ -2285,14 +2274,14 @@ class AccountStatLastAll(ObjectResumeStat):
class AccountStatLast(HybridDetailView):
"""
Returns a graph (or a JSON Response) of the evolution a the personnal
consommation of a trigramm at the diffent dates specified
consommation of a trigramme at the diffent dates specified
"""
model = Account
trigramme_url_kwarg = 'trigramme'
template_name = 'kfet/account_stat_last.html'
context_object_name = 'account'
end_date = timezone.now()
id_prefix = "lol"
id_prefix = ""
# doit rendre un dictionnaire des dates
# la première date correspond au début
@ -2333,9 +2322,6 @@ class AccountStatLast(HybridDetailView):
return operations
def get_context_data(self, **kwargs):
# On hérite
# en fait non, pas besoin et c'est chiant à dumper
# context = super(AccountStat, self).get_context_data(**kwargs)
context = {}
nb_ventes = {}
# On récupère les labels des dates
@ -2433,7 +2419,7 @@ class ArticleStatLast(HybridDetailView):
template_name = 'kfet/article_stat_last.html'
context_object_name = 'article'
end_date = timezone.now()
id_prefix = "lol"
id_prefix = ""
def render_to_response(self, context):
# Look for a 'format=json' GET argument
@ -2454,9 +2440,6 @@ class ArticleStatLast(HybridDetailView):
pass
def get_context_data(self, **kwargs):
# On hérite
# en fait non, pas besoin et c'est chiant à dumper
# context = super(ArticleStat, self).get_context_data(**kwargs)
context = {}
# On récupère les labels des dates
context['labels'] = self.get_labels().copy()