Add package collections

Fixes #378
This commit is contained in:
rubenwardy
2023-08-14 21:48:50 +01:00
parent bf20177756
commit f7a5a1218f
17 changed files with 702 additions and 10 deletions

View File

@@ -19,7 +19,7 @@ from flask import Blueprint, render_template
from flask_login import current_user
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, Collection
bp = Blueprint("donate", __name__)
@@ -30,7 +30,8 @@ def donate():
if current_user.is_authenticated:
reviewed_packages = Package.query.filter(
Package.state == PackageState.APPROVED,
Package.reviews.any(and_(PackageReview.author_id == current_user.id, PackageReview.rating >= 3)),
or_(Package.reviews.any(and_(PackageReview.author_id == current_user.id, PackageReview.rating >= 3)),
Package.collections.any(and_(Collection.author_id == current_user.id, Collection.name == "favorites"))),
or_(Package.donate_url.isnot(None), Package.author.has(User.donate_url.isnot(None)))
).order_by(db.asc(Package.title)).all()