test commit

geo
Alice 7 years ago
parent 720e8d8469
commit cc191859bd

@ -4,7 +4,7 @@ from wtforms.validators import InputRequired, DataRequired
from wtforms import FieldList
from wtforms import Form as NoCsrfForm
from wtforms.fields import StringField, FormField, SubmitField, SelectField
from app.models import Book, BookSchema, Author
from app.models import Book, BookSchema, Author, Stack, StackSchema
# - - - Forms - - -
class AuthorForm(NoCsrfForm):
@ -25,11 +25,14 @@ class EditForm(FlaskForm):
author = FieldList(FormField(AuthorForm, default=lambda: Author()), min_entries=1)
category = StringField('category', validators=[InputRequired()])
year_published = StringField('year published', [validators.Length(max=4)],default=None)
class ChatForm(FlaskForm):
message = StringField('message', validators=[InputRequired()])
send = SubmitField(label='Send')
class StackForm(FlaskForm):
stack_name = StringField('Stack', validators=[InputRequired()])
stack_description = StringField('Description', validators=[InputRequired()])
create = SubmitField(label='Create')
class SearchForm(FlaskForm):
choices = [('All', 'All'),

@ -1,4 +1,3 @@
{% extends 'base.html' %}
{% block main %}
<div class="container">
@ -9,7 +8,7 @@
<p>Stack description:
{% for stack in stacks %}
{{stack.stack_description}}
<a href="{{url_for('show_stack_by_id', id=stack.id)}}">{{ stack.stack_description }}</a>
{% endfor %}
</p>
@ -22,7 +21,7 @@
<br>
<br>
<p><a href="{{url_for('show_stacks')}}">Go back to stacks</p>
</div>
{% endblock %}

@ -7,36 +7,25 @@
<table style="width:100%">
<!--
<td> {% for stack in stacks %}
<li><a href="{{url_for('show_stack_by_id', id=stack.id)}}">{{ stack.stack_name }}</a> </li>
<div id="tabs">
<ul>
{% for stack in stacks %}
{% endfor %}
</td>
<li> <a href="stacks/{{ stack.id }}">{{ stack.stack_name }}</a></td>
</table>
-->
<div id="tabs">
<ul>
{% for stack in stacks %}
<li><a href="#tabs-1">{{ stack.stack_name }}</a></li>
{% endfor %}
</ul>
<div id="tabs-1">
<h2>Stack description</h2>
<p>This stack is nice.</p>
</div>
</div>
<br>
<br>
<h1 class="page-header">Build a stack</h1>
<p><a href= {{ url_for('add_stack') }}>Add Stack</a></p>
<div id="draggable" class="ui-widget-content">
<p>List of books</p>
</div>

@ -9,7 +9,7 @@ from app import app, db, socketio, DOMAIN
from flask import Flask, Response, render_template, request, redirect, url_for, flash, send_from_directory, jsonify, abort
import json
from sqlalchemy.sql.expression import func, select
from app.forms import UploadForm, EditForm, SearchForm, ChatForm
from app.forms import UploadForm, EditForm, SearchForm, ChatForm, StackForm
from app.models import Book, BookSchema, Author, AuthorSchema, Stack, StackSchema, UserIns, Chat, ChatSchema
from app.cover import get_cover
from os import environ
@ -263,6 +263,39 @@ def show_stacks():
stacks = db.session.query(Stack).all()
return render_template('show_stacks.html', stacks=stacks)
@app.route('/stacks/add_stack', methods=['POST', 'GET'])
def add_stack():
form = StackForm()
stacks = db.session.query(Stack).all()
#if request.method == 'GET':
# return render_template('add_stack.html', stacks=stacks, form=form)
if request.method == 'POST':
stack_name = form.stack_name.data
stack_description = form.stack_description.data
stack = Stack(stack_name, stack_description)
if form.stack_name.data:
stack = Stack(stack_name, stack_description)
db.session.add(stack)
stacks = db.session.query(Stack).all()
#this potentially deals with the connection between books and stacks
#book = Book(title, filename, cover, file_extension, category,year_published)
#for book in books:
# book_title = book.get("title")
# if book_title:
# a = db.session.query(Book).filter_by(book_title=book_title).first()
# if a == None:
# a = Book(book_title=book_title)
# db.session.add(a)
# stacks.book.append(a)
#db.session.commit()
flash("%s stack created" % (stack_name))
return render_template('add_stack.html', stacks=stacks, form=form)
@app.route('/stacks/<int:id>', methods=['POST', 'GET'])
def show_stack_by_id(id):
stack = Stack.query.get(id)

@ -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['Shelf'], None)
book = Book(row['Title'], row['Filename'], cover, row['Format'], row['Category'], None)
db.session.add(book)
authors = row['Author'].split(',')

@ -1,5 +1,4 @@
Title,Author,Shelf,Format,OCR,Downloaded,Origin,Filename,Stack
Mac OS X Leopard Edition,David Pogue,Technical,pdf,1,1,LibGen,,
Title,Author,Category,Format,OCR,Downloaded,Origin,Filename,Stack
The Qmail Handbook,Dave Sill,Technical,pdf,1,1,LibGen,,
Hardening Network Infrastructure: Bulletproof Your Systems Before You Are Hacked!,Wes Noonan,Technical,"chm, pdf",1,1,LibGen,,Make a library
Cocoa Programming for Mac OS X Second Edition,Aaron Hillegaas,Technical,pdf,1,1,LibGen,,

1 Title Author Shelf Category Format OCR Downloaded Origin Filename Stack
Mac OS X Leopard Edition David Pogue Technical pdf 1 1 LibGen
2 The Qmail Handbook Dave Sill Technical pdf 1 1 LibGen
3 Hardening Network Infrastructure: Bulletproof Your Systems Before You Are Hacked! Wes Noonan Technical chm, pdf 1 1 LibGen Make a library
4 Cocoa Programming for Mac OS X Second Edition Aaron Hillegaas Technical pdf 1 1 LibGen
Loading…
Cancel
Save