diff --git a/verse/describer/describe_files.py b/verse/describer/describe_files.py index 015597a..62ec170 100644 --- a/verse/describer/describe_files.py +++ b/verse/describer/describe_files.py @@ -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("/") +@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 diff --git a/verse/describer/forms/describe_file_form.py b/verse/describer/forms/describe_file_form.py index 2125642..0a97b3e 100644 --- a/verse/describer/forms/describe_file_form.py +++ b/verse/describer/forms/describe_file_form.py @@ -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), ], ) diff --git a/verse/describer/templates/describe_files/describe.html b/verse/describer/templates/describe_files/describe.html index 22b486d..6b30b14 100644 --- a/verse/describer/templates/describe_files/describe.html +++ b/verse/describer/templates/describe_files/describe.html @@ -29,6 +29,34 @@
{% for file in distribusi_files %}

{{file.path}}

+
+ {{ describe_form.csrf_token }} +
+ {{ describe_form.description.label }} + {{ describe_form.description }} + {% for message in describe_form.description.errors %} +
{{ message }}
+ {% endfor %} +
+
+ {{ describe_form.searchtags.label }} + {{ describe_form.searchtags }} + {% for message in describe_form.searchtags.errors %} +
{{ message }}
+ {% endfor %} +
+
+ {{ describe_form.alttext.label }} + {{ describe_form.alttext }} + {% for message in describe_form.alttext.errors %} +
{{ message }}
+ {% endfor %} +
+
+ {{ describe_form.save }} +
+
{% endfor%}
+ {% endblock %} diff --git a/verse/start.py b/verse/start.py index 0b3be38..0796441 100644 --- a/verse/start.py +++ b/verse/start.py @@ -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")