diff --git a/app/blueprints/admin/languageseditor.py b/app/blueprints/admin/languageseditor.py index 18e45749..d4137a73 100644 --- a/app/blueprints/admin/languageseditor.py +++ b/app/blueprints/admin/languageseditor.py @@ -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 +from app.models import db, AuditSeverity, UserRank, Language, Package, PackageState from app.utils import add_audit_log, rank_required from . import bp @@ -29,7 +29,9 @@ from . import bp @bp.route("/admin/languages/") @rank_required(UserRank.ADMIN) def language_list(): - return render_template("admin/languages/list.html", languages=Language.query.all()) + 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) class LanguageForm(FlaskForm): diff --git a/app/models/packages.py b/app/models/packages.py index 85c3da04..fc0bef62 100644 --- a/app/models/packages.py +++ b/app/models/packages.py @@ -847,6 +847,8 @@ class Language(db.Model): id = db.Column(db.String(10), primary_key=True) title = db.Column(db.String(100), unique=True, nullable=False) + packages = db.relationship("Package", secondary="package_translation", lazy="dynamic") + @property def has_contentdb_translation(self): return self.id in app.config["LANGUAGES"].keys() diff --git a/app/templates/admin/languages/list.html b/app/templates/admin/languages/list.html index 580ad8dd..24f5417e 100644 --- a/app/templates/admin/languages/list.html +++ b/app/templates/admin/languages/list.html @@ -5,21 +5,27 @@ {% endblock %} {% block content %} - {{ _("New Tag") }} + New Language

{{ _("Languages") }}

-
+
{{ _("Id") }}
-
+
{{ _("Title") }}
+
+ {{ _("Packages") }} +
+ +
+
{{ _("Has ContentDB translation?") }}
@@ -27,15 +33,31 @@
{% for l in languages %} + {% if l.id == "en" %} + {% set lang_package_count = total_package_count %} + {% else %} + {% set lang_package_count = l.packages.filter_by(state='APPROVED').count() %} + {% endif %} -
-
+
+
{{ l.id }}
-
+
{{ l.title }}
+
+ {{ lang_package_count }} +
+
+
+
+
+
+
{% if l.has_contentdb_translation %}