resolved conflicts

master
Alice 7 years ago
commit 30d8bade54

@ -25,6 +25,7 @@ class EditForm(FlaskForm):
author = FieldList(FormField(AuthorForm, default=lambda: Author()), min_entries=1) author = FieldList(FormField(AuthorForm, default=lambda: Author()), min_entries=1)
category = StringField('category', validators=[InputRequired()]) category = StringField('category', validators=[InputRequired()])
year_published = StringField('year published', [validators.Length(max=4)],default=None) year_published = StringField('year published', [validators.Length(max=4)],default=None)
class ChatForm(FlaskForm): class ChatForm(FlaskForm):
message = StringField('message', validators=[InputRequired()]) message = StringField('message', validators=[InputRequired()])
send = SubmitField(label='Send') send = SubmitField(label='Send')
@ -36,7 +37,11 @@ class StackForm(FlaskForm):
class AddtoStackForm(FlaskForm): class AddtoStackForm(FlaskForm):
select_stack = SelectField('Stacks', validators=[InputRequired()]) 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): class SearchForm(FlaskForm):
choices = [('All', 'All'), choices = [('All', 'All'),
('Title', 'Title'), ('Title', 'Title'),

@ -16,22 +16,6 @@
<button type="submit" class="button" value="Stack" name="add_book">Add to stack</button> <button type="submit" class="button" value="Stack" name="add_book">Add to stack</button>
</form> </form>
<br>
<br>
<h1 class="page-header">Build a stack</h1>
<p><a href= {{ url_for('add_stack') }}>Add Stack</a></p>
<div id="draggable" class="ui-widget-content">
<p>List of books</p>
</div>
<div id="droppable" class="ui-widget-header">
<p>Stack</p>
</div>
</div> </div>
{% endblock %} {% endblock %}

@ -0,0 +1,25 @@
{% extends 'base.html' %}
{% block main %}
<div class="container">
<!--
{% from "_formhelpers.html" import render_field %} -->
<!--
{{ render_field(form.edit_stack_name)}}
{{ render_field(form.edit_stack_description)}} -->
<form method="POST" action="{{ url_for('edit_stack_by_id', id=stack.id )}}">
{{ form.csrf_token }}
<br> <br>
<div class="form-group">
{{ form.edit_stack_name.label }} {{ form.edit_stack_name(size=20, class="form-control") }}
</div><br>
<div class="form-group">
{{ form.edit_stack_description.label }} {{ form.edit_stack_description(size=20, class="form-control") }}
</div>
<br>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
{% endblock %}

@ -33,6 +33,8 @@
<th>Filetype</th> <th>Filetype</th>
<th>Category</th> <th>Category</th>
<th>Stack</th> <th>Stack</th>
<th>Add to stack</th>
</tr> </tr>
{% for book in books %} {% for book in books %}
<tr> <tr>
@ -51,6 +53,10 @@
<li><a href="{{url_for('show_stack_by_id', id=stack.id)}}">{{ stack.stack_name }}</a> </li> <li><a href="{{url_for('show_stack_by_id', id=stack.id)}}">{{ stack.stack_name }}</a> </li>
{% endfor %} {% endfor %}
</td> </td>
<td id='plus'><a href='{{url_for('add_to_stack', id=book.id)}}'>
==>
</a></td>
{% endfor %} {% endfor %}
</table> </table>
@ -68,6 +74,8 @@
<th>Filetype</th> <th>Filetype</th>
<th>Category</th> <th>Category</th>
<th>Stack</th> <th>Stack</th>
<th>Add to stack</th>
</tr> </tr>
{% for book in books_all %} {% for book in books_all %}
<tr> <tr>
@ -86,6 +94,9 @@
<li><a href="{{url_for('show_stack_by_id', id=stack.id)}}">{{ stack.stack_name }}</a> </li> <li><a href="{{url_for('show_stack_by_id', id=stack.id)}}">{{ stack.stack_name }}</a> </li>
{% endfor %} {% endfor %}
</td> </td>
<td id='plus'><a href='{{url_for('add_to_stack', id=book.id)}}'>
==>
</a></td>
{% endfor %} {% endfor %}
</table> </table>
<p> <p>

@ -63,15 +63,8 @@
</td> </td>
<td id='plus'><a href='{{url_for('add_to_stack', id=book.id)}}'> <td id='plus'><a href='{{url_for('add_to_stack', id=book.id)}}'>
\│/<br> ==>
─ ─ <br>
/│\<br>
</a></td> </a></td>
</tr> </tr>
{% endfor %} {% endfor %}

@ -5,12 +5,14 @@
<h1 class="header">{{ stack.stack_name }}</h1> <h1 class="header">{{ stack.stack_name }}</h1>
<p>{{ stack.stack_description }} </p> <p>{{ stack.stack_description }} </p>
<p>Books in this stack: {% for book in stack.books %} <p>Books in this stack: {% for book in stack.books %}
<li> <a href="{{url_for('show_book_by_id', id=book.id)}}">{{book.title}}</a> </li> <li> <a href="{{url_for('show_book_by_id', id=book.id)}}">{{book.title}}</a> </li>
<img class="no_cover" id="{{ book.title }}" src="../uploads/cover/{{ book.cover }}" width="150" onerror="if (this.src != '../static/img/{{ book.cover }}') this.src = '../static/img/default_cover.png';">
<div class='widget'>
<iframe src="../uploads/{{ book.file }}" width="50%" ></iframe>
</div>
{% endfor %}</p> {% endfor %}</p>
@ -18,6 +20,9 @@
<br> <br>
<p> <p>
<a href="{{ url_for('remove_stack_by_id', id=stack.id )}}">Delete</a> </p> <a href="{{ url_for('remove_stack_by_id', id=stack.id )}}">Delete</a> </p>
<a href="{{ url_for('edit_stack_by_id', id=stack.id )}}">Edit</a> </p>
<p><a href="{{url_for('show_stacks')}}">Go back to stacks</p> <p><a href="{{url_for('show_stacks')}}">Go back to stacks</p>

@ -1,15 +1,24 @@
{% block main %} {% block main %}
<div class="container"> <div class="container">
<h1 class="header">{{ stack.stack_name }}</h1> <h1 class="header">
<a href="{{url_for('show_stack_by_id', id=stack.id)}}">
{{ stack.stack_name }} </a>
</h1>
<p>Stack description: {{ stack.stack_description }} </p>
<p>{{ stack.stack_description }} </p>
<p>Books in this stack: {% for book in stack.books %} <p>Books in this stack: {% for book in stack.books %}
<li> <a href="{{url_for('show_book_by_id', id=book.id)}}">{{book.title}}</a> </li> <li style="font-size: 18px;"> <a href="{{url_for('show_book_by_id', id=book.id)}}">{{book.title}}</a> </li>
<p style="font-size: 10px;"><a href='{{url_for('add_to_stack', id=book.id)}}'>
Add to another stack
</a></p>
{% endfor %}</p> {% endfor %}</p>

@ -4,6 +4,8 @@
<div class="container"> <div class="container">
<h1 class="page-header">Stacks</h1> <h1 class="page-header">Stacks</h1>
<p>These are all the stacks that have been built so far.</p> <p>These are all the stacks that have been built so far.</p>
<p><a href= {{ url_for('add_stack') }}>Add a new stack</a></p>
<table style="width:100%"> <table style="width:100%">
@ -11,7 +13,11 @@
<ul> <ul>
{% for stack in stacks %} {% for stack in stacks %}
<li> <a href="stacks/tab/{{ stack.id }}">{{ stack.stack_name }}</a></td> <li> <a href="stacks/tab/{{ stack.id }}">
{{ stack.stack_name }}
</a></td>
@ -22,19 +28,7 @@
<br> <br>
<br> <br>
<h1 class='page-header'><a href= {{ url_for('add_stack') }}>Add Stack</a></h1>
<!--
<div id="draggable" class="ui-widget-content">
<p>List of books</p>
</div>
<div id="droppable" class="ui-widget-header">
<p>Stack</p>
</div>
-->
</div> </div>
{% endblock %} {% endblock %}

@ -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 from flask import Flask, Response, session, 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, 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.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
@ -303,6 +303,21 @@ def remove_stack_by_id(id):
db.session.commit() db.session.commit()
return redirect(url_for('show_stacks')) return redirect(url_for('show_stacks'))
@app.route('/stacks/<int:id>/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
## search ## search

@ -39,7 +39,7 @@ with open(args.csv) as f:
if stack: if stack:
b = db.session.query(Stack).filter_by(stack_name=stack).first() b = db.session.query(Stack).filter_by(stack_name=stack).first()
if b == None: if b == None:
b = Stack(stack_name=stack, stack_description="test") b = Stack(stack_name=stack, stack_description=stack_description)
db.session.add(b) db.session.add(b)
book.stacks.append(b) book.stacks.append(b)

Loading…
Cancel
Save