diff --git a/app.py b/app.py index a67beda4416..1aaa2169b1c 100644 --- a/app.py +++ b/app.py @@ -1006,8 +1006,10 @@ def programs_page(user): submitted=submitted, pagination_token=page) ids_to_fetch = [] + # Some old programs don't have adventure_name in them, or the field is emtpy. for program in all_programs: - if 'adventure_name' in program and program['adventure_name'] not in adventure_names: + if 'adventure_name' in program and program['adventure_name'] and\ + program['adventure_name'] not in adventure_names: ids_to_fetch.append(program['adventure_name']) teacher_adventures = DATABASE.batch_get_adventures(ids_to_fetch) diff --git a/hedy_content.py b/hedy_content.py index 669b3c48506..bd485e5eca5 100644 --- a/hedy_content.py +++ b/hedy_content.py @@ -542,11 +542,12 @@ def get_sorted_level_programs(self, programs, adventure_names): def get_sorted_adventure_programs(self, programs, adventure_names): programs_by_adventure = [] for item in programs: - programs_by_adventure.append( - {'adventure_name': adventure_names.get(item.get('adventure_name'), item.get('adventure_name')), - 'level': item['level'], - } - ) + if item.get('adventure_name') != '': + programs_by_adventure.append( + {'adventure_name': adventure_names.get(item.get('adventure_name'), item.get('adventure_name')), + 'level': item['level'], + } + ) sort = {} for program in programs_by_adventure: