added stack author

This commit is contained in:
Alice 2018-06-10 19:33:50 +02:00
parent c3ea2d4868
commit 2fb4013c7f
9 changed files with 31 additions and 13 deletions

View File

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

View File

@ -91,11 +91,14 @@ class Stack(db.Model):
__tablename__ = 'stacks'
id = db.Column(db.Integer, primary_key = True)
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_description = stack_description
self.stack_author = stack_author
def __repr__(self):
return '<Stack %r>' % self.stack_name

View File

@ -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-panel { padding: 1em; float: left; width: 50em; font-size: 12px; list-style-type: none;}
#creator{
font-size: 12px;
color: grey;
}
#newstext{
width: 100%;

View File

@ -23,7 +23,7 @@
<br>
{{ render_field(form.stack_name)}}
{{ render_field(form.stack_description)}}
{{ render_field(form.stack_author)}}
<button type="submit" class='button'>Create</button>

View File

@ -6,6 +6,12 @@
<h1 class="header">{{ stack.stack_name }}</h1>
<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>
<p>
{% for book in stack.books %}

View File

@ -10,6 +10,13 @@
<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 %}

View File

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

View File

@ -321,9 +321,10 @@ def add_stack():
if form.validate_on_submit():
stack_name = form.stack_name.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:
stack = Stack(stack_name, stack_description)
stack = Stack(stack_name, stack_description, stack_author)
db.session.add(stack)
stacks = db.session.query(Stack).all()
return redirect(url_for('show_stacks'))