Skip to content

Commit

Permalink
import problems fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
nimaafshar79 committed Jun 10, 2020
1 parent 0b65ea0 commit 8b5a778
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
from werkzeug.debug import DebuggedApplication
from whitenoise import WhiteNoise

from admin import admin
from blog import blog
from calculator import calculator
from extentions import db, elastic, jwt, mail, migrate
from foods import foods
from foods import models as food_models
from users import models as user_models
from foods import models as food_models
from blog import models as blog_models
from users import users
from blog import blog
from admin import admin


def create_app(environment='Development'):
Expand Down Expand Up @@ -44,9 +45,9 @@ def temp_main_function():
}

app.register_blueprint(calculator)
app.register_blueprint(blog)
app.register_blueprint(users)
app.register_blueprint(foods)
app.register_blueprint(blog)


db.init_app(app)
Expand Down
8 changes: 5 additions & 3 deletions blog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from . import blog
from .forms import PostForm
from .models import Post
from users.models import User


@blog.route('/', methods=['GET'])
Expand All @@ -15,15 +16,16 @@ def list_posts():
for p in posts:
tmp = dict()
tmp['id'] = p.id
tmp = {'slug': p.slug, 'title' : p.title, 'summary': p.summary, 'content': p.content, 'category': p.category}
tmp = {'slug': p.slug, 'title': p.title, 'summary': p.summary, 'content': p.content, 'category': p.category}
result.update({f'{p.id}': tmp})
return jsonify(result), 200


@blog.route('/<string:slug>', methods=['GET'])
def single_post(slug):
post = Post.query.filter(Post.slug == slug).first()
result = {'slug': post.slug, 'title' : post.title, 'summary': post.summary, 'content': post.content, 'category': post.category}
result = {'slug': post.slug, 'title': post.title, 'summary': post.summary, 'content': post.content,
'category': post.category}
return jsonify(result), 200


Expand Down Expand Up @@ -63,4 +65,4 @@ def delete_post(post_id):
# post.summary = form.summary.data
# post.category = form.category.data
# db.session.commit()
# return {'msg': 'Post Modified!'}, 201
# return {'msg': 'Post Modified!'}, 201
1 change: 0 additions & 1 deletion users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from werkzeug.security import check_password_hash, generate_password_hash

from extentions import db
from blog.models import Post
from flask_admin.contrib.sqla import ModelView


Expand Down
1 change: 0 additions & 1 deletion users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from users.forms import ChangePasswordForm, LoginForm, RegisterForm
from users.models import User
from users.token import confirm_token, generate_confirmation_token
from utils.decorators import confirmed_only, json_only


@users.route('/signup', methods=['POST'])
Expand Down

0 comments on commit 8b5a778

Please sign in to comment.