Skip to content

Commit

Permalink
🪲 Fix view programs for non students (#5903)
Browse files Browse the repository at this point in the history
When trying to access a program from a user that's not in a class, the paged failed due to indexing an empty dictionary.

**How to test**

* Go to  http://localhost:8080/hedy/30bd4e4ce84f40bca40b24b9295e1483/view and it should open normally.
  • Loading branch information
jpelay authored Oct 30, 2024
1 parent cff3b78 commit 58f864a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1965,7 +1965,7 @@ def view_program(user, id):
level=int(result['level']),
code=code),
is_teacher=user['is_teacher'],
class_id=student_customizations['id'],
class_id=student_customizations.get('id'),
next_program_id=next_program_id,
next_classmate_program_id=next_classmate_adventure_id,
**arguments_dict)
Expand Down
8 changes: 5 additions & 3 deletions templates/view-program-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ <h1>{{initial_adventure.name}}</h1>
{% if next_classmate_program_id %}
<a class="green-btn" href="/hedy/{{ next_classmate_program_id }}/view">{{ _('next_student') }}</a>
{% endif %}
<a class="green-btn" href="/for-teachers/class/{{ class_id }}">
{{_('back_to_class')}}
</a>
{% if class_id %}
<a class="green-btn" href="/for-teachers/class/{{ class_id }}">
{{_('back_to_class')}}
</a>
{% endif %}
{% endif %}
</div>
<h2 class="p-0 m-0">{{_('level_title')}} {{level}}</h2>
Expand Down

0 comments on commit 58f864a

Please sign in to comment.