Fixes form element display inside details panel

This commit is contained in:
Mouse Reeve 2022-01-30 09:31:57 -08:00
parent 6983884eaa
commit ae0e67f076
5 changed files with 47 additions and 36 deletions

View file

@ -2,15 +2,17 @@
{% load i18n %}
{% block filter %}
<label class="label is-block" for="id_format">{% trans "Format:" %}</label>
<div class="select">
<select id="id_format" name="format">
<option value="">{% trans "Any" %}</option>
{% for format in formats %}{% if format %}
<option value="{{ format }}" {% if request.GET.format == format %}selected{% endif %}>
{{ format|title }}
</option>
{% endif %}{% endfor %}
</select>
<div class="control">
<label class="label is-block" for="id_format">{% trans "Format:" %}</label>
<div class="select">
<select id="id_format" name="format">
<option value="">{% trans "Any" %}</option>
{% for format in formats %}{% if format %}
<option value="{{ format }}" {% if request.GET.format == format %}selected{% endif %}>
{{ format|title }}
</option>
{% endif %}{% endfor %}
</select>
</div>
</div>
{% endblock %}

View file

@ -2,15 +2,17 @@
{% load i18n %}
{% block filter %}
<label class="label is-block" for="id_language">{% trans "Language:" %}</label>
<div class="select">
<select id="id_language" name="language">
<option value="">{% trans "Any" %}</option>
{% for language in languages %}
<option value="{{ language }}" {% if request.GET.language == language %}selected{% endif %}>
{{ language }}
</option>
{% endfor %}
</select>
<div class="control">
<label class="label is-block" for="id_language">{% trans "Language:" %}</label>
<div class="select">
<select id="id_language" name="language">
<option value="">{% trans "Any" %}</option>
{% for language in languages %}
<option value="{{ language }}" {% if request.GET.language == language %}selected{% endif %}>
{{ language }}
</option>
{% endfor %}
</select>
</div>
</div>
{% endblock %}

View file

@ -2,7 +2,9 @@
{% load i18n %}
{% block filter %}
<label class="label" for="id_search">{% trans "Search editions" %}</label>
<input type="text" class="input" name="q" value="{{ request.GET.q|default:'' }}" id="id_search">
<div class="control">
<label class="label" for="id_search">{% trans "Search editions" %}</label>
<input type="text" class="input" name="q" value="{{ request.GET.q|default:'' }}" id="id_search">
</div>
{% endblock %}

View file

@ -38,9 +38,11 @@
{% block filter_fields %}
{% endblock %}
</div>
<button type="submit" class="button is-primary is-small">
<div class="control">
<button type="submit" class="button is-primary">
{% trans "Apply filters" %}
</button>
</div>
</form>
</div>
</details>

View file

@ -36,19 +36,22 @@ def get_next_shelf(current_shelf):
def active_shelf(context, book):
"""check what shelf a user has a book on, if any"""
user = context["request"].user
return cache.get_or_set(
f"active_shelf-{user.id}-{book.id}",
lambda u, b: (
models.ShelfBook.objects.filter(
shelf__user=u,
book__parent_work__editions=b,
).first()
or False
),
user,
book,
timeout=15552000,
) or {"book": book}
return (
cache.get_or_set(
f"active_shelf-{user.id}-{book.id}",
lambda u, b: (
models.ShelfBook.objects.filter(
shelf__user=u,
book__parent_work__editions=b,
).first()
or False
),
user,
book,
timeout=15552000,
)
or {"book": book}
)
@register.simple_tag(takes_context=False)