Browse Source

wip describe file form

pull/12/head
crunk 4 months ago
parent
commit
d301ab8b53
  1. 12
      verse/describer/describe_files.py
  2. 3
      verse/describer/forms/describe_file_form.py
  3. 28
      verse/describer/templates/describe_files/describe.html
  4. 2
      verse/start.py

12
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("/<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

3
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),
],
)

28
verse/describer/templates/describe_files/describe.html

@ -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 %}

2
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")

Loading…
Cancel
Save