diff --git a/app/blueprints/homepage/__init__.py b/app/blueprints/homepage/__init__.py index 4f6d5ebb..37c18001 100644 --- a/app/blueprints/homepage/__init__.py +++ b/app/blueprints/homepage/__init__.py @@ -21,7 +21,8 @@ def home(): pop_mod = join(query.filter_by(type=PackageType.MOD).order_by(db.desc(Package.score))).limit(8).all() pop_gam = join(query.filter_by(type=PackageType.GAME).order_by(db.desc(Package.score))).limit(4).all() pop_txp = join(query.filter_by(type=PackageType.TXP).order_by(db.desc(Package.score))).limit(4).all() + reviews = PackageReview.query.filter_by(recommends=True).order_by(db.desc(PackageReview.created_at)).limit(5).all() downloads_result = db.session.query(func.sum(Package.downloads)).one_or_none() downloads = 0 if not downloads_result or not downloads_result[0] else downloads_result[0] return render_template("index.html", count=count, downloads=downloads, \ - new=new, pop_mod=pop_mod, pop_txp=pop_txp, pop_gam=pop_gam) + new=new, pop_mod=pop_mod, pop_txp=pop_txp, pop_gam=pop_gam, reviews=reviews) diff --git a/app/models.py b/app/models.py index e026c778..f89fb6fa 100644 --- a/app/models.py +++ b/app/models.py @@ -1118,6 +1118,8 @@ class PackageReview(db.Model): package_id = db.Column(db.Integer, db.ForeignKey("package.id"), nullable=True) package = db.relationship("Package", foreign_keys=[package_id], backref=db.backref("reviews", lazy=True)) + created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow) + author_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False) author = db.relationship("User", foreign_keys=[author_id], backref=db.backref("reviews", lazy=True)) diff --git a/app/templates/index.html b/app/templates/index.html index a7574d63..84c1d06d 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -20,20 +20,6 @@ {% endblock %} {% block content %} - {% from "macros/packagegridtile.html" import render_pkggrid %} @@ -64,6 +50,11 @@
+ {% if show_package_link %} + + {{ _("View %(title)s by %(author)s", title=review.package.title, author=review.package.author.display_name) }} + + {% endif %} + + + + {{ _("%(num)d comments", num=review.thread.replies.count() - 1) }} + +