mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 19:57:29 +01:00
Add package count to languages editor
This commit is contained in:
parent
b1a9398ed1
commit
fe40a7c6d4
@ -21,7 +21,7 @@ from flask_wtf import FlaskForm
|
|||||||
from wtforms import StringField, TextAreaField, SubmitField
|
from wtforms import StringField, TextAreaField, SubmitField
|
||||||
from wtforms.validators import InputRequired, Length, Optional
|
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 app.utils import add_audit_log, rank_required
|
||||||
from . import bp
|
from . import bp
|
||||||
|
|
||||||
@ -29,7 +29,9 @@ from . import bp
|
|||||||
@bp.route("/admin/languages/")
|
@bp.route("/admin/languages/")
|
||||||
@rank_required(UserRank.ADMIN)
|
@rank_required(UserRank.ADMIN)
|
||||||
def language_list():
|
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):
|
class LanguageForm(FlaskForm):
|
||||||
|
@ -847,6 +847,8 @@ class Language(db.Model):
|
|||||||
id = db.Column(db.String(10), primary_key=True)
|
id = db.Column(db.String(10), primary_key=True)
|
||||||
title = db.Column(db.String(100), unique=True, nullable=False)
|
title = db.Column(db.String(100), unique=True, nullable=False)
|
||||||
|
|
||||||
|
packages = db.relationship("Package", secondary="package_translation", lazy="dynamic")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_contentdb_translation(self):
|
def has_contentdb_translation(self):
|
||||||
return self.id in app.config["LANGUAGES"].keys()
|
return self.id in app.config["LANGUAGES"].keys()
|
||||||
|
@ -5,21 +5,27 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<a class="btn btn-primary float-end" href="{{ url_for('admin.create_edit_language') }}">{{ _("New Tag") }}</a>
|
<a class="btn btn-primary float-end" href="{{ url_for('admin.create_edit_language') }}">New Language</a>
|
||||||
|
|
||||||
<h1>{{ _("Languages") }}</h1>
|
<h1>{{ _("Languages") }}</h1>
|
||||||
|
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
<div class="row text-muted">
|
<div class="row text-muted">
|
||||||
<div class="col-2">
|
<div class="col-1">
|
||||||
{{ _("Id") }}
|
{{ _("Id") }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col">
|
<div class="col-2">
|
||||||
{{ _("Title") }}
|
{{ _("Title") }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-1">
|
||||||
|
{{ _("Packages") }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col"></div>
|
||||||
|
|
||||||
<div class="col-3 text-end">
|
<div class="col-3 text-end">
|
||||||
{{ _("Has ContentDB translation?") }}
|
{{ _("Has ContentDB translation?") }}
|
||||||
</div>
|
</div>
|
||||||
@ -27,15 +33,31 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% for l in languages %}
|
{% 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 %}
|
||||||
<a class="list-group-item list-group-item-action"
|
<a class="list-group-item list-group-item-action"
|
||||||
href="{{ url_for('admin.create_edit_language', id_=l.id) }}">
|
href="{{ url_for('admin.create_edit_language', id_=l.id) }}">
|
||||||
<div class="row">
|
<div class="row align-items-center justify-content-center">
|
||||||
<div class="col-2">
|
<div class="col-1">
|
||||||
{{ l.id }}
|
{{ l.id }}
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col-2">
|
||||||
{{ l.title }}
|
{{ l.title }}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-1">
|
||||||
|
{{ lang_package_count }}
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<div class="progress">
|
||||||
|
<div class="progress-bar" role="progressbar"
|
||||||
|
style="width: {{ 100 * lang_package_count / total_package_count }}%;"
|
||||||
|
aria-valuenow="{{ lang_package_count }}" aria-valuemin="0" aria-valuemax="{{ total_package_count }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="col-3 text-end">
|
<div class="col-3 text-end">
|
||||||
{% if l.has_contentdb_translation %}
|
{% if l.has_contentdb_translation %}
|
||||||
<i class="fas fa-check text-success"></i>
|
<i class="fas fa-check text-success"></i>
|
||||||
|
Loading…
Reference in New Issue
Block a user