new upload form questions

master
nberting 7 years ago
parent 93bf8a6b93
commit 8fa8200c49

@ -5,6 +5,8 @@ from wtforms import FieldList
from wtforms import Form as NoCsrfForm
from wtforms.fields import StringField, FormField, SubmitField, SelectField, RadioField
from app.models import Book, BookSchema, Author, Stack, StackSchema
from wtforms.fields.html5 import DecimalRangeField
# - - - Forms - - -
class AuthorForm(NoCsrfForm):
@ -20,6 +22,19 @@ class UploadForm(FlaskForm):
upload = SubmitField(label='Upload')
wish = SubmitField(label='''I don't have the file, but wish I did.''')
message = StringField('message', default=None)
sameness = DecimalRangeField('sameness', default=0)
diversity = DecimalRangeField('diversity', default=0)
gender = DecimalRangeField('gender', default=50)
time = StringField('time', [validators.Length(max=5)],default=None)
choices = [('Student', 'Student'),
('Librarian', 'Librarian'),
('Pirate', 'Pirate'),
('Teacher', 'Teacher'),
('Institution', 'Institution'),
('All of the above', 'All of the above'),
('None of the above', 'None of the above')]
who = SelectField('', choices=choices, default='Student')
class EditForm(FlaskForm):
title = StringField('title', validators=[InputRequired()])

