From 59f80bd47a2485a591c9887374d5c206f327e52a Mon Sep 17 00:00:00 2001 From: David Wallace Date: Wed, 4 Dec 2024 09:45:31 +0100 Subject: [PATCH] refactor(projects,pages): rename variables, update comments Signed-off-by: David Wallace --- rdmo/projects/progress.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rdmo/projects/progress.py b/rdmo/projects/progress.py index ce03d340b..5994a08fe 100644 --- a/rdmo/projects/progress.py +++ b/rdmo/projects/progress.py @@ -48,28 +48,27 @@ def compute_sets(values): def compute_next_relevant_page(current_page, direction, catalog, resolved_conditions): - # compute the next relevant page based on resolved conditions. - - # Determine the next page based on the specified direction + # recursively compute the next relevant page based on resolved conditions. + # first, get the next page from the catalog based on the specified direction next_page = ( catalog.get_prev_page(current_page) if direction == 'prev' else catalog.get_next_page(current_page) ) - # If no current_page, return None - if not current_page: + # if no current_page, return None + if not next_page: return None - # Check if the current page meets the conditions - if compute_show_page(current_page, resolved_conditions): - return current_page + # check if the current page meets the conditions + if compute_show_page(next_page, resolved_conditions): + return next_page - # Recursive step: Check the next page + # recursive step: check the next page return compute_next_relevant_page(next_page, direction, catalog, resolved_conditions) def compute_show_page(page, conditions): - """Determine if a page should be shown based on resolved conditions.""" + # determine if a page should be shown based on resolved conditions # show only pages with resolved conditions, but show all pages without conditions pages_conditions = {page.id for page in page.conditions.all()} @@ -114,6 +113,7 @@ def compute_navigation(section, project, snapshot=None): for page in catalog_section.elements: + # determine if a page should be shown or not show = compute_show_page(page, conditions) # count the total number of questions, taking sets and conditions into account