|
@@ -349,12 +349,16 @@ def _save_job(job):
|
|
|
if job_type == "ynh_app":
|
|
if job_type == "ynh_app":
|
|
|
cfg = {"app_id": f.get("app_id", ""), "core_only": f.get("core_only") == "1"}
|
|
cfg = {"app_id": f.get("app_id", ""), "core_only": f.get("core_only") == "1"}
|
|
|
elif job_type == "ynh_system":
|
|
elif job_type == "ynh_system":
|
|
|
- selected = f.getlist("system_hooks")
|
|
|
|
|
all_hooks = {"conf_ynh_settings", "conf_ynh_firewall", "conf_ssowat", "conf_nginx",
|
|
all_hooks = {"conf_ynh_settings", "conf_ynh_firewall", "conf_ssowat", "conf_nginx",
|
|
|
"conf_ynh_certs", "conf_ynh_domain", "conf_ynh_user", "data_home", "data_mail"}
|
|
"conf_ynh_certs", "conf_ynh_domain", "conf_ynh_user", "data_home", "data_mail"}
|
|
|
|
|
+ selected = [h for h in f.getlist("system_hooks") if h in all_hooks]
|
|
|
if not selected:
|
|
if not selected:
|
|
|
flash("Sélectionnez au moins un hook système.", "error")
|
|
flash("Sélectionnez au moins un hook système.", "error")
|
|
|
- return render_template("job_form.html", job=job,
|
|
|
|
|
|
|
+ # Pour un nouveau job, on crée un objet temporaire (non persisté) pour
|
|
|
|
|
+ # que le template puisse pré-remplir le nom et le type.
|
|
|
|
|
+ job_for_form = job or Job(name=name, type=job_type,
|
|
|
|
|
+ cron_expr=(f.get("cron_expr") or "").strip())
|
|
|
|
|
+ return render_template("job_form.html", job=job_for_form,
|
|
|
ynh_apps=get_ynh_apps(exclude_app_ids=_used_app_ids(exclude_job_id=job.id if job else None)),
|
|
ynh_apps=get_ynh_apps(exclude_app_ids=_used_app_ids(exclude_job_id=job.id if job else None)),
|
|
|
destinations=Destination.query.filter_by(enabled=True).all(),
|
|
destinations=Destination.query.filter_by(enabled=True).all(),
|
|
|
remote_instances=RemoteInstance.query.order_by(RemoteInstance.name).all())
|
|
remote_instances=RemoteInstance.query.order_by(RemoteInstance.name).all())
|
|
@@ -436,7 +440,7 @@ def _save_job(job):
|
|
|
if t.startswith("dest:") else
|
|
if t.startswith("dest:") else
|
|
|
JobDestination(dest_type="instance", dest_id=int(t[5:]))
|
|
JobDestination(dest_type="instance", dest_id=int(t[5:]))
|
|
|
for t in transfer_targets
|
|
for t in transfer_targets
|
|
|
- if t.startswith("dest:") or t.startswith("inst:")
|
|
|
|
|
|
|
+ if (t.startswith("dest:") or t.startswith("inst:")) and t[5:].isdigit()
|
|
|
]
|
|
]
|
|
|
job.updated_at = datetime.utcnow()
|
|
job.updated_at = datetime.utcnow()
|
|
|
db.session.commit()
|
|
db.session.commit()
|