Skip to content

Commit

Permalink
Merge pull request #111 from tecladocode/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jslvtr authored Jan 13, 2023
2 parents e601a2c + 59d8234 commit 5d38a64
Show file tree
Hide file tree
Showing 61 changed files with 71 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down Expand Up @@ -117,7 +117,7 @@ class TagsInStore(MethodView):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down Expand Up @@ -190,7 +190,7 @@ class TagsInStore(MethodView):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ def create_app(db_url=None):
:::caution
The secret key set here, `"jose"`, is **not very safe**.

Instead you should generate a long and random secret key using something like `secrets.SystemRandom().getrandbits(128)`.
Instead you should generate a long and random secret key using something like `str(secrets.SystemRandom().getrandbits(128))`.
:::
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
items = db.relationship("ItemModel", back_populates="tags", secondary="items_tags")
items = db.relationship(
"ItemModel", back_populates="tags", secondary="items_tags")
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
items = db.relationship("ItemModel", back_populates="tags", secondary="items_tags")
items = db.relationship(
"ItemModel", back_populates="tags", secondary="items_tags")
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
items = db.relationship("ItemModel", back_populates="tags", secondary="items_tags")
items = db.relationship(
"ItemModel", back_populates="tags", secondary="items_tags")
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

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

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
items = db.relationship("ItemModel", back_populates="tags", secondary="items_tags")
items = db.relationship(
"ItemModel", back_populates="tags", secondary="items_tags")
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TagModel(db.Model):
__tablename__ = "tags"

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
name = db.Column(db.String(80), unique=False, nullable=False)
store_id = db.Column(db.Integer(), db.ForeignKey("stores.id"), nullable=False)

store = db.relationship("StoreModel", back_populates="tags")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self, store_id):
@blp.arguments(TagSchema)
@blp.response(201, TagSchema)
def post(self, tag_data, store_id):
if TagModel.query.filter(TagModel.store_id == store_id).first():
if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data["name"]).first():
abort(400, message="A tag with that name already exists in that store.")

tag = TagModel(**tag_data, store_id=store_id)
Expand Down
Loading

0 comments on commit 5d38a64

Please sign in to comment.