Skip to content

Added name field #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions blogexample/blueprints/blog/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class AddPostForm(FlaskForm):
body = TextAreaField('Body', [DataRequired(), Length(1, 8192)])
# tags = TextAreaField('tags', [DataRequired(), Length(3, 100)])
taglist = StringField('taglist')
name = StringField("name")
# tags = FieldList(StringField('tags'), min_entries=1)
visible = BooleanField('Published')
# body = CKEditorField('Body', [DataRequired(), Length(1, 8192)])
Expand Down
4 changes: 2 additions & 2 deletions blogexample/blueprints/blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Post(ResourceMixin, db.Model):
title = db.Column(db.String(128), nullable=False)
#short_description = db.Column(db.String())
body = db.Column(db.String(), nullable=False)

name = db.Column(db.String(128))
# time = DateTimeField(default=datetime.now)
url = db.Column(db.String(128), nullable=False, unique=True)
visible = db.Column(db.Boolean(), index=True, nullable=False, server_default='1')
Expand Down Expand Up @@ -104,7 +104,7 @@ def create_blogpost(cls, params):
blog_params['body'] = params['body']
blog_params['visible'] = params['visible']
blog_params['url'] = Post.create_url(params['title'])

blog_params["name"] = params["name"]
print('CREATING BLOG POST NOW with params', blog_params)
post = Post(**blog_params)

Expand Down
3 changes: 2 additions & 1 deletion blogexample/blueprints/blog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def add_post():
'title': blogpost.title,#request.form['title'],#
'body': blogpost.body,#request.form['body'],
'taglist': request.form['taglist'],#string_to_tag_list(blogpost.tags)
'visible': blogpost.visible
'visible': blogpost.visible,
"name": blogpost.name.strip()
}
print('PARAMS ARE: ', params)
if Post.create_blogpost(params):
Expand Down
34 changes: 34 additions & 0 deletions blogexample/migrations/versions/a6db2c3a9b0c_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from alembic import op
import sqlalchemy as sa

import lib.util_datetime# import tzware_datetime
import lib.util_sqlalchemy# import AwareDateTime


"""empty message

Revision ID: a6db2c3a9b0c
Revises: 5430b6f4296f
Create Date: 2020-02-10 17:00:07.205728

"""



# revision identifiers, used by Alembic.
revision = 'a6db2c3a9b0c'
down_revision = '5430b6f4296f'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('posts', sa.Column('name', sa.String(length=128)))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('posts', 'name')
# ### end Alembic commands ###
122 changes: 65 additions & 57 deletions blogexample/templates/posts.html
Original file line number Diff line number Diff line change
@@ -1,75 +1,83 @@
<!DOCTYPE html>
<html lang="en">
<head>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Posts</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

<link rel="stylesheet" type="text/css" href="../static/css/styles.css">
<style type="text/css">
#us{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some Formatting Changes can be ignored.

float: right;
margin-right: 20px;
margin-top: 10px;
}
#us h3{
margin: 0 0 0 0;
}
.ps{
width: 60%;
margin-top: 20px;
margin-left: 20%
}
#icon{
float: right;
margin-top: -15px;
}
#signout{
width: 100px;
height: 20px;
}
#signout a{
padding: 2px 0px 2px 20px;
}
#us {
float: right;
margin-right: 20px;
margin-top: 10px;
}

#us h3 {
margin: 0 0 0 0;
}

.ps {
width: 60%;
margin-top: 20px;
margin-left: 20%
}

#icon {
float: right;
margin-top: -15px;
}

#signout {
width: 100px;
height: 20px;
}

#signout a {
padding: 2px 0px 2px 20px;
}
</style>
</head>
</head>

<body>
<div>
<ul class="nav nav-tabs">
<li role="presentation"><a href="/add">Add Posts</a></li>
</ul>
</div>
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<h3 class="flashes" align="center" style="color:#337ab7">{{ message }}</h3>
{% endfor %}
{% endif %}
{% endwith %}
<div class="ps">
{% for each_post in posts %}
<div class="panel panel-info">
<div class="panel-heading">
<div><h3 class="panel-title">{{each_post.title}}</h3></div>
<div id="icon">
<a class="glyphicon glyphicon-sunglasses" href="/detail/{{ each_post.url }}"></a>&nbsp &nbsp
<a class="glyphicon glyphicon-pencil" href="/update/{{ each_post.id }}"></a>&nbsp &nbsp
<a class="glyphicon glyphicon-trash" id="del" href="/delete/{{ each_post.id }}"></a>
<div>
<ul class="nav nav-tabs">
<li role="presentation"><a href="/add">Add Posts</a></li>
</ul>
</div>
{% with messages = get_flashed_messages() %} {% if messages %} {% for message in messages %}
<h3 class="flashes" align="center" style="color:#337ab7">{{ message }}</h3>
{% endfor %} {% endif %} {% endwith %}
<div class="ps">
{% for each_post in posts %}
<div class="panel panel-info">
<div class="panel-heading">
<div>
<h3 class="panel-title">{{each_post.title}}</h3>
</div>
<div id="icon">
<a class="glyphicon glyphicon-sunglasses" href="/detail/{{ each_post.url }}"></a>&nbsp &nbsp
<a class="glyphicon glyphicon-pencil" href="/update/{{ each_post.id }}"></a>&nbsp &nbsp
<a class="glyphicon glyphicon-trash" id="del" href="/delete/{{ each_post.id }}"></a>
</div>
</div>
<div class="panel-body">
<p>{{ each_post.body|safe }}</p>
<p>Author: {{ each_post.name }}</p>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Author Info here.

<p>Tags: {{ each_post.tagstring }}</p>
<p>Published: {{ each_post.visible }}</p>
<p>Last updated: {{ each_post.updated_on.strftime('%m/%d/%Y') }}</p>
</div>
</div>
{% endfor %}
</div>
</div>
<div class="panel-body"><p>{{ each_post.body|safe }}</p>
<p>Tags: {{ each_post.tagstring }}</p>
<p>Published: {{ each_post.visible }}</p>
<p>Last updated: {{ each_post.updated_on.strftime('%m/%d/%Y') }}</p>
</div>
</div>
{% endfor %}
</div>
</body>

</html>