Cleanup
- Un peu de PEP8 - Suppression d'une partie de la py2 compat - Typos
This commit is contained in:
parent
9607fab046
commit
bd7f767953
1 changed files with 24 additions and 41 deletions
|
@ -1,9 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- 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.shortcuts import render, get_object_or_404, redirect
|
||||||
from django.core.exceptions import PermissionDenied, ValidationError
|
from django.core.exceptions import PermissionDenied, ValidationError
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
|
@ -1990,8 +1986,8 @@ class HybridDetailView(JSONResponseMixin,
|
||||||
SingleObjectTemplateResponseMixin,
|
SingleObjectTemplateResponseMixin,
|
||||||
BaseDetailView):
|
BaseDetailView):
|
||||||
"""
|
"""
|
||||||
Returns a DetailView as an html page except if a JSON is requested
|
Returns a DetailView as an html page except if a JSON file is requested
|
||||||
file by the GET method in which case it returns a JSON response.
|
by the GET method in which case it returns a JSON response.
|
||||||
"""
|
"""
|
||||||
def render_to_response(self, context):
|
def render_to_response(self, context):
|
||||||
# Look for a 'format=json' GET argument
|
# Look for a 'format=json' GET argument
|
||||||
|
@ -2001,14 +1997,12 @@ class HybridDetailView(JSONResponseMixin,
|
||||||
return super(HybridDetailView, self).render_to_response(context)
|
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,
|
class HybridListView(JSONResponseMixin,
|
||||||
MultipleObjectTemplateResponseMixin,
|
MultipleObjectTemplateResponseMixin,
|
||||||
BaseListView):
|
BaseListView):
|
||||||
"""
|
"""
|
||||||
Returns a ListView as an html page except if a JSON is requested
|
Returns a ListView as an html page except if a JSON file is requested
|
||||||
file by the GET method in which case it returns a JSON response.
|
by the GET method in which case it returns a JSON response.
|
||||||
"""
|
"""
|
||||||
def render_to_response(self, context):
|
def render_to_response(self, context):
|
||||||
# Look for a 'format=json' GET argument
|
# Look for a 'format=json' GET argument
|
||||||
|
@ -2024,7 +2018,7 @@ class ObjectResumeStat(DetailView):
|
||||||
DOES NOT RETURN A JSON RESPONSE
|
DOES NOT RETURN A JSON RESPONSE
|
||||||
"""
|
"""
|
||||||
template_name = 'kfet/object_stat_resume.html'
|
template_name = 'kfet/object_stat_resume.html'
|
||||||
context_object_name = 'lul'
|
context_object_name = ''
|
||||||
id_prefix = 'id_a_definir'
|
id_prefix = 'id_a_definir'
|
||||||
# nombre de vues à résumer
|
# nombre de vues à résumer
|
||||||
nb_stat = 2
|
nb_stat = 2
|
||||||
|
@ -2043,7 +2037,7 @@ class ObjectResumeStat(DetailView):
|
||||||
return [{}] * self.nb_stat
|
return [{}] * self.nb_stat
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
# On hérite pas
|
# On n'hérite pas
|
||||||
object_id = self.object.id
|
object_id = self.object.id
|
||||||
url_kwargs = self.url_kwargs()
|
url_kwargs = self.url_kwargs()
|
||||||
context = {}
|
context = {}
|
||||||
|
@ -2074,11 +2068,6 @@ class ObjectResumeStat(DetailView):
|
||||||
# Evolution Balance perso
|
# Evolution Balance perso
|
||||||
# -----------------------
|
# -----------------------
|
||||||
ID_PREFIX_ACC_BALANCE = "balance_acc"
|
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
|
# Un résumé de toutes les vues ArticleStatBalance
|
||||||
|
@ -2118,17 +2107,17 @@ class AccountStatBalanceAll(ObjectResumeStat):
|
||||||
class AccountStatBalance(HybridDetailView):
|
class AccountStatBalance(HybridDetailView):
|
||||||
"""
|
"""
|
||||||
Returns a graph (or a JSON Response) of the evolution a the personnal
|
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)
|
ago (specified to the view as an argument)
|
||||||
takes intto account the Operations and the Transfers
|
takes into account the Operations and the Transfers
|
||||||
does not takes intto account the balance offset
|
does not takes into account the balance offset
|
||||||
"""
|
"""
|
||||||
model = Account
|
model = Account
|
||||||
trigramme_url_kwarg = 'trigramme'
|
trigramme_url_kwarg = 'trigramme'
|
||||||
nb_date_url_kwargs = 'nb_date'
|
nb_date_url_kwargs = 'nb_date'
|
||||||
template_name = 'kfet/account_stat_balance.html'
|
template_name = 'kfet/account_stat_balance.html'
|
||||||
context_object_name = 'account'
|
context_object_name = 'account'
|
||||||
id_prefix = "lol"
|
id_prefix = ""
|
||||||
|
|
||||||
def get_object(self, **kwargs):
|
def get_object(self, **kwargs):
|
||||||
trigramme = self.kwargs.get(self.trigramme_url_kwarg)
|
trigramme = self.kwargs.get(self.trigramme_url_kwarg)
|
||||||
|
@ -2285,14 +2274,14 @@ class AccountStatLastAll(ObjectResumeStat):
|
||||||
class AccountStatLast(HybridDetailView):
|
class AccountStatLast(HybridDetailView):
|
||||||
"""
|
"""
|
||||||
Returns a graph (or a JSON Response) of the evolution a the personnal
|
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
|
model = Account
|
||||||
trigramme_url_kwarg = 'trigramme'
|
trigramme_url_kwarg = 'trigramme'
|
||||||
template_name = 'kfet/account_stat_last.html'
|
template_name = 'kfet/account_stat_last.html'
|
||||||
context_object_name = 'account'
|
context_object_name = 'account'
|
||||||
end_date = timezone.now()
|
end_date = timezone.now()
|
||||||
id_prefix = "lol"
|
id_prefix = ""
|
||||||
|
|
||||||
# doit rendre un dictionnaire des dates
|
# doit rendre un dictionnaire des dates
|
||||||
# la première date correspond au début
|
# la première date correspond au début
|
||||||
|
@ -2333,9 +2322,6 @@ class AccountStatLast(HybridDetailView):
|
||||||
return operations
|
return operations
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
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 = {}
|
context = {}
|
||||||
nb_ventes = {}
|
nb_ventes = {}
|
||||||
# On récupère les labels des dates
|
# On récupère les labels des dates
|
||||||
|
@ -2433,7 +2419,7 @@ class ArticleStatLast(HybridDetailView):
|
||||||
template_name = 'kfet/article_stat_last.html'
|
template_name = 'kfet/article_stat_last.html'
|
||||||
context_object_name = 'article'
|
context_object_name = 'article'
|
||||||
end_date = timezone.now()
|
end_date = timezone.now()
|
||||||
id_prefix = "lol"
|
id_prefix = ""
|
||||||
|
|
||||||
def render_to_response(self, context):
|
def render_to_response(self, context):
|
||||||
# Look for a 'format=json' GET argument
|
# Look for a 'format=json' GET argument
|
||||||
|
@ -2454,9 +2440,6 @@ class ArticleStatLast(HybridDetailView):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
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 = {}
|
context = {}
|
||||||
# On récupère les labels des dates
|
# On récupère les labels des dates
|
||||||
context['labels'] = self.get_labels().copy()
|
context['labels'] = self.get_labels().copy()
|
||||||
|
|
Loading…
Reference in a new issue