From 9a2bc3892fefce0ffe83ea0aedf09fc9fc637c57 Mon Sep 17 00:00:00 2001 From: Alice Date: Tue, 5 Jun 2018 18:26:25 +0200 Subject: [PATCH 1/5] tried to add edit --- app/forms.py | 7 ++++++- app/templates/edit_stack_detail.html | 22 ++++++++++++++++++++++ app/templates/results.html | 11 +++++++++++ app/templates/show_books.html | 9 +-------- app/templates/show_stack_detail.html | 2 ++ app/templates/show_stack_detail_tab.html | 7 ++++++- app/templates/show_stacks.html | 6 +++++- app/views.py | 14 +++++++++++++- import_csv.py | 2 +- 9 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 app/templates/edit_stack_detail.html 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) From 85d0dba0b42fa363793986c4898736f26621b086 Mon Sep 17 00:00:00 2001 From: Alice Date: Wed, 6 Jun 2018 11:39:38 +0200 Subject: [PATCH 2/5] edited css of tabs --- app/forms.py | 4 ++-- app/static/css/style.css | 2 +- app/views.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/forms.py b/app/forms.py index ed1404b..0db4fdf 100755 --- a/app/forms.py +++ b/app/forms.py @@ -39,8 +39,8 @@ 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()]) + edit_stack_name = StringField('Stack', validators=[InputRequired()]) + edit_stack_description = StringField('Description', validators=[InputRequired()]) class SearchForm(FlaskForm): choices = [('All', 'All'), diff --git a/app/static/css/style.css b/app/static/css/style.css index 36c021f..abc3102 100755 --- a/app/static/css/style.css +++ b/app/static/css/style.css @@ -184,7 +184,7 @@ font-size: 12px; } .ui-tabs-vertical { width: 100em; border-top: 0;} -.ui-tabs-vertical .ui-tabs-nav { padding: .2em .2em .2em .2em; float: left; width: 12em; } +.ui-tabs-vertical .ui-tabs-nav { padding: .2em .2em .2em .2em; float: left; width: 15em; -webkit-appearance: none;} .ui-tabs-vertical .ui-tabs-nav li { clear: left; width: 100%; border-bottom-width: 0 !important; border-right-width: 0 !important; margin: 0 -1px .2em 0; } .ui-tabs-vertical .ui-tabs-nav li a { display:block; } .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active { padding-bottom: 0; padding-right: .1em; border-right-width: 0; background-color: #A9A9A9} diff --git a/app/views.py b/app/views.py index 4317969..788d76e 100755 --- a/app/views.py +++ b/app/views.py @@ -309,9 +309,9 @@ def edit_stack_by_id(id): 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 + if form.validate_on_submit(): + stack_name = form.edit_stack_name.data + stack_description = form.edit_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) From e151495683e85ee7b82787ec0107c09c6c326cce Mon Sep 17 00:00:00 2001 From: Alice Date: Wed, 6 Jun 2018 13:27:01 +0200 Subject: [PATCH 3/5] default form entries --- app/templates/edit_stack_detail.html | 19 +++++++++++-------- app/views.py | 5 ++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/templates/edit_stack_detail.html b/app/templates/edit_stack_detail.html index 8dd6ea8..6390e23 100644 --- a/app/templates/edit_stack_detail.html +++ b/app/templates/edit_stack_detail.html @@ -2,18 +2,21 @@ {% block main %}
      - - {% from "_formhelpers.html" import render_field %} - + +
      {{ form.csrf_token }}

      - - +
      + {{ form.edit_stack_name.label }} {{ form.edit_stack_name(size=20, class="form-control") }} +

      +
      + {{ form.edit_stack_description.label }} {{ form.edit_stack_description(size=20, class="form-control") }} +
      - {{ render_field(form.edit_stack_name)}} - {{ render_field(form.edit_stack_description)}} -
      diff --git a/app/views.py b/app/views.py index 788d76e..ccedbb1 100755 --- a/app/views.py +++ b/app/views.py @@ -306,13 +306,16 @@ def remove_stack_by_id(id): @app.route('/stacks//edit', methods=['POST', 'GET']) def edit_stack_by_id(id): stack = Stack.query.filter_by(id=id).first() - form = EditStackForm() + 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 From ca91e2e37afa65835ae4eaf6b75a27652cc44b48 Mon Sep 17 00:00:00 2001 From: Alice Date: Wed, 6 Jun 2018 14:32:18 +0200 Subject: [PATCH 4/5] connect stacks and edit stacks and add covers --- app/templates/add_to_stacks.html | 16 ---------------- app/templates/show_stack_detail.html | 2 +- app/templates/show_stack_detail_tab.html | 6 +++++- app/templates/show_stacks.html | 14 ++------------ 4 files changed, 8 insertions(+), 30 deletions(-) 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 @@ - - -
      -
      -

      Build a stack

      - -

      Add Stack

      - -
      -

      List of books

      -
      - -
      -

      Stack

      -
      - {% endblock %} diff --git a/app/templates/show_stack_detail.html b/app/templates/show_stack_detail.html index 9f8dbca..39f5539 100644 --- a/app/templates/show_stack_detail.html +++ b/app/templates/show_stack_detail.html @@ -5,11 +5,11 @@

      {{ stack.stack_name }}

      -

      {{ stack.stack_description }}

      Books in this stack: {% for book in stack.books %}

    • {{book.title}}
    • + {% endfor %}

      diff --git a/app/templates/show_stack_detail_tab.html b/app/templates/show_stack_detail_tab.html index c82d9ba..029d5a9 100644 --- a/app/templates/show_stack_detail_tab.html +++ b/app/templates/show_stack_detail_tab.html @@ -13,8 +13,12 @@

      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 15daff3..f1388a5 100644 --- a/app/templates/show_stacks.html +++ b/app/templates/show_stacks.html @@ -4,6 +4,8 @@

      Stacks

      These are all the stacks that have been built so far.

      +

      Add a new stack

      +
      @@ -26,19 +28,7 @@

      -

      Add Stack

      - - - {% endblock %} From 2b49e98fdd6f3bf8a57bb0182b6761d00e407771 Mon Sep 17 00:00:00 2001 From: Alice Date: Wed, 6 Jun 2018 16:07:39 +0200 Subject: [PATCH 5/5] removed tab styling --- app/static/css/style.css | 19 ++++++++++++++++++- app/templates/base.html | 1 - app/templates/show_stack_detail.html | 5 ++++- app/templates/show_stack_detail_tab.html | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/static/css/style.css b/app/static/css/style.css index abc3102..be7e00f 100755 --- a/app/static/css/style.css +++ b/app/static/css/style.css @@ -187,11 +187,12 @@ font-size: 12px; .ui-tabs-vertical .ui-tabs-nav { padding: .2em .2em .2em .2em; float: left; width: 15em; -webkit-appearance: none;} .ui-tabs-vertical .ui-tabs-nav li { clear: left; width: 100%; border-bottom-width: 0 !important; border-right-width: 0 !important; margin: 0 -1px .2em 0; } .ui-tabs-vertical .ui-tabs-nav li a { display:block; } -.ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active { padding-bottom: 0; padding-right: .1em; border-right-width: 0; background-color: #A9A9A9} +.ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active { padding-bottom: 0; padding-right: .1em; border-right-width: 0; background-color: #A9A9A9 !important;} .ui-tabs-vertical .ui-tabs-panel { padding: 1em; float: left; width: 50em; font-size: 12px;} #draggable { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; } #droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; } + #newstext{ width: 100%; margin: 0; @@ -307,3 +308,19 @@ box-sizing: border-box; font-size: 16px; font-style: italic; } + +.widget { + resize: both; + overflow: hidden; + width: 300px; + height: 300px; + display: inline-block; + +} + +.widget iframe { + + width: 100%; + height: 100%; + border: none; +} diff --git a/app/templates/base.html b/app/templates/base.html index cae3d58..76a7e06 100755 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -14,7 +14,6 @@ - {% block css %} {% endblock%} diff --git a/app/templates/show_stack_detail.html b/app/templates/show_stack_detail.html index 39f5539..af144cd 100644 --- a/app/templates/show_stack_detail.html +++ b/app/templates/show_stack_detail.html @@ -10,7 +10,9 @@
    • {{book.title}}
    • - +
      + +
      {% endfor %}

      @@ -21,6 +23,7 @@ Edit

      +

      Go back to stacks

      diff --git a/app/templates/show_stack_detail_tab.html b/app/templates/show_stack_detail_tab.html index 029d5a9..d074c2c 100644 --- a/app/templates/show_stack_detail_tab.html +++ b/app/templates/show_stack_detail_tab.html @@ -9,7 +9,7 @@ -

      Stack description: {{ stack.stack_description }}

      +

      {{ stack.stack_description }}

      Books in this stack: {% for book in stack.books %}