Fix crash on donate page

This commit is contained in:
rubenwardy 2023-04-30 00:27:10 +01:00
parent b1570d4632
commit 4c66b25e7c
2 changed files with 4 additions and 4 deletions

@ -1,6 +1,6 @@
from flask import Blueprint, render_template from flask import Blueprint, render_template
from flask_login import current_user from flask_login import current_user
from sqlalchemy import or_ from sqlalchemy import or_, and_
from app.models import User, Package, PackageState, db, License, PackageReview from app.models import User, Package, PackageState, db, License, PackageReview
@ -13,7 +13,7 @@ def donate():
if current_user.is_authenticated: if current_user.is_authenticated:
reviewed_packages = Package.query.filter( reviewed_packages = Package.query.filter(
Package.state == PackageState.APPROVED, Package.state == PackageState.APPROVED,
Package.reviews.any(PackageReview.author_id == current_user.id, PackageReview.rating >= 3), Package.reviews.any(and_(PackageReview.author_id == current_user.id, PackageReview.rating >= 3)),
or_(Package.donate_url.isnot(None), Package.author.has(User.donate_url.isnot(None))) or_(Package.donate_url.isnot(None), Package.author.has(User.donate_url.isnot(None)))
).order_by(db.asc(Package.title)).all() ).order_by(db.asc(Package.title)).all()

@ -1,8 +1,8 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %} {% block title -%}
{{ _("Support packages") }} {{ _("Support packages") }}
{% endblock %} {%- endblock %}
{% macro authorlink(author) %} {% macro authorlink(author) %}
<a href="{{ url_for('users.profile', username=author.username) }}"> <a href="{{ url_for('users.profile', username=author.username) }}">