@ -26,7 +26,6 @@ class Book(db.Model):
category = db.Column(db.String(255))
year_published = db.Column(db.Numeric(4,0))
description = db.Column(db.String(2500))
html = db.Column(db.String(255))
authors = db.relationship('Author', secondary=authors,cascade="delete", lazy='subquery',
backref=db.backref('books', lazy=True),passive_deletes=True)
stacks = db.relationship('Stack', secondary=stacks, lazy='subquery',
@ -34,9 +33,14 @@ class Book(db.Model):
scapeX = db.Column(db.Numeric(10,2))
scapeY = db.Column(db.Numeric(10,2))
message = db.Column(db.String(1000))
sameness = db.Column(db.Numeric())
diversity = db.Column(db.Numeric())
gender = db.Column(db.Numeric())
who = db.Column(db.String(255))
time = db.Column(db.Numeric())
def __init__(self, title, file, cover, fileformat, category, year_published, message):
def __init__(self, title, file, cover, fileformat, category, year_published, message, sameness, diversity, gender, who, time):
self.title = title
self.file = file
self.cover = cover
@ -46,6 +50,11 @@ class Book(db.Model):
self.scapeX = 0
self.scapeY = 0
self.message = message
self.sameness = sameness
self.diversity = diversity
self.gender = gender
self.who = who
self.time = time
def __repr__(self):

@ -1,6 +1,21 @@
{% extends 'base.html' %}
{% block main %}
{% from "_formhelpers.html" import render_field %}
<head>
<script>
function outputUpdate(sameness) {
document.querySelector('#selected-sameness').value = sameness;
}
function outputUpdate2(diversity) {
document.querySelector('#selected-diversity').value = diversity;
}
function outputUpdate3(gender) {
document.querySelector('#selected-gender').value = gender;
}
</script>
</head>
<div class="container" style="float: left; width:50%;">
<div style="width: 98%; border-right: dashed; border-width: 1px;">
@ -18,10 +33,10 @@
{% endwith %}
<form method="POST" action="{{ url_for('add_book') }}" enctype=multipart/form-data>
{{ form.csrf_token }}
<div class="form-group">Title: {{ form.title (size=34, class="form-control") }}</div>
<div class="form-group">Title:* <br> {{ form.title (size=50, class="form-control") }}</div>
<br>
<div data-toggle="fieldset" id="phone-fieldset">
Author(s): <button type="button" data-toggle="fieldset-add-row data-target="#phone-fieldset">+</button>
Author(s):* <button type="button" data-toggle="fieldset-add-row data-target="#phone-fieldset">+</button>
<table>
<tr>
<th></th>
@ -29,19 +44,43 @@
</tr>
{% for author in form.author %}
<tr data-toggle="fieldset-entry">
<td>{{ author.author_name (size=40)}}</td>
<td>{{ author.author_name (size=50)}}</td>
<td><button type="button" data-toggle="fieldset-remove-row" id="phone-{{loop.index0}}-remove">-</button></td>
</tr>
{% endfor %}
</table>
</div>
<br>
Category: {{ form.category(size=27, class="form-control") }}
<br>
<br>
Year published: {{ form.year_published(size=8, class="form-control") }}
<br>
Category:* <br> {{ form.category(size=50, class="form-control") }} <br><br>
Year published: <br> {{ form.year_published(size=8, class="form-control") }} <br><br>
How different is this item to the rest of the collection?
Or is it more of the same? <br>
{{ form.sameness(min=0, max=100, oninput="outputUpdate(value)") }} &nbsp;
<span style="color: #d3d3d3;"><output for="sameness" id="selected-sameness">{{ form.sameness.data }} </output> % different</span>
<br><hr align="left" style="width:96%;"><br>
Check the bibliography. How diverse are the references in this book? <br>
{{ form.diversity(min=0, max=100, oninput="outputUpdate2(value)") }} &nbsp;
<span style="color: #d3d3d3;"><output for="diversity" id="selected-diversity">{{ form.diversity.data }} </output> % diverse</span>
<br><hr align="left" style="width:96%;"><br>
Check the writing. Who is speaking? Is the voice more often male or female? <br>
{{ form.diversity(min=1, max=100, oninput="outputUpdate3(value)") }} &nbsp;
<span style="color: #d3d3d3;"><output for="diversity" id="selected-gender">{{ form.gender.data }} </output> % female</span>
<br><hr align="left" style="width:96%;"><br>
Who are you? {{ render_field(form.who) }}
<br><hr align="left" style="width:96%;"><br>
How much time have you spent with this item?
Include the time spent looking for it, and uploading it.<br>
{{ form.time (size = 50, class="form-control")}} <span style="color: #d3d3d3;">hours</span>
<br>
<br><hr align="left" style="width:96%;"><br>
<div style="width: 40%;">
Add a message for future readers: {{ form.message(size=90, class="form-control") }}
<br></div>
@ -49,11 +88,12 @@
{{ form.file }}
{{ form.upload }}
{{ form.wish }}
</div>
</form>
</div>
<div>
<table class="library_table" id="table" style="width:30% padding:10px;" >
<table class="library_table" id="table" style="width:30% padding:10px; padding-bottom: 400px;" >
<thead>
<tr id="header" style="height:15px;">
<th style="width: 10%;"> <h5> Currently in the library </h5></th>
@ -90,4 +130,5 @@
</table>
</div>
</div>
<clear>
{% endblock %}

@ -3,16 +3,16 @@
{% block main %}
<div class="container">
<h1 class="header">{{ book.title }}</h1>
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="180" onerror="if (this.src != '../uploads/cover/{{ book.cover }}') this.src = '../static/img/default_cover.gif';">
<div style="float:right; padding-right: 140px;">
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="280px" onerror="if (this.src != '../uploads/cover/{{ book.cover }}') this.src = '../static/img/default_cover.gif';"></div>
<table class="library_table" id="table" style="width:50%; padding-bottom: 20px;">
<thead>
<table class="library_table" id="table" style="width:50%; padding-bottom: 80px;">
<thead>
<tr id="header">
<th style="width: 150px;"></th>
<th style="width: 500px;"></th>
<th style="width: 300px;"></th>
</tr>
</thead>
</thead>
<tbody>
<tr>
<td>Year published: </td>
@ -21,9 +21,7 @@
<tr>
<td> Author(s): </td>
<td>{% for author in book.authors %}
<a href="{{url_for('show_author_by_id', id=author.id)}}">{{ author.author_name }}</a><br>
{% endfor %}</td>
</tr>
<tr>
@ -36,6 +34,34 @@
<li><a href="{{url_for('show_stack_by_id', id=stack.id)}}">{{ stack.stack_name }}</a>
<p style="font-size: 10px;"><a href="{{url_for('remove_from_stack', stackid=stack.id, bookid=book.id)}}"> Remove from stack</a>{% endfor %}</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td style="font-style: italic;">Notes from uploader</td>
<td></td>
</tr>
<tr>
<td>How different is this item to the rest of the collection?<br></td>
<td>{{ book.sameness or '?'}} % different</td>
</tr>
<tr>
<td>How diverse are the references in this book?<br></td>
<td>{{ book.diversity or '?' }} % diverse </td>
</tr>
<tr>
<td>Who is speaking?<br></td>
<td>{{ book.gender or '?' }} % female </td>
</tr>
<tr>
<td>Who is uploading<br></td>
<td>{{ book.who or '?' }} </td>
</tr>
<tr>
<td>How much time has been spent with this item?<br></td>
<td>{{ book.time or '?' }} </td>
</tr>
</tbody>
</table>
@ -55,6 +81,7 @@
<button style= "font-size: 10pt;"> <a href="{{ url_for('edit_book_by_id', id=book.id )}}">edit</a></button>
<button style= "font-size: 10pt;"> <a href="{{ url_for('remove_book_by_id', id=book.id)}}">delete</a></button>
<br><br>
<hr>
{% if previousbook %}
<a href="{{ url_for('show_book_by_id', id=previousbook.id )}}" style="font-size: 9pt;"> < see the previous book added to XPPL: &nbsp;<i>{{ previousbook.title |truncate(40,True,'...') }} </i></a> {% endif %}

@ -220,6 +220,12 @@ def add_book():
category = upload_form.category.data
message = upload_form.message.data
year_published = upload_form.year_published.data
sameness = upload_form.sameness.data
gender = upload_form.gender.data
diversity = upload_form.diversity.data
time = upload_form.time.data
who = upload_form.who.data
if year_published=="":
year_published = None
@ -263,7 +269,7 @@ def add_book():
html.write_pdf(target='app/uploads/potential.pdf');
print ('potential_pdf')
book = Book(title, filename, cover, file_extension, category, year_published, message)
book = Book(title, filename, cover, file_extension, category, year_published, message, sameness, diversity, gender, who, time)
db.session.add(book)
for author in authors:
author_name = author.get("author_name")

@ -20,7 +20,7 @@ with open(args.csv) as f:
print ('get_cover', fullpath, name)
cover = get_cover(fullpath, name)
book = Book(row['Title'], row['Filename'], cover, row['Format'], row['Category'], None, '')
book = Book(row['Title'], row['Filename'], cover, row['Format'], row['Category'], None, None, None, None, None, None, None)
db.session.add(book)
authors = row['Author'].split(',')

Loading…
Cancel
Save