Browse Source

added stack author

ansible-setup-and-deploy
Alice 6 years ago
parent
commit
2fb4013c7f
  1. 5
      app/forms.py
  2. 7
      app/models.py
  3. 4
      app/static/css/style.css
  4. 4
      app/templates/add_stack.html
  5. 2
      app/templates/show_books.html
  6. 6
      app/templates/show_stack_detail.html
  7. 7
      app/templates/show_stack_detail_tab.html
  8. 4
      app/templates/show_stacks.html
  9. 5
      app/views.py

5
app/forms.py

@ -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')

7
app/models.py

@ -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

4
app/static/css/style.css

@ -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%;

4
app/templates/add_stack.html

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

2
app/templates/show_books.html

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

6
app/templates/show_stack_detail.html

@ -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 %}

7
app/templates/show_stack_detail_tab.html

@ -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 %}

4
app/templates/show_stacks.html

@ -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>

5
app/views.py

@ -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'))

Loading…
Cancel
Save