mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-09 17:13:45 +01:00
Add recent positive reviews to homepage
This commit is contained in:
parent
25b481ac0a
commit
75ab56cad1
@ -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)
|
||||
|
@ -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))
|
||||
|
||||
|
@ -20,20 +20,6 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<!-- <header class="jumbotron">
|
||||
<div class="container">
|
||||
<h1 class="display-3">{{ config.USER_APP_NAME }}</h1>
|
||||
|
||||
<p class="lead">
|
||||
Minetest's official content repository.
|
||||
Browse {{ count }} packages,
|
||||
the majority of which are available under a free
|
||||
and open source license.
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="container"> -->
|
||||
{% from "macros/packagegridtile.html" import render_pkggrid %}
|
||||
|
||||
|
||||
@ -64,6 +50,11 @@
|
||||
<h2 class="my-3">{{ _("Top Texture Packs") }}</h2>
|
||||
{{ render_pkggrid(pop_txp) }}
|
||||
|
||||
|
||||
<h2 class="my-3">{{ _("Recent Positive Reviews") }}</h2>
|
||||
{% from "macros/reviews.html" import render_reviews %}
|
||||
{{ render_reviews(reviews, True) }}
|
||||
|
||||
<div class="text-center">
|
||||
<small>
|
||||
{{ _("CDB has %(count)d packages, with a total of %(downloads)d downloads.", count=count, downloads=downloads) }}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% macro render_reviews(reviews) -%}
|
||||
{% macro render_reviews(reviews, show_package_link=False) -%}
|
||||
<ul class="comments mt-4 mb-0">
|
||||
{% for review in reviews %}
|
||||
<li class="row my-2 mx-0">
|
||||
@ -37,10 +37,18 @@
|
||||
|
||||
{{ reply.comment | markdown }}
|
||||
|
||||
<p class="mt-2 mb-0">
|
||||
{% if show_package_link %}
|
||||
<a class="btn btn-primary mr-1" href="{{ review.package.getDetailsURL() }}">
|
||||
{{ _("View %(title)s by %(author)s", title=review.package.title, author=review.package.author.display_name) }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<a class="btn btn-primary" href="{{ url_for('threads.view', id=review.thread.id) }}">
|
||||
<i class="fas fa-comments mr-2"></i>
|
||||
{{ _("%(num)d comments", num=review.thread.replies.count() - 1) }}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -9,7 +9,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ _("Post a review for %(name)s by %(author)s", name=self.link(), author=package.author.display_name) }}</h1>
|
||||
<h1>{{ _("Post a review for %(title)s by %(author)s", title=self.link(), author=package.author.display_name) }}</h1>
|
||||
|
||||
{% from "macros/forms.html" import render_field, render_submit_field, render_radio_field %}
|
||||
<form method="POST" action="" enctype="multipart/form-data">
|
||||
|
29
migrations/versions/019da77ba02d_.py
Normal file
29
migrations/versions/019da77ba02d_.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 019da77ba02d
|
||||
Revises: 4f2e19bc2a27
|
||||
Create Date: 2020-07-09 04:07:23.926213
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import datetime
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '019da77ba02d'
|
||||
down_revision = '4f2e19bc2a27'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('package_review', sa.Column('created_at', sa.DateTime(), nullable=False, server_default=datetime.datetime.utcnow().isoformat()))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('package_review', 'created_at')
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in New Issue
Block a user