Add overview stat to languages editor

This commit is contained in:
rubenwardy 2024-03-03 00:47:38 +00:00
parent fe40a7c6d4
commit ffdd0bbafd
2 changed files with 7 additions and 2 deletions

@ -21,7 +21,7 @@ from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, SubmitField
from wtforms.validators import InputRequired, Length, Optional
from app.models import db, AuditSeverity, UserRank, Language, Package, PackageState
from app.models import db, AuditSeverity, UserRank, Language, Package, PackageState, PackageTranslation
from app.utils import add_audit_log, rank_required
from . import bp
@ -29,9 +29,11 @@ from . import bp
@bp.route("/admin/languages/")
@rank_required(UserRank.ADMIN)
def language_list():
at_least_one_count = db.session.query(PackageTranslation.package_id).group_by(PackageTranslation.package_id).count()
total_package_count = Package.query.filter_by(state=PackageState.APPROVED).count()
return render_template("admin/languages/list.html",
languages=Language.query.all(), total_package_count=total_package_count)
languages=Language.query.all(), total_package_count=total_package_count,
at_least_one_count=at_least_one_count)
class LanguageForm(FlaskForm):

@ -8,6 +8,9 @@
<a class="btn btn-primary float-end" href="{{ url_for('admin.create_edit_language') }}">New Language</a>
<h1>{{ _("Languages") }}</h1>
<p>
{{ at_least_one_count }} packages support at least one language other than English.
</p>
<div class="list-group">
<div class="list-group-item">