diff --git a/app/forms.py b/app/forms.py index 6089ca9..f314919 100755 --- a/app/forms.py +++ b/app/forms.py @@ -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()]) diff --git a/app/models.py b/app/models.py index 2f6f119..8bdc1c2 100755 --- a/app/models.py +++ b/app/models.py @@ -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): diff --git a/app/templates/add_book.html b/app/templates/add_book.html index cf5dac6..6326174 100755 --- a/app/templates/add_book.html +++ b/app/templates/add_book.html @@ -1,6 +1,21 @@ {% extends 'base.html' %} {% block main %} +{% from "_formhelpers.html" import render_field %} + + + +
@@ -18,10 +33,10 @@ {% endwith %}
{{ form.csrf_token }} -
Title: {{ form.title (size=34, class="form-control") }}
+
Title:*
{{ form.title (size=50, class="form-control") }}

- Author(s): + Author(s):* @@ -29,19 +44,43 @@ {% for author in form.author %} - + {% endfor %}
{{ author.author_name (size=40)}}{{ author.author_name (size=50)}}

- Category: {{ form.category(size=27, class="form-control") }} -
-
- Year published: {{ form.year_published(size=8, class="form-control") }} -
+ Category:*
{{ form.category(size=50, class="form-control") }}

+ Year published:
{{ form.year_published(size=8, class="form-control") }}

+ +How different is this item to the rest of the collection? +Or is it more of the same?
+{{ form.sameness(min=0, max=100, oninput="outputUpdate(value)") }}   +{{ form.sameness.data }} % different + +


+ +Check the bibliography. How diverse are the references in this book?
+{{ form.diversity(min=0, max=100, oninput="outputUpdate2(value)") }}   +{{ form.diversity.data }} % diverse + +


+ +Check the writing. Who is speaking? Is the voice more often male or female?
+{{ form.diversity(min=1, max=100, oninput="outputUpdate3(value)") }}   +{{ form.gender.data }} % female + +


+Who are you? {{ render_field(form.who) }} + +


+How much time have you spent with this item? +Include the time spent looking for it, and uploading it.
+{{ form.time (size = 50, class="form-control")}} hours
+


+
Add a message for future readers: {{ form.message(size=90, class="form-control") }}
@@ -49,11 +88,12 @@ {{ form.file }} {{ form.upload }} {{ form.wish }} +
- +
@@ -90,4 +130,5 @@
+ {% endblock %} diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html index 19e8c64..54deecd 100755 --- a/app/templates/show_book_detail.html +++ b/app/templates/show_book_detail.html @@ -3,17 +3,17 @@ {% block main %}

{{ book.title }}

- +
+
- - - - - - - - - +
+ + + + + + + @@ -21,21 +21,47 @@ + {{ author.author_name }}
+ {% endfor %} - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Year published: {{ book.year_published or '––'}}
Author(s): {% for author in book.authors %} - - {{ author.author_name }}
- - {% endfor %}
Category: {{ book.category }}
Included in stack(s): {% for stack in book.stacks %}
  • {{ stack.stack_name }}

    – Remove from stack{% endfor %}

  • Notes from uploader
    How different is this item to the rest of the collection?
    {{ book.sameness or '?'}} % different
    How diverse are the references in this book?
    {{ book.diversity or '?' }} % diverse
    Who is speaking?
    {{ book.gender or '?' }} % female
    Who is uploading
    {{ book.who or '?' }}
    How much time has been spent with this item?
    {{ book.time or '?' }}
    @@ -55,6 +81,7 @@

    +
    {% if previousbook %} < see the previous book added to XPPL:  {{ previousbook.title |truncate(40,True,'...') }} {% endif %} diff --git a/app/views.py b/app/views.py index a55aa8a..424abff 100755 --- a/app/views.py +++ b/app/views.py @@ -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") diff --git a/import_csv.py b/import_csv.py index bca2b12..af53fbe 100644 --- a/import_csv.py +++ b/import_csv.py @@ -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(',')