Skip to content

Commit 5d38a64

Browse files
authored
Merge pull request #111 from tecladocode/develop
2 parents e601a2c + 59d8234 commit 5d38a64

File tree

61 files changed

+71
-68
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+71
-68
lines changed

docs/docs/07_sqlalchemy_many_to_many/02_one_to_many_review/README.md

Lines changed: 2 additions & 2 deletions

docs/docs/07_sqlalchemy_many_to_many/02_one_to_many_review/end/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/07_sqlalchemy_many_to_many/02_one_to_many_review/end/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/07_sqlalchemy_many_to_many/03_many_to_many_relationships/README.md

Lines changed: 2 additions & 2 deletions

docs/docs/07_sqlalchemy_many_to_many/03_many_to_many_relationships/end/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/07_sqlalchemy_many_to_many/03_many_to_many_relationships/end/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/07_sqlalchemy_many_to_many/03_many_to_many_relationships/start/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/07_sqlalchemy_many_to_many/03_many_to_many_relationships/start/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/04_flask_jwt_extended_setup/README.md

Lines changed: 1 addition & 1 deletion

docs/docs/08_flask_jwt_extended/04_flask_jwt_extended_setup/end/models/tag.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")
12-
items = db.relationship("ItemModel", back_populates="tags", secondary="items_tags")
12+
items = db.relationship(
13+
"ItemModel", back_populates="tags", secondary="items_tags")

docs/docs/08_flask_jwt_extended/04_flask_jwt_extended_setup/end/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/04_flask_jwt_extended_setup/start/models/tag.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")
12-
items = db.relationship("ItemModel", back_populates="tags", secondary="items_tags")
12+
items = db.relationship(
13+
"ItemModel", back_populates="tags", secondary="items_tags")

docs/docs/08_flask_jwt_extended/04_flask_jwt_extended_setup/start/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/05_user_model_and_schema/end/models/tag.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")
12-
items = db.relationship("ItemModel", back_populates="tags", secondary="items_tags")
12+
items = db.relationship(
13+
"ItemModel", back_populates="tags", secondary="items_tags")

docs/docs/08_flask_jwt_extended/05_user_model_and_schema/end/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/05_user_model_and_schema/start/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/08_flask_jwt_extended/05_user_model_and_schema/start/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/06_registering_users_rest_api/end/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/08_flask_jwt_extended/06_registering_users_rest_api/end/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/06_registering_users_rest_api/start/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/08_flask_jwt_extended/06_registering_users_rest_api/start/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/07_login_users_rest_api/end/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/08_flask_jwt_extended/07_login_users_rest_api/end/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/07_login_users_rest_api/start/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/08_flask_jwt_extended/07_login_users_rest_api/start/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/08_protect_resources_with_jwt_required/end/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/08_flask_jwt_extended/08_protect_resources_with_jwt_required/end/resources/tag.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
25-
2625
tag = TagModel(**tag_data, store_id=store_id)
2726

2827
try:

docs/docs/08_flask_jwt_extended/08_protect_resources_with_jwt_required/start/models/tag.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")
12-
items = db.relationship("ItemModel", back_populates="tags", secondary="items_tags")
12+
items = db.relationship(
13+
"ItemModel", back_populates="tags", secondary="items_tags")

docs/docs/08_flask_jwt_extended/08_protect_resources_with_jwt_required/start/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/09_jwt_claims_and_authorization/end/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/08_flask_jwt_extended/09_jwt_claims_and_authorization/end/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/09_jwt_claims_and_authorization/start/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/08_flask_jwt_extended/09_jwt_claims_and_authorization/start/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/10_logout_users_rest_api/end/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/08_flask_jwt_extended/10_logout_users_rest_api/end/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/10_logout_users_rest_api/start/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/08_flask_jwt_extended/10_logout_users_rest_api/start/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/12_token_refreshing_flask_jwt_extended/end/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/08_flask_jwt_extended/12_token_refreshing_flask_jwt_extended/end/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

docs/docs/08_flask_jwt_extended/12_token_refreshing_flask_jwt_extended/start/models/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TagModel(db.Model):
55
__tablename__ = "tags"
66

77
id = db.Column(db.Integer, primary_key=True)
8-
name = db.Column(db.String(80), unique=True, nullable=False)
8+
name = db.Column(db.String(80), unique=False, nullable=False)
99
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)
1010

1111
store = db.relationship("StoreModel", back_populates="tags")

docs/docs/08_flask_jwt_extended/12_token_refreshing_flask_jwt_extended/start/resources/tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self, store_id):
2020
@blp.arguments(TagSchema)
2121
@blp.response(201, TagSchema)
2222
def post(self, tag_data, store_id):
23-
if TagModel.query.filter(TagModel.store_id == store_id).first():
23+
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
2424
abort(400, message="A tag with that name already exists in that store.")
2525

2626
tag = TagModel(**tag_data, store_id=store_id)

0 commit comments

Comments
 (0)