resolved conflicts
This commit is contained in:
commit
30d8bade54
@ -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')
|
||||
@ -37,6 +38,10 @@ 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'),
|
||||
|
@ -16,22 +16,6 @@
|
||||
<button type="submit" class="button" value="Stack" name="add_book">Add to stack</button>
|
||||
</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>
|
||||
|
||||
{% endblock %}
|
||||
|
25
app/templates/edit_stack_detail.html
Normal file
25
app/templates/edit_stack_detail.html
Normal file
@ -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>Category</th>
|
||||
<th>Stack</th>
|
||||
<th>Add to stack</th>
|
||||
|
||||
</tr>
|
||||
{% for book in books %}
|
||||
<tr>
|
||||
@ -51,6 +53,10 @@
|
||||
<li><a href="{{url_for('show_stack_by_id', id=stack.id)}}">{{ stack.stack_name }}</a> </li>
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
||||
<td id='plus'><a href='{{url_for('add_to_stack', id=book.id)}}'>
|
||||
==>
|
||||
</a></td>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
@ -68,6 +74,8 @@
|
||||
<th>Filetype</th>
|
||||
<th>Category</th>
|
||||
<th>Stack</th>
|
||||
<th>Add to stack</th>
|
||||
|
||||
</tr>
|
||||
{% for book in books_all %}
|
||||
<tr>
|
||||
@ -86,6 +94,9 @@
|
||||
<li><a href="{{url_for('show_stack_by_id', id=stack.id)}}">{{ stack.stack_name }}</a> </li>
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td id='plus'><a href='{{url_for('add_to_stack', id=book.id)}}'>
|
||||
==>
|
||||
</a></td>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<p>
|
||||
|
@ -63,15 +63,8 @@
|
||||
</td>
|
||||
<td id='plus'><a href='{{url_for('add_to_stack', id=book.id)}}'>
|
||||
|
||||
\│/<br>
|
||||
─ ─ <br>
|
||||
/│\<br>
|
||||
|
||||
|
||||
|
||||
|
||||
==>
|
||||
</a></td>
|
||||
|
||||
</tr>
|
||||
|
||||
{% endfor %}
|
||||
|
@ -5,12 +5,14 @@
|
||||
|
||||
<h1 class="header">{{ stack.stack_name }}</h1>
|
||||
|
||||
|
||||
<p>{{ stack.stack_description }} </p>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
@ -18,6 +20,9 @@
|
||||
<br>
|
||||
<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>
|
||||
|
||||
|
@ -1,15 +1,24 @@
|
||||
{% block main %}
|
||||
<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 %}
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
<div class="container">
|
||||
<h1 class="page-header">Stacks</h1>
|
||||
<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%">
|
||||
|
||||
@ -11,7 +13,11 @@
|
||||
<ul>
|
||||
{% 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>
|
||||
|
||||
<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>
|
||||
|
||||
{% endblock %}
|
||||
|
17
app/views.py
17
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/<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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user