clean some comments

- fix: error if actions are empty in balance stats
This commit is contained in:
Aurélien Delobelle 2017-04-03 17:06:32 +02:00
parent 6d2e150aa0
commit 10d2b58fa7

View file

@ -2049,9 +2049,10 @@ class PkUrlMixin(object):
class SingleResumeStat(JSONDetailView): class SingleResumeStat(JSONDetailView):
""" """Manifest for a kind of a stat about an object.
Summarize all the stats of an object
Handles JSONResponse Returns JSON whose payload is an array containing descriptions of a stat:
url to retrieve data, label, ...
""" """
id_prefix = '' id_prefix = ''
@ -2095,9 +2096,8 @@ class SingleResumeStat(JSONDetailView):
ID_PREFIX_ACC_BALANCE = "balance_acc" ID_PREFIX_ACC_BALANCE = "balance_acc"
# Un résumé de toutes les vues ArticleStatBalance
# REND DU JSON
class AccountStatBalanceList(PkUrlMixin, SingleResumeStat): class AccountStatBalanceList(PkUrlMixin, SingleResumeStat):
"""Manifest for balance stats of an account."""
model = Account model = Account
context_object_name = 'account' context_object_name = 'account'
pk_url_kwarg = 'trigramme' pk_url_kwarg = 'trigramme'
@ -2138,12 +2138,10 @@ class AccountStatBalanceList(PkUrlMixin, SingleResumeStat):
class AccountStatBalance(PkUrlMixin, JSONDetailView): class AccountStatBalance(PkUrlMixin, JSONDetailView):
""" """Datasets of balance of an account.
Returns a JSON containing the evolution a the personnal
balance of a trigramme between timezone.now() and `nb_days` Operations and Transfers are taken into account.
ago (specified to the view as an argument)
takes into account the Operations and the Transfers
does not takes into account the balance offset
""" """
model = Account model = Account
pk_url_kwarg = 'trigramme' pk_url_kwarg = 'trigramme'
@ -2253,8 +2251,9 @@ class AccountStatBalance(PkUrlMixin, JSONDetailView):
"values": changes, "values": changes,
}] }]
context['is_time_chart'] = True context['is_time_chart'] = True
context['min_date'] = changes[-1]['at'] if len(changes) > 0:
context['max_date'] = changes[0]['at'] context['min_date'] = changes[-1]['at']
context['max_date'] = changes[0]['at']
# TODO: offset # TODO: offset
return context return context
@ -2278,9 +2277,8 @@ ID_PREFIX_ACC_LAST_WEEKS = "last_weeks_acc"
ID_PREFIX_ACC_LAST_MONTHS = "last_months_acc" ID_PREFIX_ACC_LAST_MONTHS = "last_months_acc"
# Un résumé de toutes les vues ArticleStatLast
# NE REND PAS DE JSON
class AccountStatOperationList(PkUrlMixin, SingleResumeStat): class AccountStatOperationList(PkUrlMixin, SingleResumeStat):
"""Manifest for operations stats of an account."""
model = Account model = Account
context_object_name = 'account' context_object_name = 'account'
pk_url_kwarg = 'trigramme' pk_url_kwarg = 'trigramme'
@ -2301,10 +2299,7 @@ class AccountStatOperationList(PkUrlMixin, SingleResumeStat):
class AccountStatOperation(ScaleMixin, PkUrlMixin, JSONDetailView): class AccountStatOperation(ScaleMixin, PkUrlMixin, JSONDetailView):
""" """Datasets of operations of an account."""
Returns a JSON containing the evolution a the personnal
consommation of a trigramme at the diffent dates specified
"""
model = Account model = Account
pk_url_kwarg = 'trigramme' pk_url_kwarg = 'trigramme'
context_object_name = 'account' context_object_name = 'account'
@ -2363,9 +2358,8 @@ ID_PREFIX_ART_LAST_WEEKS = "last_weeks_art"
ID_PREFIX_ART_LAST_MONTHS = "last_months_art" ID_PREFIX_ART_LAST_MONTHS = "last_months_art"
# Un résumé de toutes les vues ArticleStatLast
# NE REND PAS DE JSON
class ArticleStatSalesList(SingleResumeStat): class ArticleStatSalesList(SingleResumeStat):
"""Manifest for sales stats of an article."""
model = Article model = Article
context_object_name = 'article' context_object_name = 'article'
id_prefix = ID_PREFIX_ART_LAST id_prefix = ID_PREFIX_ART_LAST
@ -2379,10 +2373,7 @@ class ArticleStatSalesList(SingleResumeStat):
class ArticleStatSales(ScaleMixin, JSONDetailView): class ArticleStatSales(ScaleMixin, JSONDetailView):
""" """Datasets of sales of an article."""
Returns a JSON containing the consommation
of an article at the diffent dates precised
"""
model = Article model = Article
context_object_name = 'article' context_object_name = 'article'