WIP uploadform, Up next is the CSV writer

This commit is contained in:
crunk 2021-03-07 19:55:47 +01:00
parent a34cc1f634
commit 469dfdd892
10 changed files with 204 additions and 5 deletions

0
__init.py__ Normal file
View File

View File

@ -1 +0,0 @@
,shambler,caprice,14.02.2021 19:03,file:///home/shambler/.config/libreoffice/4;

View File

@ -7,6 +7,7 @@ from icalendar import Calendar
import datetime
from flask import render_template
from rnrfeed.rnrfeeder import getevents, getlatestevent
from uploadform import PublicationForm
from csvparser.csvparser import (
getlicenses,
getpublications,
@ -14,8 +15,13 @@ from csvparser.csvparser import (
getyears,
getfullpublication,
)
from flask_wtf.csrf import CSRFProtect
csrf = CSRFProtect()
APP = flask.Flask(__name__, static_folder="static")
APP.config['SECRET_KEY'] = 'ty4425hk54a21eee5719b9s9df7sdfklx'
csrf.init_app(APP)
@APP.route("/")
@ -35,6 +41,12 @@ def index():
return template
@APP.route("/upload")
def upload():
uploadform = PublicationForm()
return render_template("upload.html", uploadform=uploadform)
@APP.route("/<publicationID>")
def show_book(publicationID):
"""route for a publication, still needs to be made"""

View File

@ -0,0 +1,45 @@
#uploadform {
max-width: 60%;
margin-top: 3em;
margin-left: 1em;
margin-right: 1em;
padding: 1em;
z-index: 10;
border: 3px solid black;
background-color: #f1f1f1;
border-spacing: 0;
border-collapse: collapse;
clear: both;
position: relative;
}
.uploadform-field {
margin: 0;
padding: 1em;
}
input[type=text], select {
width: 100%;
padding: 1em 3em;
padding-left: 0.5em;
margin: 1em 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type=submit] {
background-color: #DD4F77;
text-align: right;
color: white;
padding: 1em 3em;
margin: 1em 1em;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type=submit]:hover {
background-color: #404d81;
}

View File

@ -6,6 +6,7 @@
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style.css')}}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/dropdown.css')}}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/bookmark.css')}}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/upload.css')}}">
</head>
<body>
<div id="cloud"></div>

View File

@ -9,7 +9,7 @@
<h2>{{ eventtitle }}</h2>
{{ text[0]|safe }}
<hr>
<p>For those interested in this read and repair event the physical library at varia offers the following books:</p>
<p>For those interested to learn more on the topics of this read and repair event the physical library at varia offers the following books:</p>
<ul>
{% for link, booktitle in text[1].items() %}
<li><a href="/{{ link }}">{{ booktitle }}</a></li>

View File

@ -8,8 +8,8 @@
{% if upcoming %}
<h2 id="upcomingevent">Upcoming event!</h2>
{% else %}
<p id="latestevent">Unfortunately this Read&Repair event has already happened, keep an eye on <a href="http://varia.zone/">Varia.zone</a>
or this site for upcoming Read&Repair and other varia events!</p>
<p id="latestevent">Unfortunately this Read&Repair event has already happened, keep an eye on <a href="http://varia.zone/">varia.zone</a>
or this site for upcoming Read&Repair and other Varia events!</p>
{% endif %}
<h2>{{ event.title }}</h2>
{{ event.description|safe }}

View File

@ -0,0 +1,76 @@
{% extends "base.html" %}
{% block main %}
<div id="nav" class="container">
<button id="leftmostbtn"><a href="/">All books</a></button>
<button><a href="/upload">Upload</a></button>
</div>
<div id="uploadform">
<h2 id="uploadformtitle">Upload a new book</h2>
<form method="POST" action="{{ url_for('upload') }}">
<fieldset class="uploadform-field">
{{ uploadform.uploadpublication.label }}
{{ uploadform.uploadpublication(size=20) }}
</fieldset>
<fieldset class="uploadform-field">
{{ uploadform.author.label }}
{{ uploadform.author }}
</fieldset>
<fieldset class="uploadform-field">
{{ uploadform.year.label }}
{{ uploadform.year }}
</fieldset>
<fieldset class="uploadform-field">
{{ uploadform.custodian.label }}
{{ uploadform.custodian(size=20) }}
</fieldset>
<fieldset class="uploadform-field">
{{ uploadform.fields.label }}
{{ uploadform.fields }}
</fieldset>
<fieldset class="uploadform-field">
{{ uploadform.type.label }}
{{ uploadform.type }}
</fieldset>
<fieldset class="uploadform-field">
{{ uploadform.publishers.label }}
{{ uploadform.publishers(size=20) }}
</fieldset>
<fieldset class="uploadform-field">
{{ uploadform.license.label }}
{{ uploadform.license }}
</fieldset>
<fieldset class="uploadform-field">
{{ uploadform.licenseshort.label }}
{{ uploadform.licenseshort }}
</fieldset>
<fieldset class="uploadform-field">
{{ uploadform.highlights.label }}
{{ uploadform.highlights(size=20) }}
</fieldset>
<fieldset class="uploadform-field">
{{ uploadform.comments.label }}
{{ uploadform.comments }}
</fieldset>
<fieldset class="uploadform-field">
{{ uploadform.borrowed.label }}
{{ uploadform.borrowed }}
</fieldset>
{{ uploadform.submit }}
</form>
</div>
<script src="{{ url_for('static', filename='js/dropdown.js')}}"></script>
{% endblock %}

63
library/uploadform.py Normal file
View File

@ -0,0 +1,63 @@
"""Form object declaration."""
from flask_wtf import FlaskForm
from wtforms import StringField, IntegerField, TextField, RadioField, SubmitField
from wtforms.validators import DataRequired, Length
class PublicationForm(FlaskForm):
"""Contact form."""
uploadpublication = StringField(
'Title of the publication:',
[DataRequired()]
)
author = StringField(
'The author or editor:',
[DataRequired()]
)
year = IntegerField(
'Year:',
[DataRequired()]
)
custodian = StringField(
'Custodian:',
[DataRequired()]
)
fields = StringField(
'Fields:',
[DataRequired()]
)
type = StringField(
'Type:',
[DataRequired()]
)
publishers = StringField(
'Publishers:',
[DataRequired()]
)
license = StringField(
'License:',
[DataRequired()]
)
licenseshort = RadioField(
'Select the closest license type:',
choices = [
('Anti-copyright','Anti-copyright'),
('No License Mentioned','No License Mentioned'),
('Free Art License','Free Art License'),
('Copyright','Copyright'),
('Copyleft','Copyleft'),
('Creative Commons','Creative Commons'),
('Public Domain','Public Domain'),
('GNU Free Documentation License','GNU Free Documentation License'),
]
)
highlights = TextField(
'Highlights from the publication:'
)
comments = TextField(
'Comments on the publication:'
)
borrowed = StringField(
'Currently borrowed by:'
)
submit = SubmitField('Submit')

View File

@ -1,2 +1,5 @@
flask
icalendar
feedparser
flask
flask_wtf
requests