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
23 files changed +23
-24
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ class TagsInStore(MethodView):
117
117
@blp.arguments (TagSchema)
118
118
@blp.response (201 , TagSchema)
119
119
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():
121
121
abort(400 , message = " A tag with that name already exists in that store." )
122
122
123
123
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
190
190
@blp.arguments (TagSchema)
191
191
@blp.response (201 , TagSchema)
192
192
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():
194
194
abort(400 , message = " A tag with that name already exists in that store." )
195
195
196
196
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
tag = TagModel (** tag_data , store_id = store_id )
Original file line number Diff line number Diff line change @@ -20,9 +20,8 @@ def get(self, store_id):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
-
26
25
tag = TagModel (** tag_data , store_id = store_id )
27
26
28
27
try :
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ def get(self, store_id):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
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):
20
20
@blp .arguments (TagSchema )
21
21
@blp .response (201 , TagSchema )
22
22
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 ():
24
24
abort (400 , message = "A tag with that name already exists in that store." )
25
25
26
26
tag = TagModel (** tag_data , store_id = store_id )
You can’t perform that action at this time.
0 commit comments