Show review language on reviews

This commit is contained in:
rubenwardy 2024-06-09 11:50:21 +01:00
parent b6e7e09171
commit 663fb38d9f
3 changed files with 10 additions and 4 deletions

@ -18,7 +18,7 @@ from flask import Blueprint, render_template, redirect
from sqlalchemy import and_ from sqlalchemy import and_
from app.models import Package, PackageReview, Thread, User, PackageState, db, PackageType, PackageRelease, Tags, Tag, \ from app.models import Package, PackageReview, Thread, User, PackageState, db, PackageType, PackageRelease, Tags, Tag, \
Collection, License Collection, License, Language
bp = Blueprint("homepage", __name__) bp = Blueprint("homepage", __name__)
@ -77,9 +77,10 @@ def home():
def review_load(query): def review_load(query):
return query.options( return query.options(
load_only(PackageReview.id, PackageReview.rating, PackageReview.created_at, raiseload=True), load_only(PackageReview.id, PackageReview.rating, PackageReview.created_at, PackageReview.language_id, raiseload=True),
joinedload(PackageReview.author).load_only(User.username, User.rank, User.email, User.display_name, User.profile_pic, User.is_active, raiseload=True), joinedload(PackageReview.author).load_only(User.username, User.rank, User.email, User.display_name, User.profile_pic, User.is_active, raiseload=True),
joinedload(PackageReview.votes), joinedload(PackageReview.votes),
joinedload(PackageReview.language).load_only(Language.title, raiseload=True),
joinedload(PackageReview.thread).load_only(Thread.title, Thread.replies_count, raiseload=True).subqueryload(Thread.first_reply), joinedload(PackageReview.thread).load_only(Thread.title, Thread.replies_count, raiseload=True).subqueryload(Thread.first_reply),
joinedload(PackageReview.package) joinedload(PackageReview.package)
.load_only(Package.title, Package.name, raiseload=True) .load_only(Package.title, Package.name, raiseload=True)

@ -143,8 +143,8 @@ def review(package):
url_for("threads.view", id=thread.id), package) url_for("threads.view", id=thread.id), package)
if was_new: if was_new:
post_discord_webhook.delay(thread.author.display_name, msg = f"Reviewed {package.title} ({review.language.title}): {thread.get_view_url(absolute=True)}"
"Reviewed {}: {}".format(package.title, thread.get_view_url(absolute=True)), False) post_discord_webhook.delay(thread.author.display_name, msg, False)
db.session.commit() db.session.commit()

@ -63,6 +63,11 @@
<i class="fas fa-pen"></i> <i class="fas fa-pen"></i>
</a> </a>
{% endif %} {% endif %}
{% if review.language %}
<span class="float-end mx-2 text-muted">
{{ review.language.title }}
</span>
{% endif %}
<p> <p>
<strong>{{ review.thread.title }}</strong> <strong>{{ review.thread.title }}</strong>