Skip to content
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

Fix dependencies and imports in SQL Storage section (s06) #102

Merged
Merged
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
flask
flask-smorest
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ class StoreModel(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)

items = db.relationship("ItemModel", back_populates="store", lazy="dynamic")
items = db.relationship(
"ItemModel", back_populates="store", lazy="dynamic", cascade="all, delete"
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
flask
flask-smorest
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from models.user import UserModel
from models.item import ItemModel
from models.tag import TagModel
from models.store import StoreModel
from models.item_tags import ItemsTags
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-sqlalchemy
flask-smorest
python-dotenv
marshmallow
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def get(self, item_id):

def delete(self, item_id):
item = ItemModel.query.get_or_404(item_id)
raise NotImplementedError("Deleting an item is not implemented.")
db.session.delete(item)
db.session.commit()
return {"message": "Item deleted."}

@blp.arguments(ItemUpdateSchema)
@blp.response(200, ItemSchema)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def get(self, store_id):

def delete(self, store_id):
store = StoreModel.query.get_or_404(store_id)
raise NotImplementedError("Deleting a store is not implemented.")
db.session.delete(store)
db.session.commit()
return {"message": "Store deleted"}, 200


@blp.route("/store")
Expand Down