Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪲 Fix old programs in program page, improve filtering teacher programs #5197

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,10 +1005,15 @@ def programs_page(user):
all_programs = DATABASE.filtered_programs_for_user(from_user or username,
submitted=submitted,
pagination_token=page)

ids_to_fetch = []
for program in all_programs:
adventure_names[program['adventure_name']] = program['name']
if 'adventure_name' in program and program['adventure_name'] not in adventure_names:
ids_to_fetch.append(program['adventure_name'])

teacher_adventures = DATABASE.batch_get_adventures(ids_to_fetch)
for id, teacher_adventure in teacher_adventures.items():
if teacher_adventure is not None:
adventure_names[id] = teacher_adventure['name']
swapped_adventure_names = {value: key for key, value in adventure_names.items()}
result = DATABASE.filtered_programs_for_user(from_user or username,
level=level,
Expand Down
2 changes: 1 addition & 1 deletion templates/htmx-program.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h3 id="submitted_header_{{ loop_index }}" class="mt-0 mb-4 text-red-500 text-ce
<td>{{program.name|truncate(30)}}</td>
<td>{{_('level')}} {{ program.level }}</td>
{% if program.adventure_name %}
<td>{{adventure_names.get(program.adventure_name)}}</td>
<td>{{adventure_names.get(program.adventure_name, program.adventure_name)}}</td>
{% else %}
<td>-</td>
{% endif %}
Expand Down
Loading