some cleaning
This commit is contained in:
parent
9cae3ad0bd
commit
1c90608f6d
4 changed files with 8 additions and 147 deletions
|
@ -557,7 +557,7 @@ class Operation(models.Model):
|
|||
templates = {
|
||||
self.PURCHASE: "{nb} {article.name} ({amount}€)",
|
||||
self.DEPOSIT: "charge ({amount})",
|
||||
self.WITHDRAW: "retrait ({amount})",
|
||||
self.WITHDRAW: "retrait ({amount})",
|
||||
self.INITIAL: "initial ({amount})",
|
||||
}
|
||||
return templates[self.type].format(nb=self.article_nb,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django.utils import timezone
|
||||
from django.db.models import Sum
|
||||
|
||||
|
||||
# donne le nom des jours d'une liste de dates
|
||||
|
@ -28,6 +29,7 @@ def monthnames(dates):
|
|||
names[i] = dates[i].strftime("%B")
|
||||
return names
|
||||
|
||||
|
||||
# rend les dates des nb derniers jours
|
||||
# dans l'ordre chronologique
|
||||
# aujourd'hui compris
|
||||
|
@ -55,7 +57,7 @@ def lastmonths(nb):
|
|||
this_year = first_month_day.year
|
||||
this_month = first_month_day.month
|
||||
for i in range(1, nb+1):
|
||||
month = ((this_month - 1 - (nb - i)) % 12) + 1
|
||||
month = ((this_month - 1 - (nb - i)) % 12) + 1
|
||||
year = this_year + (nb - i) // 12
|
||||
first_days[i] = timezone.datetime(year=year,
|
||||
month=month,
|
||||
|
@ -91,7 +93,5 @@ def this_morning():
|
|||
# Étant donné un queryset d'operations
|
||||
# rend la somme des article_nb
|
||||
def tot_ventes(queryset):
|
||||
res = 0
|
||||
for op in queryset:
|
||||
res += op.article_nb
|
||||
return res
|
||||
res = queryset.aggregate(Sum('article_nb'))['article_nb__sum']
|
||||
return res and res or 0
|
||||
|
|
141
kfet/tests.py
141
kfet/tests.py
|
@ -2,143 +2,4 @@
|
|||
|
||||
from django.test import TestCase
|
||||
|
||||
from kfet.models import Account
|
||||
from gestioncof.models import CofProfile, User
|
||||
|
||||
|
||||
|
||||
names = ['Abelardus',
|
||||
'Abrahamus',
|
||||
'Acacius',
|
||||
'Accius',
|
||||
'Achaicus',
|
||||
'Achill',
|
||||
'Achilles',
|
||||
'Achilleus',
|
||||
'Acrisius',
|
||||
'Actaeon',
|
||||
'Acteon',
|
||||
'Adalricus',
|
||||
'Adelfonsus',
|
||||
'Adelphus',
|
||||
'Adeodatus',
|
||||
'Adolfus',
|
||||
'Adolphus',
|
||||
'Adrastus',
|
||||
'Adrianus',
|
||||
'Ægidius',
|
||||
'Ælia',
|
||||
'Ælianus',
|
||||
'Æmilianus',
|
||||
'Æmilius',
|
||||
'Aeneas',
|
||||
'Æolus',
|
||||
'Æschylus',
|
||||
'Æson',
|
||||
'Æsop',
|
||||
'Æther',
|
||||
'Ætius',
|
||||
'Agapetus',
|
||||
'Agapitus',
|
||||
'Agapius',
|
||||
'Agathangelus',
|
||||
'Aigidius',
|
||||
'Aiolus',
|
||||
'Ajax',
|
||||
'Alair',
|
||||
'Alaricus',
|
||||
'Albanus',
|
||||
'Alberic',
|
||||
'Albericus',
|
||||
'Albertus',
|
||||
'Albinus',
|
||||
'Albus',
|
||||
'Alcaeus',
|
||||
'Alcander',
|
||||
'Alcimus',
|
||||
'Alcinder',
|
||||
'Alerio',
|
||||
'Alexandrus',
|
||||
'Alexis',
|
||||
'Alexius',
|
||||
'Alexus',
|
||||
'Alfonsus',
|
||||
'Alfredus',
|
||||
'Almericus',
|
||||
'Aloisius',
|
||||
'Aloysius',
|
||||
'Alphaeus',
|
||||
'Alpheaus',
|
||||
'Alpheus',
|
||||
'Alphoeus',
|
||||
'Alphonsus',
|
||||
'Alphonzus',
|
||||
'Alvinius',
|
||||
'Alvredus',
|
||||
'Amadeus',
|
||||
'Amaliricus',
|
||||
'Amandus',
|
||||
'Amantius',
|
||||
'Amarandus',
|
||||
'Amaranthus',
|
||||
'Amatus',
|
||||
'Ambrosianus',
|
||||
'Ambrosius',
|
||||
'Amedeus',
|
||||
'Americus',
|
||||
'Amlethus',
|
||||
'Amletus',
|
||||
'Amor',
|
||||
'Ampelius',
|
||||
'Amphion',
|
||||
'Anacletus',
|
||||
'Anastasius',
|
||||
'Anastatius',
|
||||
'Anastius',
|
||||
'Anatolius',
|
||||
'Androcles',
|
||||
'Andronicus',
|
||||
'Anencletus',
|
||||
'Angelicus',
|
||||
'Angelus',
|
||||
'Anicetus',
|
||||
'Antigonus',
|
||||
'Antipater',
|
||||
'Antoninus',
|
||||
'Antonius',
|
||||
'Aphrodisius',
|
||||
'Apollinaris']
|
||||
|
||||
|
||||
# Ne pas supprimer, peut être utile pour regénérer
|
||||
# d'autres fixtures à l'avenir
|
||||
class TestFoo(TestCase):
|
||||
fixtures = ['users', 'sites', 'gestion', 'articles']
|
||||
|
||||
def test_foo(self):
|
||||
pass
|
||||
# for name in names:
|
||||
# user = User(username=name,
|
||||
# last_name='Romain',
|
||||
# first_name=name)
|
||||
# user.email = '{}.{}@ens.fr'.format(user.first_name, user.last_name)
|
||||
# user.save()
|
||||
|
||||
# galois_trigrammes = map('{:03d}'.format, range(40))
|
||||
# galois = CofProfile.objects.filter(user__last_name='Gaulois')
|
||||
|
||||
# romains_trigrammes = map(lambda x: str(100+x), range(40))
|
||||
# romains = CofProfile.objects.filter(user__last_name='Romain')
|
||||
|
||||
# for t, c in zip(galois_trigrammes, galois):
|
||||
# Account.objects.create(cofprofile=c, trigramme=t)
|
||||
# for t, c in zip(romains_trigrammes, romains):
|
||||
# Account.objects.create(cofprofile=c, trigramme=t)
|
||||
|
||||
|
||||
# class TestBar(TestCase):
|
||||
# fixtures = ['users', 'sites', 'gestion', 'articles', 'groups', 'accounts']
|
||||
|
||||
|
||||
# def test_foo(self):
|
||||
# pass
|
||||
# Écrire les tests ici
|
||||
|
|
|
@ -2020,7 +2020,7 @@ class ObjectResumeStat(DetailView):
|
|||
"""
|
||||
template_name = 'kfet/object_stat_resume.html'
|
||||
context_object_name = ''
|
||||
id_prefix = 'id_a_definir'
|
||||
id_prefix = ''
|
||||
# nombre de vues à résumer
|
||||
nb_stat = 2
|
||||
# Le combienième est celui par defaut ?
|
||||
|
|
Loading…
Reference in a new issue