moved form code to application folder
This commit is contained in:
parent
b435b159e3
commit
f393f7389f
@ -22,7 +22,7 @@ Or run `make`.
|
|||||||
* currently this software is broken.
|
* currently this software is broken.
|
||||||
|
|
||||||
## readme driven development
|
## readme driven development
|
||||||
* add regular login instead of a secret key
|
* add regular login instead of a secret key ✅
|
||||||
* have a settings file for the application ✅
|
* have a settings file for the application ✅
|
||||||
* downloadable pdfs
|
* downloadable pdfs
|
||||||
* upon boot check for images of the book otherwise extract front page of pdfs
|
* upon boot check for images of the book otherwise extract front page of pdfs
|
||||||
|
@ -16,11 +16,4 @@ class BorrowForm(FlaskForm):
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
secret = StringField(
|
|
||||||
"Librarians secret:",
|
|
||||||
[
|
|
||||||
validators.InputRequired(),
|
|
||||||
Length(min=2, message="Fill in the secret to unlock to library."),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
submit = SubmitField("Borrow")
|
submit = SubmitField("Borrow")
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
"""Form object declaration."""
|
|
||||||
from flask_wtf import FlaskForm
|
|
||||||
from wtforms import StringField, SubmitField, validators
|
|
||||||
from wtforms.validators import Length
|
|
||||||
|
|
||||||
|
|
||||||
class BorrowForm(FlaskForm):
|
|
||||||
"""Borrow a publication form."""
|
|
||||||
|
|
||||||
borrowed = StringField(
|
|
||||||
"Fill in your name if you're going to borrow this publication.",
|
|
||||||
[
|
|
||||||
validators.InputRequired(),
|
|
||||||
Length(
|
|
||||||
min=3, message="Just so we know who is borrowing this book."
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
secret = StringField(
|
|
||||||
"Librarians secret:",
|
|
||||||
[
|
|
||||||
validators.InputRequired(),
|
|
||||||
Length(min=2, message="Fill in the secret to unlock to library."),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
submit = SubmitField("Borrow")
|
|
@ -1,14 +0,0 @@
|
|||||||
"""Forgotten password form to help user."""
|
|
||||||
from flask_wtf import FlaskForm
|
|
||||||
from wtforms import StringField, SubmitField, validators
|
|
||||||
from wtforms.validators import Email, Length
|
|
||||||
|
|
||||||
|
|
||||||
class ForgotPasswordForm(FlaskForm):
|
|
||||||
"""Forgotten password csv-library form"""
|
|
||||||
|
|
||||||
email = StringField(
|
|
||||||
"Email address:",
|
|
||||||
validators=[validators.InputRequired(), Email(), Length(6, 64)],
|
|
||||||
)
|
|
||||||
submit = SubmitField("Send email")
|
|
@ -1,17 +0,0 @@
|
|||||||
"""Login form to validate user."""
|
|
||||||
from flask_wtf import FlaskForm
|
|
||||||
from wtforms import PasswordField, StringField, SubmitField, validators
|
|
||||||
from wtforms.validators import Email, Length
|
|
||||||
|
|
||||||
|
|
||||||
class LoginForm(FlaskForm):
|
|
||||||
"""Login csv-library form"""
|
|
||||||
|
|
||||||
email = StringField(
|
|
||||||
"Email address:",
|
|
||||||
validators=[validators.InputRequired(), Email(), Length(6, 64)],
|
|
||||||
)
|
|
||||||
password = PasswordField(
|
|
||||||
"Password:", validators=[validators.InputRequired()]
|
|
||||||
)
|
|
||||||
submit = SubmitField("Sign In")
|
|
@ -1,37 +0,0 @@
|
|||||||
"""Register form to make a new user."""
|
|
||||||
from flask_wtf import FlaskForm
|
|
||||||
from wtforms import PasswordField, StringField, SubmitField, validators
|
|
||||||
from wtforms.validators import Email, EqualTo, Length, ValidationError
|
|
||||||
|
|
||||||
|
|
||||||
class RegisterForm(FlaskForm):
|
|
||||||
"""Register for csv-library form"""
|
|
||||||
|
|
||||||
username = StringField(
|
|
||||||
"Username:",
|
|
||||||
validators=[validators.InputRequired(), Length(3, 150)],
|
|
||||||
)
|
|
||||||
|
|
||||||
email = StringField(
|
|
||||||
"Email address:",
|
|
||||||
validators=[
|
|
||||||
validators.InputRequired(),
|
|
||||||
Email(),
|
|
||||||
Length(6, 64),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
password = PasswordField(
|
|
||||||
"New password:",
|
|
||||||
validators=[validators.InputRequired(), Length(12, 72)],
|
|
||||||
)
|
|
||||||
|
|
||||||
confirmpassword = PasswordField(
|
|
||||||
"Confirm your password:",
|
|
||||||
validators=[
|
|
||||||
validators.InputRequired(),
|
|
||||||
Length(12, 72),
|
|
||||||
EqualTo("password", message="Passwords must match !"),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
submit = SubmitField("Register to the library")
|
|
@ -1,22 +0,0 @@
|
|||||||
"""Reset Password Form form to reset a users PasswordField."""
|
|
||||||
from flask_wtf import FlaskForm
|
|
||||||
from wtforms import PasswordField, SubmitField, validators
|
|
||||||
from wtforms.validators import EqualTo, Length
|
|
||||||
|
|
||||||
|
|
||||||
class ResetPasswordForm(FlaskForm):
|
|
||||||
"""ResetPassword for csv-library form"""
|
|
||||||
|
|
||||||
password = PasswordField(
|
|
||||||
"New password:",
|
|
||||||
validators=[validators.InputRequired(), Length(12, 72)],
|
|
||||||
)
|
|
||||||
confirmpassword = PasswordField(
|
|
||||||
"Confirm your password:",
|
|
||||||
validators=[
|
|
||||||
validators.InputRequired(),
|
|
||||||
Length(12, 72),
|
|
||||||
EqualTo("password", message="Passwords must match !"),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
submit = SubmitField("Reset your password")
|
|
@ -1,76 +0,0 @@
|
|||||||
"""Form object declaration."""
|
|
||||||
from flask_wtf import FlaskForm
|
|
||||||
from flask_wtf.file import FileAllowed, FileField
|
|
||||||
from wtforms import (
|
|
||||||
IntegerField,
|
|
||||||
RadioField,
|
|
||||||
StringField,
|
|
||||||
SubmitField,
|
|
||||||
validators,
|
|
||||||
)
|
|
||||||
from wtforms.validators import Length, NumberRange
|
|
||||||
|
|
||||||
|
|
||||||
class PublicationForm(FlaskForm):
|
|
||||||
"""Publication upload form."""
|
|
||||||
|
|
||||||
uploadpublication = StringField(
|
|
||||||
"Title of the publication:",
|
|
||||||
[
|
|
||||||
validators.InputRequired(),
|
|
||||||
Length(
|
|
||||||
min=3, message="A publication in the library needs a title."
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
author = StringField(
|
|
||||||
"The author or editor:",
|
|
||||||
[
|
|
||||||
validators.InputRequired(),
|
|
||||||
Length(
|
|
||||||
min=3,
|
|
||||||
message=(
|
|
||||||
"If the author or editor is not known just type unkown."
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
year = IntegerField(
|
|
||||||
"Year:",
|
|
||||||
[validators.InputRequired(), NumberRange(min=0, max=2050)],
|
|
||||||
default=2023,
|
|
||||||
)
|
|
||||||
fields = StringField("Fields:")
|
|
||||||
type = StringField(
|
|
||||||
"Type of publication:",
|
|
||||||
[
|
|
||||||
validators.InputRequired(),
|
|
||||||
Length(
|
|
||||||
min=3,
|
|
||||||
message=(
|
|
||||||
"Here you can use terms such as zine, paperback,"
|
|
||||||
" hardcover."
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
publishers = StringField("Publishers:")
|
|
||||||
license = StringField("License:")
|
|
||||||
highlights = StringField("Highlights from the publication:")
|
|
||||||
comments = StringField("Comments on the publication:")
|
|
||||||
image = FileField(
|
|
||||||
"Image of the book:",
|
|
||||||
validators=[FileAllowed(["jpg", "png", "gif"], "Images only!")],
|
|
||||||
)
|
|
||||||
pdf = FileField(
|
|
||||||
"Pdf of the book:",
|
|
||||||
validators=[FileAllowed(["pdf"], "Only pdf uploads supported")],
|
|
||||||
)
|
|
||||||
secret = StringField(
|
|
||||||
"Librarians secret:",
|
|
||||||
[
|
|
||||||
validators.InputRequired(),
|
|
||||||
Length(min=2, message="Fill in the secret to unlock to library."),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
submit = SubmitField("Submit")
|
|
@ -90,9 +90,7 @@ def show_book(publicationID):
|
|||||||
fullpublication = csvparser.getfullpublication(publicationID)
|
fullpublication = csvparser.getfullpublication(publicationID)
|
||||||
borrowform = BorrowForm()
|
borrowform = BorrowForm()
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
if borrowform.validate_on_submit() and checksecret(
|
if borrowform.validate_on_submit():
|
||||||
borrowform.secret.data
|
|
||||||
):
|
|
||||||
editborrowedby(publicationID, borrowform.borrowed.data)
|
editborrowedby(publicationID, borrowform.borrowed.data)
|
||||||
fullpublication["Borrowed"] = borrowform.borrowed.data
|
fullpublication["Borrowed"] = borrowform.borrowed.data
|
||||||
return render_template(
|
return render_template(
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block main %}
|
{% block main %}
|
||||||
<div id="nav" class="container">
|
<div id="nav" class="menu">
|
||||||
<button id="leftmostbtn"><a href="/">Back to books</a></button>
|
<div class="dropdown">
|
||||||
<button><a href="/upload">Upload</a></button>
|
<button><a href="/">Back to books</a></button>
|
||||||
|
</div>
|
||||||
|
<div class="dropdown">
|
||||||
|
<button><a href="/upload">Upload</a></button>
|
||||||
|
</div>
|
||||||
<div class="dropdown" style="visibility: hidden">
|
<div class="dropdown" style="visibility: hidden">
|
||||||
<button id="Year" class="dropbtn">Year</button>
|
<button id="Year" class="dropbtn">Year</button>
|
||||||
</div>
|
</div>
|
||||||
@ -92,17 +96,7 @@
|
|||||||
<div class="error">{{ message }}</div>
|
<div class="error">{{ message }}</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="uploadform-field">
|
|
||||||
{{ uploadform.secret.label }}
|
|
||||||
{{ uploadform.secret }}
|
|
||||||
{% for message in uploadform.secret.errors %}
|
|
||||||
<div class="error">{{ message }}</div>
|
|
||||||
{% endfor %}
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
{{ uploadform.submit }}
|
{{ uploadform.submit }}
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="logout">
|
<div class="auth">
|
||||||
<a href="/logout">
|
<a href="/logout">
|
||||||
<svg class="feather">
|
<svg class="feather">
|
||||||
<use href="{{ url_for('static', filename='icons/users-feather-sprite.svg') + '#log-out'}}" />
|
<use href="{{ url_for('static', filename='icons/users-feather-sprite.svg') + '#log-out'}}" />
|
||||||
|
Loading…
Reference in New Issue
Block a user