|
|
@ -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
|
|
|
|
from flask import Flask, Response, render_template, request, redirect, url_for, flash, send_from_directory, jsonify, abort
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
from sqlalchemy.sql.expression import func, select
|
|
|
|
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.models import Book, BookSchema, Author, AuthorSchema, Stack, StackSchema, UserIns, Chat, ChatSchema
|
|
|
|
from app.cover import get_cover
|
|
|
|
from app.cover import get_cover
|
|
|
|
from os import environ
|
|
|
|
from os import environ
|
|
|
@ -263,6 +263,39 @@ def show_stacks():
|
|
|
|
stacks = db.session.query(Stack).all()
|
|
|
|
stacks = db.session.query(Stack).all()
|
|
|
|
return render_template('show_stacks.html', stacks=stacks)
|
|
|
|
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'])
|
|
|
|
@app.route('/stacks/<int:id>', methods=['POST', 'GET'])
|
|
|
|
def show_stack_by_id(id):
|
|
|
|
def show_stack_by_id(id):
|
|
|
|
stack = Stack.query.get(id)
|
|
|
|
stack = Stack.query.get(id)
|
|
|
|