Przeglądaj źródła

fix: utiliser le champ name en fallback quand label est null (apps YunoHost)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cedric Hansen 2 tygodni temu
rodzic
commit
17dbe42863
2 zmienionych plików z 5 dodań i 4 usunięć
  1. 3 3
      sources/blueprints/jobs.py
  2. 2 1
      sources/templates/job_form.html

+ 3 - 3
sources/blueprints/jobs.py

@@ -30,7 +30,7 @@ def index():
         for j in jobs
     }
     instances = RemoteInstance.query.order_by(RemoteInstance.name).all()
-    ynh_app_labels = {a["id"]: a.get("label", "") for a in get_ynh_apps()}
+    ynh_app_labels = {a["id"]: a.get("label") or a.get("name", "") for a in get_ynh_apps()}
     return render_template("dashboard_local.html", jobs=jobs, last_runs=last_runs,
                            instances=instances, ynh_app_labels=ynh_app_labels)
 
@@ -154,7 +154,7 @@ def job_toggle(job_id):
 def job_history(job_id):
     job = db.get_or_404(Job, job_id)
     runs = Run.query.filter_by(job_id=job_id).order_by(Run.started_at.desc()).limit(100).all()
-    ynh_app_labels = {a["id"]: a.get("label", "") for a in get_ynh_apps()} if job.type == "ynh_app" else {}
+    ynh_app_labels = {a["id"]: a.get("label") or a.get("name", "") for a in get_ynh_apps()} if job.type == "ynh_app" else {}
     return render_template("job_history.html", job=job, runs=runs, ynh_app_labels=ynh_app_labels)
 
 
@@ -178,7 +178,7 @@ def archives():
             runs_by_archive[run.archive_name] = run
     jobs_by_id = {j.id: j for j in Job.query.all()}
 
-    ynh_app_labels = {a["id"]: a.get("label", "") for a in get_ynh_apps()}
+    ynh_app_labels = {a["id"]: a.get("label") or a.get("name", "") for a in get_ynh_apps()}
 
     items = []
     for name in sorted_names:

+ 2 - 1
sources/templates/job_form.html

@@ -49,7 +49,8 @@
             {% for ynh_app in ynh_apps %}
               <option value="{{ ynh_app.id }}"
                       {% if ynh_app.id == current_app_id %}selected{% endif %}>
-                {{ ynh_app.id }}{% if ynh_app.label %} — {{ ynh_app.label }}{% endif %}
+                {% set _display = ynh_app.label or ynh_app.name %}
+                {{ ynh_app.id }}{% if _display %} — {{ _display }}{% endif %}
               </option>
             {% endfor %}
             {% if not ynh_apps %}