Merge branch 'stack_stuff' of git.xpub.nl:/var/www/git.xpub.nl/repos/xpub-lib into stack_stuff

master
nberting 7 years ago
commit deb426ebaf

4
.gitignore vendored

@ -4,3 +4,7 @@ __pycache__/
app/uploads/** app/uploads/**
!app/uploads/cover !app/uploads/cover
app/mydatabase.db app/mydatabase.db
pyrqlite/
whoosh/
sqlalchemy-rqlite/
rqlite*

@ -51,6 +51,7 @@ class ChatForm(FlaskForm):
class StackForm(FlaskForm): class StackForm(FlaskForm):
stack_name = StringField('Stack', validators=[InputRequired()]) stack_name = StringField('Stack', validators=[InputRequired()])
stack_description = StringField('Description', validators=[InputRequired()]) stack_description = StringField('Description', validators=[InputRequired()])
stack_author = StringField('Who made this', validators=[InputRequired()])
create = SubmitField(label='Create') create = SubmitField(label='Create')
class AddtoStackForm(FlaskForm): class AddtoStackForm(FlaskForm):
@ -71,7 +72,3 @@ class SearchForm(FlaskForm):
grid = SubmitField('Grid') grid = SubmitField('Grid')
listview = SubmitField('List') listview = SubmitField('List')
randomize = SubmitField('Order differently') randomize = SubmitField('Order differently')

@ -100,11 +100,14 @@ class Stack(db.Model):
__tablename__ = 'stacks' __tablename__ = 'stacks'
id = db.Column(db.Integer, primary_key = True) id = db.Column(db.Integer, primary_key = True)
stack_name = db.Column(db.String(50)) stack_name = db.Column(db.String(50))
stack_description = db.Column(db.String(500)) stack_description = db.Column(db.String(1000))
stack_author = db.Column(db.String(255))
def __init__(self, stack_name, stack_description):
def __init__(self, stack_name, stack_description, stack_author):
self.stack_name = stack_name self.stack_name = stack_name
self.stack_description = stack_description self.stack_description = stack_description
self.stack_author = stack_author
def __repr__(self): def __repr__(self):
return '<Stack %r>' % self.stack_name return '<Stack %r>' % self.stack_name

@ -205,7 +205,11 @@ font-size: 12px;
.ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active { padding-bottom: 0; padding-right: .1em; border-right-width: 0; background-color: yellow !important; list-style-type: none;} .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active { padding-bottom: 0; padding-right: .1em; border-right-width: 0; background-color: yellow !important; list-style-type: none;}
.ui-tabs-vertical .ui-tabs-panel { padding: 1em; float: left; width: 50em; font-size: 12px; list-style-type: none;} .ui-tabs-vertical .ui-tabs-panel { padding: 1em; float: left; width: 50em; font-size: 12px; list-style-type: none;}
#creator{
font-size: 12px;
color: grey;
}
#newstext{ #newstext{
width: 100%; width: 100%;

@ -16,14 +16,14 @@
</ul> </ul>
</div> </div>
{% endif %} {% endif %}
{% endwith %} {% endwith %}
<form method="POST" action="{{ url_for('add_stack') }}" enctype=multipart/form-data> <form method="POST" action="{{ url_for('add_stack') }}" enctype=multipart/form-data>
{{form.hidden_tag()}} {{form.hidden_tag()}}
<br> <br>
{{ render_field(form.stack_name)}} {{ render_field(form.stack_name)}}
{{ render_field(form.stack_description)}} {{ render_field(form.stack_description)}}
{{ render_field(form.stack_author)}}
<button type="submit" class='button'>Create</button> <button type="submit" class='button'>Create</button>

@ -63,7 +63,7 @@
<li><a href="{{url_for('show_stack_by_id', id=stack.id)}}"> </a> <li><a href="{{url_for('show_stack_by_id', id=stack.id)}}"> </a>
{{ stack.stack_name }} {{ stack.stack_name }}
</li> </li>
{% endfor %} {% endfor %}

@ -6,6 +6,12 @@
<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 id='creator'>Created by:
{% if stack.stack_author == None %} anon</p>
{% else %}
{{ stack.stack_author }}
{% endif %}
<h2>Books in this stack:</h2> <h2>Books in this stack:</h2>
<p> <p>
{% for book in stack.books %} {% for book in stack.books %}

@ -10,6 +10,13 @@
<p>{{ stack.stack_description }} </p> <p>{{ stack.stack_description }} </p>
<p id='creator'>Created by:
{% if stack.stack_author == None %} anon</p>
{% else %}
{{ stack.stack_author }}
{% endif %}
<p style='font-weight:bold;'>Books in this stack: {% for book in stack.books %} <p style='font-weight:bold;'>Books in this stack: {% for book in stack.books %}

@ -4,8 +4,6 @@
<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%">
@ -26,6 +24,8 @@
</div> </div>
<br> <br>
<p><a href= {{ url_for('add_stack') }}>Add a new stack</a></p>
<br>
<br> <br>

@ -327,9 +327,10 @@ def add_stack():
if form.validate_on_submit(): if form.validate_on_submit():
stack_name = form.stack_name.data stack_name = form.stack_name.data
stack_description = form.stack_description.data stack_description = form.stack_description.data
stack = Stack(stack_name, stack_description) stack_author = form.stack_author.data
stack = Stack(stack_name, stack_description, stack_author)
if form.stack_name.data: if form.stack_name.data:
stack = Stack(stack_name, stack_description) stack = Stack(stack_name, stack_description, stack_author)
db.session.add(stack) db.session.add(stack)
stacks = db.session.query(Stack).all() stacks = db.session.query(Stack).all()
return redirect(url_for('show_stacks')) return redirect(url_for('show_stacks'))

Loading…
Cancel
Save