diff --git a/app/forms.py b/app/forms.py
index 6eeb292..0db4fdf 100755
--- a/app/forms.py
+++ b/app/forms.py
@@ -25,6 +25,7 @@ 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')
@@ -36,7 +37,11 @@ class StackForm(FlaskForm):
class AddtoStackForm(FlaskForm):
select_stack = SelectField('Stacks', validators=[InputRequired()])
-
+
+class EditStackForm(FlaskForm):
+ edit_stack_name = StringField('Stack', validators=[InputRequired()])
+ edit_stack_description = StringField('Description', validators=[InputRequired()])
+
class SearchForm(FlaskForm):
choices = [('All', 'All'),
('Title', 'Title'),
diff --git a/app/templates/add_to_stacks.html b/app/templates/add_to_stacks.html
index 144b15b..c2ed248 100644
--- a/app/templates/add_to_stacks.html
+++ b/app/templates/add_to_stacks.html
@@ -16,22 +16,6 @@
-
-
-
-
-
-
-Add Stack
-
-
-
-
-
{% endblock %}
diff --git a/app/templates/edit_stack_detail.html b/app/templates/edit_stack_detail.html
new file mode 100644
index 0000000..6390e23
--- /dev/null
+++ b/app/templates/edit_stack_detail.html
@@ -0,0 +1,25 @@
+{% extends 'base.html' %}
+
+{% block main %}
+
+{% endblock %}
diff --git a/app/templates/results.html b/app/templates/results.html
index 8114fcd..aa1acf7 100644
--- a/app/templates/results.html
+++ b/app/templates/results.html
@@ -33,6 +33,8 @@
Filetype |
Category |
Stack |
+ Add to stack |
+
{% for book in books %}
@@ -51,6 +53,10 @@
{{ stack.stack_name }}
{% endfor %}
+
+
+ ==>
+ |
{% endfor %}
@@ -68,6 +74,8 @@
Filetype |
Category |
Stack |
+ Add to stack |
+
{% for book in books_all %}
@@ -86,6 +94,9 @@
{{ stack.stack_name }}
{% endfor %}
+
+ ==>
+ |
{% endfor %}
diff --git a/app/templates/show_books.html b/app/templates/show_books.html
index 4171fef..e4860e7 100755
--- a/app/templates/show_books.html
+++ b/app/templates/show_books.html
@@ -63,15 +63,8 @@
- \│/
- ─ ─
- /│\
-
-
-
-
+ ==>
|
-
{% endfor %}
diff --git a/app/templates/show_stack_detail.html b/app/templates/show_stack_detail.html
index 01551de..af144cd 100644
--- a/app/templates/show_stack_detail.html
+++ b/app/templates/show_stack_detail.html
@@ -5,12 +5,14 @@
-
{{ stack.stack_description }}
Books in this stack: {% for book in stack.books %}
{{book.title}}
-
+
+
+
+
{% endfor %}
@@ -18,6 +20,9 @@
Delete
+ Edit
+
+
Go back to stacks
diff --git a/app/templates/show_stack_detail_tab.html b/app/templates/show_stack_detail_tab.html
index c8f703a..d074c2c 100644
--- a/app/templates/show_stack_detail_tab.html
+++ b/app/templates/show_stack_detail_tab.html
@@ -1,15 +1,24 @@
{% block main %}
-
+
-
Stack description: {{ stack.stack_description }}
+
+
+
{{ stack.stack_description }}
Books in this stack: {% for book in stack.books %}
-
{{book.title}}
+
{{book.title}}
+
+
+ Add to another stack
+
{% endfor %}
diff --git a/app/templates/show_stacks.html b/app/templates/show_stacks.html
index 27fd207..f1388a5 100644
--- a/app/templates/show_stacks.html
+++ b/app/templates/show_stacks.html
@@ -4,6 +4,8 @@
These are all the stacks that have been built so far.
+
Add a new stack
+
@@ -11,7 +13,11 @@
{% for stack in stacks %}
- - {{ stack.stack_name }}
+
-
+
+ {{ stack.stack_name }}
+
+
@@ -22,19 +28,7 @@
-
-
-
-
{% endblock %}
diff --git a/app/views.py b/app/views.py
index 6467899..8497647 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, session, 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, StackForm, AddtoStackForm
+from app.forms import UploadForm, EditForm, SearchForm, ChatForm, StackForm, AddtoStackForm, EditStackForm
from app.models import Book, BookSchema, Author, AuthorSchema, Stack, StackSchema, UserIns, Chat, ChatSchema
from app.cover import get_cover
from os import environ
@@ -303,6 +303,21 @@ def remove_stack_by_id(id):
db.session.commit()
return redirect(url_for('show_stacks'))
+@app.route('/stacks//edit', methods=['POST', 'GET'])
+def edit_stack_by_id(id):
+ stack = Stack.query.filter_by(id=id).first()
+ form = EditStackForm(edit_stack_name = stack.stack_name, edit_stack_description = stack.stack_description)
+
+ if request.method == 'POST':
+ if form.validate_on_submit():
+ stack_name = form.edit_stack_name.data
+ stack_description = form.edit_stack_description.data
+ stack.stack_name = stack_name
+ stack.stack_description = stack_description
+ db.session.commit()
+
+ return redirect(url_for('show_stack_by_id', id=id))
+ return render_template('edit_stack_detail.html', stack=stack, form=form)
## search
## search
diff --git a/import_csv.py b/import_csv.py
index e3dd830..9aa06d1 100644
--- a/import_csv.py
+++ b/import_csv.py
@@ -39,7 +39,7 @@ with open(args.csv) as f:
if stack:
b = db.session.query(Stack).filter_by(stack_name=stack).first()
if b == None:
- b = Stack(stack_name=stack, stack_description="test")
+ b = Stack(stack_name=stack, stack_description=stack_description)
db.session.add(b)
book.stacks.append(b)