diff --git a/app/forms.py b/app/forms.py index 6eeb292..ed1404b 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 = SelectField('Stack', validators=[InputRequired()]) + edit_stack_description = SelectField('Description', validators=[InputRequired()]) + class SearchForm(FlaskForm): choices = [('All', 'All'), ('Title', 'Title'), diff --git a/app/templates/edit_stack_detail.html b/app/templates/edit_stack_detail.html new file mode 100644 index 0000000..8dd6ea8 --- /dev/null +++ b/app/templates/edit_stack_detail.html @@ -0,0 +1,22 @@ +{% extends 'base.html' %} + +{% block main %} +
+ + {% from "_formhelpers.html" import render_field %} + +
+ {{ form.csrf_token }} +

+ + + + {{ render_field(form.edit_stack_name)}} + {{ render_field(form.edit_stack_description)}} + +
+ + + + +{% 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 @@ + + {% for book in books %} @@ -51,6 +53,10 @@
  • {{ stack.stack_name }}
  • {% endfor %} + + {% endfor %}
    Filetype Category StackAdd to stack
    + ==> +
    @@ -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 27f539a..101ce54 100755 --- a/app/templates/show_books.html +++ b/app/templates/show_books.html @@ -62,15 +62,8 @@ - \│/
    - ─ ─
    - /│\
    - - - - + ==>
    - {% endfor %} diff --git a/app/templates/show_stack_detail.html b/app/templates/show_stack_detail.html index 01551de..9f8dbca 100644 --- a/app/templates/show_stack_detail.html +++ b/app/templates/show_stack_detail.html @@ -18,6 +18,8 @@

    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..c82d9ba 100644 --- a/app/templates/show_stack_detail_tab.html +++ b/app/templates/show_stack_detail_tab.html @@ -1,7 +1,12 @@ {% block main %}
    -

    {{ stack.stack_name }}

    +

    + + + {{ stack.stack_name }} +

    +

    Stack description: {{ stack.stack_description }}

    diff --git a/app/templates/show_stacks.html b/app/templates/show_stacks.html index 27fd207..15daff3 100644 --- a/app/templates/show_stacks.html +++ b/app/templates/show_stacks.html @@ -11,7 +11,11 @@
      {% for stack in stacks %} -
    • {{ stack.stack_name }} +
    • + + {{ stack.stack_name }} + + diff --git a/app/views.py b/app/views.py index 3ff00d6..4317969 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, 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,18 @@ 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() + + if request.method == 'POST': + if edit_stack_form.validate_on_submit(): + stack_name = form.stack_name.data + stack_description = form.stack_description.data + 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)