From: Christian Heller <c.heller@plomlompom.de>
Date: Thu, 20 Feb 2025 18:23:38 +0000 (+0100)
Subject: In /files view only show "show absent" option if file editing allowed.
X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/static/blog?a=commitdiff_plain;h=8fa5ccc89aaf29843a5ab8ae4d979f53905c6545;p=ytplom
In /files view only show "show absent" option if file editing allowed.
---
diff --git a/src/templates/files.tmpl b/src/templates/files.tmpl
index bb60fc2..81ae35d 100644
--- a/src/templates/files.tmpl
+++ b/src/templates/files.tmpl
@@ -81,7 +81,9 @@ function draw_files_table() {
async function update_files_list() {
const filter_path = encodeURIComponent(document.getElementById("input_filter_path").value);
let target = `${PATH_FILES_JSON}?filter_path=${filter_path}`;
+ {% if allow_show_absent %}
if (document.getElementById("input_show_absent").checked) { target = `${target}&show_absent=1`; }
+ {% endif %}
needed_tags.forEach((tag) => target = `${target}&needed_tag=${encodeURIComponent(tag)}`);
filtered_files = await wrapped_fetch(target).then((response) => response.json());
document.getElementById("files_count").textContent = `${filtered_files.length}`;
@@ -119,7 +121,9 @@ button.reverse { background-color: black; color: white; }
{% block body %}
filename pattern: <input id="input_filter_path" oninput="update_files_list()" /><br />
+{% if allow_show_absent %}
show absent: <input id="input_show_absent" type="checkbox" onclick="update_files_list()" /><br />
+{% endif %}
needed tags: <select id="tags_select" onchange="select_tag()"></select><br />
<span id="tags"></span>
<hr />
diff --git a/src/ytplom/http.py b/src/ytplom/http.py
index 4986a3c..817220a 100644
--- a/src/ytplom/http.py
+++ b/src/ytplom/http.py
@@ -314,6 +314,7 @@ class _TaskHandler(PlomHttpHandler):
with DbConn() as conn:
showable_tags = sorted(list(VideoFile.all_tags_showable(conn)))
self._send_rendered_template(_NAME_TEMPLATE_FILES, {
+ 'allow_show_absent': self.server.config.allow_file_edit,
'showable_tags': showable_tags,
'needed_tags': self.params.all_for('needed_tag')})