diff --git a/src/objective/urls.py b/src/objective/urls.py index 168feaf..6c3154c 100644 --- a/src/objective/urls.py +++ b/src/objective/urls.py @@ -42,6 +42,11 @@ routine_urlpatterns = [ views.del_skill_from_routine, name="del_skill_from_routine", ), + path( + r"suggest/", + views.suggest_routine, + name="suggest_routine", + ) ] # Chrono diff --git a/src/objective/views.py b/src/objective/views.py index 4b24858..7ee6e72 100644 --- a/src/objective/views.py +++ b/src/objective/views.py @@ -370,6 +370,7 @@ def __construct_routine( Returns: ??? (list): liste des séries correspondantes aux criètres. """ + print("Il reste " + str(routine_length) + " sauts à trouver.") current_routine = [] @@ -407,18 +408,23 @@ def __construct_routine( for skill in skill_list: current_routine.append(skill) + routine_length -= 1 + if routine_length == 0: + break current_routine.append( - self.suggest_routine( - total_difficulty_score - skill.difficulty, - max_difficulty_score, - routine_length - 1, + __construct_routine( + routine_length, + total_difficulty_score - skill.difficulty if total_difficulty_score else None, competition, logic, gymnast, skill, ) ) + if len(current_routine) == 10: + print(current_routine) current_routine.pop() + routine_length += 1 # def knapSack(W, wt, val, n): # K = [[0 for x in range(W+1)] for x in range(n+1)] # for i in range(n+1): @@ -441,12 +447,11 @@ def __construct_routine( def suggest_routine( request, - routine_length, + routine_length = 10, total_difficulty_score=None, competition=True, logic=True, gymnast=None, - last_jump=None, ): """ Construit et propose des séries. @@ -460,17 +465,20 @@ def suggest_routine( Returns: ??? (list): liste des séries correspondantes aux criètres. - """ - current_routine = __construct_routine( - routine_length, - total_difficulty_score, - competition, - logic, - gymnast, - last_jump + >>> http://127.0.0.1:8000/routine/suggest/ + """ + routines = [] + routines.append(__construct_routine( + routine_length, + total_difficulty_score, + competition, + logic, + gymnast, + None + ) ) - print(current_routine) + # print(routines) @login_required