Browse Source

WIP uploadform, Up next is the CSV writer

master
crunk 4 years ago
parent
commit
469dfdd892
  1. 0
      __init.py__
  2. 1
      library/csvparser/.~lock.varlib.csv#
  3. 12
      library/page.py
  4. 45
      library/static/css/upload.css
  5. 1
      library/templates/base.html
  6. 2
      library/templates/pastevents.html
  7. 4
      library/templates/upcomingevent.html
  8. 76
      library/templates/upload.html
  9. 63
      library/uploadform.py
  10. 5
      requirements.txt

0
__init.py__

1
library/csvparser/.~lock.varlib.csv#

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

12
library/page.py

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

45
library/static/css/upload.css

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

1
library/templates/base.html

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

2
library/templates/pastevents.html

@ -9,7 +9,7 @@
<h2>{{ eventtitle }}</h2> <h2>{{ eventtitle }}</h2>
{{ text[0]|safe }} {{ text[0]|safe }}
<hr> <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> <ul>
{% for link, booktitle in text[1].items() %} {% for link, booktitle in text[1].items() %}
<li><a href="/{{ link }}">{{ booktitle }}</a></li> <li><a href="/{{ link }}">{{ booktitle }}</a></li>

4
library/templates/upcomingevent.html

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

76
library/templates/upload.html

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

@ -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')

5
requirements.txt

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

Loading…
Cancel
Save