forked from DGNum/gestioCOF
putting away some code for future improvments
This commit is contained in:
parent
de9387c6ad
commit
219835be17
2 changed files with 0 additions and 203 deletions
|
@ -2534,51 +2534,3 @@ class ArticleStatLastMonth(ArticleStatLast):
|
|||
def get_labels(self, **kwargs):
|
||||
months = lastmonths(7)
|
||||
return monthnames(months)
|
||||
|
||||
# ------------------------------
|
||||
# Article Statistique Catégories
|
||||
# ------------------------------
|
||||
|
||||
|
||||
class DurationStat(HybridListView):
|
||||
lookup_duration_type = 'day' # 'day' || 'week' || 'month'
|
||||
lookup_duration_number = 3 # ie ici : 3 jours
|
||||
|
||||
def get_end_date(self, **kwargs):
|
||||
if self.lookup_duration_type == 'day':
|
||||
return this_morning()
|
||||
elif self.lookup_duration_type == 'week':
|
||||
return this_monday_morning()
|
||||
elif self.lookup_duration_type == 'month':
|
||||
return this_first_month_day()
|
||||
else:
|
||||
raise ValueError('duration_type invalid')
|
||||
|
||||
def get_begining_date(self, **kwargs):
|
||||
end_date = self.get_end_date(self, **kwargs)
|
||||
if self.lookup_duration_type == 'day':
|
||||
days = self.lookup_nb_duration
|
||||
elif self.lookup_duration_type == 'week':
|
||||
days = 7*self.lookup_nb_duration
|
||||
elif self.lookup_duration_type == 'month':
|
||||
days = 30*self.lookup_nb_duration
|
||||
else:
|
||||
raise ValueError('this should not be happening.')
|
||||
delta = timezone.timedelta(days=days)
|
||||
return end_date - delta
|
||||
|
||||
@method_decorator(login_required)
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(DurationStat, self).dispatch(*args, **kwargs)
|
||||
|
||||
|
||||
# TODO
|
||||
# class CategoryDurationStat(DurationStat):
|
||||
# model = ArticleCategory
|
||||
# template_name = 'kfet/category_stat.html'
|
||||
#
|
||||
# def get_context_data(self, **kwargs):
|
||||
# context = {}
|
||||
# queryset = kwargs.pop('object_list', self.object_list)
|
||||
#
|
||||
# return context
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue