[FIX] Mark selected theme in the theme dropdown in the user menu

This commit is contained in:
Peter Pfeufer 2024-01-28 10:18:11 +01:00
parent 7ba65968ed
commit 8362d11714
No known key found for this signature in database
GPG Key ID: 6051D2C6AD4EBC27
2 changed files with 9 additions and 4 deletions

View File

@ -1,9 +1,13 @@
{% load i18n %}
<form action="{% url 'theme' %}?next={{ next|urlencode }}" method="post"> <form action="{% url 'theme' %}?next={{ next|urlencode }}" method="post">
{% csrf_token %} {% csrf_token %}
<select name="theme" value="theme" class="form-select" aria-label="" onchange="this.form.submit()">
<option selected>Select Theme</option> <select name="theme" class="form-select" aria-label="" onchange="this.form.submit()">
<option selected>{% translate "Select Theme" %}</option>
{% for theme in themes %} {% for theme in themes %}
<option value="{{ theme.get_name }}">{{ theme.name }}</option> <option value="{{ theme.get_name }}"{% if selected_theme.name == theme.name %} selected="selected"{% endif %}>{{ theme.name }}</option>
{% endfor %} {% endfor %}
</select> </select>
</form> </form>

View File

@ -72,5 +72,6 @@ def theme_select(context):
request = context['request'] request = context['request']
return { return {
'next': request.path, 'next': request.path,
'themes': get_hooks('theme_hook') 'themes': get_hooks('theme_hook'),
'selected_theme': get_theme(request)
} }