File tree Expand file tree Collapse file tree 23 files changed +23
-24
lines changed
07_sqlalchemy_many_to_many
03_many_to_many_relationships
04_flask_jwt_extended_setup
06_registering_users_rest_api
08_protect_resources_with_jwt_required
09_jwt_claims_and_authorization
12_token_refreshing_flask_jwt_extended
05-add-many-to-many/resources
06-add-db-migrations/resources Expand file tree Collapse file tree 23 files changed +23
-24
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ class TagsInStore(MethodView):
117117 @blp.arguments (TagSchema)
118118 @blp.response (201 , TagSchema)
119119 def post (self , tag_data , store_id ):
120- if TagModel.query.filter(TagModel.store_id == store_id).first():
120+ if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data[ " name " ] ).first():
121121 abort(400 , message = " A tag with that name already exists in that store." )
122122
123123 tag = TagModel(** tag_data, store_id = store_id)
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ class TagsInStore(MethodView):
190190 @blp.arguments (TagSchema)
191191 @blp.response (201 , TagSchema)
192192 def post (self , tag_data , store_id ):
193- if TagModel.query.filter(TagModel.store_id == store_id).first():
193+ if TagModel.query.filter(TagModel.store_id == store_id, TagModel.name == tag_data[ " name " ] ).first():
194194 abort(400 , message = " A tag with that name already exists in that store." )
195195
196196 tag = TagModel(** tag_data, store_id = store_id)
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments