wip describe file form

This commit is contained in:
crunk 2024-05-27 14:25:25 +02:00
parent 23ac3e7699
commit d301ab8b53
4 changed files with 40 additions and 5 deletions

View File

@ -1,5 +1,5 @@
from flask import Blueprint, render_template, redirect, url_for
from flask_login import current_user
from flask_login import current_user, login_required
from models.distribusi_model import Distribusis
from models.distribusi_file_model import DistribusiFiles
from describer.forms.describe_file_form import DescribeFileForm
@ -13,6 +13,7 @@ describer = Blueprint(
@describer.route("/<string:distribusiname>")
@login_required
def describe_distribusi_files(distribusiname):
if not current_user.is_authenticated:
return redirect(url_for("index"))
@ -30,3 +31,12 @@ def describe_distribusi_files(distribusiname):
distribusi_files=distribusi_files,
describe_form=describe_form,
)
@describer.route("/describe_file", methods=["POST"])
@login_required
def describe_file(file_name):
describe_form = DescribeFileForm()
if describe_form.validate_on_submit():
print(f"{file_name} description: {describe_form.description.data}")
return

View File

@ -11,21 +11,18 @@ class DescribeFileForm(FlaskForm):
alttext = StringField(
"Alt-text for this file:",
validators=[
validators.InputRequired(),
Length(3, 255),
],
)
searchtags = StringField(
"Add search tags, seperated by commas. No need for the '#' sign:",
validators=[
validators.InputRequired(),
Length(3, 500),
],
)
description = StringField(
"Description of this file:",
validators=[
validators.InputRequired(),
Length(3, 4096),
],
)

View File

@ -29,6 +29,34 @@
<div class="distribusi_files">
{% for file in distribusi_files %}
<p>{{file.path}}</p>
<form method="POST" enctype="multipart/form-data" action="{{ url_for('describer.describe_file') }}">
{{ describe_form.csrf_token }}
<fieldset class="">
{{ describe_form.description.label }}
{{ describe_form.description }}
{% for message in describe_form.description.errors %}
<div class="error">{{ message }}</div>
{% endfor %}
</fieldset>
<fieldset class="">
{{ describe_form.searchtags.label }}
{{ describe_form.searchtags }}
{% for message in describe_form.searchtags.errors %}
<div class="error">{{ message }}</div>
{% endfor %}
</fieldset>
<fieldset class="">
{{ describe_form.alttext.label }}
{{ describe_form.alttext }}
{% for message in describe_form.alttext.errors %}
<div class="error">{{ message }}</div>
{% endfor %}
</fieldset>
<fieldset class="button">
{{ describe_form.save }}
</fieldset>
</form>
{% endfor%}
</div>
{% endblock %}

View File

@ -30,7 +30,7 @@ APP = create_app()
stash_page = Blueprint("stash_page", __name__, static_folder="stash")
APP.register_blueprint(stash_page)
APP.register_blueprint(describer, url_prefix="/describe")
APP.register_blueprint(describer, url_prefix="/describer")
APP.register_blueprint(login_section, url_prefix="/login")
APP.register_blueprint(register_user, url_prefix="/register")
APP.register_blueprint(forgot_password, url_prefix="/login/forgotpassword")