diff --git a/app/forms.py b/app/forms.py
index e3b74cc..f652c5c 100755
--- a/app/forms.py
+++ b/app/forms.py
@@ -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'),
diff --git a/app/templates/show_stack_detail.html b/app/templates/show_stack_detail.html
index 816bbc2..8cee949 100644
--- a/app/templates/show_stack_detail.html
+++ b/app/templates/show_stack_detail.html
@@ -1,4 +1,3 @@
-{% extends 'base.html' %}
{% block main %}
{% endblock %}
diff --git a/app/templates/show_stacks.html b/app/templates/show_stacks.html
index 27a01ce..613f971 100644
--- a/app/templates/show_stacks.html
+++ b/app/templates/show_stacks.html
@@ -7,36 +7,25 @@
-
-
-
-
-
Stack description
-
This stack is nice.
-
-
+
+
+Add Stack
+
diff --git a/app/views.py b/app/views.py
index 768342a..2d04837 100755
--- a/app/views.py
+++ b/app/views.py
@@ -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/', methods=['POST', 'GET'])
def show_stack_by_id(id):
stack = Stack.query.get(id)
diff --git a/import_csv.py b/import_csv.py
index b0a178e..e3dd830 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['Shelf'], None)
+ book = Book(row['Title'], row['Filename'], cover, row['Format'], row['Category'], None)
db.session.add(book)
authors = row['Author'].split(',')
diff --git a/xpublibrary.csv b/xpublibrary.csv
index acd4299..54f8003 100644
--- a/xpublibrary.csv
+++ b/xpublibrary.csv
@@ -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,,