wip describe file now shows the files to be described
This commit is contained in:
parent
30f69cf03c
commit
8cf5ca198b
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
.eggs/
|
.eggs/
|
||||||
|
.ruff_cache
|
||||||
build/
|
build/
|
||||||
dist/
|
dist/
|
||||||
pip-wheel-metadata/
|
pip-wheel-metadata/
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
from flask import Blueprint, render_template, redirect, url_for
|
from flask import (
|
||||||
|
Blueprint,
|
||||||
|
render_template,
|
||||||
|
redirect,
|
||||||
|
url_for,
|
||||||
|
send_from_directory,
|
||||||
|
)
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from models.distribusi_model import Distribusis
|
from models.distribusi_model import Distribusis
|
||||||
from models.distribusi_file_model import DistribusiFiles
|
from models.distribusi_file_model import DistribusiFiles
|
||||||
@ -31,7 +37,9 @@ def show_distribusi_files(distribusiname):
|
|||||||
@login_required
|
@login_required
|
||||||
def describe_file(file_id):
|
def describe_file(file_id):
|
||||||
distribusi_file = DistribusiFiles.query.filter_by(id=file_id).first()
|
distribusi_file = DistribusiFiles.query.filter_by(id=file_id).first()
|
||||||
describe_form = DescribeFilesForm(distribusi_file.id, distribusi_file.path)
|
describe_form = DescribeFilesForm(
|
||||||
|
distribusi_file.id, distribusi_file.path, distribusi_file.type
|
||||||
|
)
|
||||||
print(
|
print(
|
||||||
f"file: {describe_form.file_path} description: {describe_form.description.data}"
|
f"file: {describe_form.file_path} description: {describe_form.description.data}"
|
||||||
)
|
)
|
||||||
@ -41,14 +49,20 @@ def describe_file(file_id):
|
|||||||
print(
|
print(
|
||||||
f"file: {describe_form.file_path} alttext: {describe_form.alttext.data}"
|
f"file: {describe_form.file_path} alttext: {describe_form.alttext.data}"
|
||||||
)
|
)
|
||||||
distribusi_file_forms = get_distribusi_file_forms(
|
distribusi = Distribusis.query.filter_by(
|
||||||
distribusi_file.distribusi
|
id=distribusi_file.distribusi
|
||||||
)
|
).first()
|
||||||
return render_template(
|
return redirect(
|
||||||
"describe.html",
|
url_for(
|
||||||
distribusi_file_forms=distribusi_file_forms,
|
"describer.show_distribusi_files",
|
||||||
|
distribusiname=distribusi.distribusiname,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@describer.route("/stash/<path:path>")
|
||||||
|
def send_stash_file(path):
|
||||||
|
return send_from_directory("stash", path)
|
||||||
|
|
||||||
|
|
||||||
def get_distribusi_file_forms(distribusi_id):
|
def get_distribusi_file_forms(distribusi_id):
|
||||||
distribusi_file_forms = {}
|
distribusi_file_forms = {}
|
||||||
@ -57,7 +71,7 @@ def get_distribusi_file_forms(distribusi_id):
|
|||||||
).all()
|
).all()
|
||||||
for distribusi_file in distribusi_files:
|
for distribusi_file in distribusi_files:
|
||||||
describe_form = DescribeFilesForm(
|
describe_form = DescribeFilesForm(
|
||||||
distribusi_file.id, distribusi_file.path
|
distribusi_file.id, distribusi_file.path, distribusi_file.type
|
||||||
)
|
)
|
||||||
describe_form.description.data = distribusi_file.description
|
describe_form.description.data = distribusi_file.description
|
||||||
describe_form.alttext.data = distribusi_file.alttext
|
describe_form.alttext.data = distribusi_file.alttext
|
||||||
|
@ -30,10 +30,11 @@ class DescribeFilesForm(FlaskForm):
|
|||||||
)
|
)
|
||||||
save = SubmitField("Save")
|
save = SubmitField("Save")
|
||||||
|
|
||||||
def __init__(self, id, file_path=None):
|
def __init__(self, id, file_path=None, type=None):
|
||||||
super(DescribeFilesForm, self).__init__()
|
super(DescribeFilesForm, self).__init__()
|
||||||
self.id = id
|
self.id = id
|
||||||
self.file_path = file_path
|
self.file_path = file_path
|
||||||
|
self.type = type
|
||||||
self.alttext.id = f"alttext-{id}"
|
self.alttext.id = f"alttext-{id}"
|
||||||
self.searchtags.id = f"searchtags-{id}"
|
self.searchtags.id = f"searchtags-{id}"
|
||||||
self.description.id = f"description-{id}"
|
self.description.id = f"description-{id}"
|
||||||
|
@ -28,10 +28,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="distribusi_files">
|
<div class="distribusi_files">
|
||||||
{% for id, describe_form in distribusi_file_forms.items() %}
|
{% for id, describe_form in distribusi_file_forms.items() %}
|
||||||
|
<div class="distribusi_file">
|
||||||
|
{% if describe_form.type == "image" %}
|
||||||
|
<img src="{{describe_form.file_path}}" alt="" />
|
||||||
|
{% elif describe_form.type == "video" %}
|
||||||
|
<video src="{{describe_form.file_path}}" preload="auto" alt="" controls></video>
|
||||||
|
{% elif describe_form.type == "audio" %}
|
||||||
|
<audio src="{{describe_form.file_path}}" preload="auto" alt="" controls></audio>
|
||||||
|
{% else %}
|
||||||
|
<a href="{{describe_form.file_path}}">file: {{describe_form.file_path}}</a>
|
||||||
|
{% endif %}
|
||||||
<form id={{id}} method="POST" enctype="multipart/form-data" action="{{ url_for('describer.describe_file', file_id=id) }}">
|
<form id={{id}} method="POST" enctype="multipart/form-data" action="{{ url_for('describer.describe_file', file_id=id) }}">
|
||||||
{{ describe_form.csrf_token }}
|
{{ describe_form.csrf_token }}
|
||||||
<p>{{describe_form.id}}</p>
|
<p>File path: {{describe_form.file_path}}</p>
|
||||||
<p>{{describe_form.file_path}}</p>
|
|
||||||
<fieldset class="">
|
<fieldset class="">
|
||||||
{{ describe_form.description.label }}
|
{{ describe_form.description.label }}
|
||||||
{{ describe_form.description }}
|
{{ describe_form.description }}
|
||||||
@ -57,6 +66,7 @@
|
|||||||
{{ describe_form.save }}
|
{{ describe_form.save }}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
{% endfor%}
|
{% endfor%}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -174,6 +174,23 @@ a:active {
|
|||||||
content: "$ ";
|
content: "$ ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.distribusi_file {
|
||||||
|
margin-top: 1em;
|
||||||
|
padding: 0.5em;
|
||||||
|
padding-left: auto;
|
||||||
|
padding-right: auto;
|
||||||
|
width: 45em;
|
||||||
|
background-color:#fdfdfd;
|
||||||
|
text-decoration: none;
|
||||||
|
scroll-behavior: smooth;
|
||||||
|
border-style: outset;
|
||||||
|
}
|
||||||
|
|
||||||
|
.distribusi_file > img, video {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
@media (prefers-reduced-motion: no-preference) {
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
@keyframes flash {
|
@keyframes flash {
|
||||||
50% { opacity: 0; }
|
50% { opacity: 0; }
|
||||||
|
Loading…
Reference in New Issue
Block a user