Add command to remove space from skill notation
This commit is contained in:
parent
4b320d3a7c
commit
58c5d83658
|
@ -13,7 +13,7 @@ from ultron.objective.models import Educative, PrerequisiteClosure
|
|||
class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
educative_list = Educative.objects.all()
|
||||
count = 0
|
||||
|
||||
for educative in educative_list:
|
||||
updated = False
|
||||
max_level = 0
|
||||
|
@ -27,7 +27,7 @@ class Command(BaseCommand):
|
|||
age_girl_without_help = 0
|
||||
age_girl_chained = 0
|
||||
age_girl_masterised = 0
|
||||
count += 1
|
||||
|
||||
print(str(count) + ' - Traitement de ' + str(educative.long_label))
|
||||
breadcrumb = educative.breadcrumb()
|
||||
|
||||
|
@ -49,14 +49,13 @@ class Command(BaseCommand):
|
|||
age_girl_without_help = max(age_girl_without_help, ancestor.age_girl_without_help)
|
||||
age_girl_chained = max(age_girl_chained, ancestor.age_girl_chained)
|
||||
age_girl_masterised = max(age_girl_masterised, ancestor.age_girl_masterised)
|
||||
|
||||
|
||||
if tree_path in tree:
|
||||
tree.remove(tree_path)
|
||||
|
||||
|
||||
for tree_path in tree:
|
||||
tree_path.delete()
|
||||
|
||||
# Dans une condition pour espérer accélérer le traitement
|
||||
if educative.level != max_level:
|
||||
updated = True
|
||||
educative.level = max_level
|
||||
|
@ -65,7 +64,6 @@ class Command(BaseCommand):
|
|||
updated = True
|
||||
educative.rank = max_rank
|
||||
|
||||
# Age boy defining
|
||||
if educative.age_boy_with_help < age_boy_with_help:
|
||||
updated = True
|
||||
educative.age_boy_with_help = age_boy_with_help
|
||||
|
@ -77,12 +75,11 @@ class Command(BaseCommand):
|
|||
if educative.age_boy_chained < age_boy_chained:
|
||||
updated = True
|
||||
educative.age_boy_chained = age_boy_chained
|
||||
|
||||
|
||||
if educative.age_boy_masterised < age_boy_masterised:
|
||||
updated = True
|
||||
educative.age_boy_masterised = age_boy_masterised
|
||||
|
||||
# Age girl defined
|
||||
if educative.age_girl_with_help < age_girl_with_help:
|
||||
updated = True
|
||||
educative.age_girl_with_help = age_girl_with_help
|
||||
|
@ -94,7 +91,7 @@ class Command(BaseCommand):
|
|||
if educative.age_girl_chained < age_girl_chained:
|
||||
updated = True
|
||||
educative.age_girl_chained = age_girl_chained
|
||||
|
||||
|
||||
if educative.age_girl_masterised < age_girl_masterised:
|
||||
updated = True
|
||||
educative.age_girl_masterised = age_girl_masterised
|
|
@ -0,0 +1,27 @@
|
|||
""" Retire les espaces contenu dans le champ "notation" et "simplified notation" de la class skill
|
||||
dans le but de faciliter les recherches (skill_lookup).
|
||||
"""
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from ultron.objective.models import Skill
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
skill_list = Skill.objects.all()
|
||||
for skill in skill_list:
|
||||
need_update = False
|
||||
notation = skill.notation.replace(" ", "")
|
||||
simplified_notation = skill.simplified_notation.replace(" ", "")
|
||||
|
||||
if notation != skill.notation:
|
||||
need_update = True
|
||||
skill.notation = notation
|
||||
|
||||
if simplified_notation != skill.simplified_notation:
|
||||
need_update = True
|
||||
skill.simplified_notation = simplified_notation
|
||||
|
||||
if need_update:
|
||||
skill.save()
|
Loading…
Reference in New Issue