Fix various issues with collections

This commit is contained in:
rubenwardy 2023-08-15 20:39:32 +01:00
parent af4f03d298
commit 2ad25f1aa9
5 changed files with 22 additions and 8 deletions

@ -30,6 +30,9 @@ from app.utils import is_package_page, nonempty_or_none, add_audit_log
bp = Blueprint("collections", __name__)
regex_invalid_chars = re.compile("[^a-z0-9_]")
@bp.route("/collections/")
@bp.route("/collections/<author>/")
def list_all(author=None):
@ -120,9 +123,6 @@ def create_edit(author=None, name=None):
collection=collection, form=form)
regex_invalid_chars = re.compile("[^a-z_]")
def handle_create_edit(collection: Collection, form: CollectionForm,
initial_package: typing.Optional[Package], author: User):

@ -266,6 +266,7 @@
{% endif %}
<li class="list-inline-item"><a href="{{ url_for('users.list_all') }}">{{ _("User List") }}</a></li>
<li class="list-inline-item"><a href="{{ url_for('threads.list_all') }}">{{ _("Threads") }}</a></li>
<li class="list-inline-item"><a href="{{ url_for('collections.list_all') }}">{{ _("Collections") }}</a></li>
<li class="list-inline-item"><a href="{{ url_for('donate.donate') }}">{{ _("Support Packages") }}</a></li>
<li class="list-inline-item"><a href="https://github.com/minetest/contentdb">{{ _("Source Code") }}</a></li>
</ul>

@ -33,7 +33,10 @@
{{ _("%(title)s by %(author)s", title=package.title, author=package.author.display_name) }}
</a>
</h5>
{{ render_field(form.descriptions[loop.index - 1]) }}
<p class="text-muted">
{{ package.short_desc }}
</p>
{{ render_field(form.descriptions[loop.index - 1], hint=_("You can replace the description with your own")) }}
{{ form.package_ids[loop.index - 1]() }}
</div>
</article>

@ -8,6 +8,13 @@
{{ collection.short_description }}
{%- endblock %}
{% block headextra %}
{% set thumb_url = collection.packages and collection.packages[0].get_thumb_url(3, True) %}
{% if thumb_url -%}
<meta name="og:image" content="{{ thumb_url }}">
{%- endif %}
{% endblock %}
{% block author_link -%}
<a href="{{ url_for('users.profile', username=collection.author.username) }}">
{{ collection.author.display_name }}
@ -59,6 +66,11 @@
{% endif %}
<div class="grid-2 gap-3">
{% for item in collection.items %}
{% set package_link %}
<a href="{{ item.package.get_url('packages.view') }}">
{{ item.package.title }}
</a>
{% endset %}
<div class="">
<article class="card">
<div class="embed-responsive embed-responsive-16by9">
@ -66,9 +78,7 @@
</div>
<div class="card-body">
<h5 class="mt-0">
<a href="{{ item.package.get_url('packages.view') }}">
{{ item.package.title }}
</a>
{{ _("%(title)s by %(author)s", title=package_link, author=item.package.author.display_name) }}
</h5>
<p class="card-text">
{% if item.description %}

@ -349,7 +349,7 @@
</div>
{% if current_user.is_authenticated %}
<div class="d-flex my-3">
<div class="d-flex mt-3 mb-4">
<form method="POST" action="{{ package.get_url('collections.package_toggle_favorite') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<button type="submit" class="btn {% if is_favorited %}text-danger{% endif %} btn-secondary mr-2" aria-label="{{ _('Favorite') }}">