On déplace choices_length
dans shared
This commit is contained in:
parent
eb075fd771
commit
2fc4073351
3 changed files with 13 additions and 14 deletions
|
@ -5,6 +5,8 @@ from django.contrib.auth.models import AbstractUser
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from shared.utils import choices_length
|
||||||
|
|
||||||
from .staticdefs import (
|
from .staticdefs import (
|
||||||
BALLOT_TYPE,
|
BALLOT_TYPE,
|
||||||
CAST_FUNCTIONS,
|
CAST_FUNCTIONS,
|
||||||
|
@ -19,7 +21,6 @@ from .utils import (
|
||||||
ResultsData,
|
ResultsData,
|
||||||
TallyFunctions,
|
TallyFunctions,
|
||||||
ValidateFunctions,
|
ValidateFunctions,
|
||||||
choices_length,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|
|
@ -16,19 +16,6 @@ from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from shared.auth.utils import generate_password
|
from shared.auth.utils import generate_password
|
||||||
|
|
||||||
# #############################################################################
|
|
||||||
# Fonctions universelles
|
|
||||||
# #############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
def choices_length(choices):
|
|
||||||
"""Renvoie la longueur maximale des choix de choices"""
|
|
||||||
m = 0
|
|
||||||
for c in choices:
|
|
||||||
m = max(m, len(c[0]))
|
|
||||||
return m
|
|
||||||
|
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Classes pour différencier les différents types de questions
|
# Classes pour différencier les différents types de questions
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|
11
shared/utils.py
Normal file
11
shared/utils.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# #############################################################################
|
||||||
|
# Fonctions universelles
|
||||||
|
# #############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
def choices_length(choices):
|
||||||
|
"""Renvoie la longueur maximale des choix de choices"""
|
||||||
|
m = 0
|
||||||
|
for c in choices:
|
||||||
|
m = max(m, len(c[0]))
|
||||||
|
return m
|
Loading…
Reference in a new issue