Пример #1
0
 def delete(self, review_id):
     review = ReviewModel.find_by_review_id(review_id)
     if not review:
         return {
             'message':
             'review with id of {} is not existing'.format(review_id)
         }
     review.delete_from_db()
     return {'message': 'review with id of {} is deleted'.format(review_id)}
Пример #2
0
 def put(self, review_id):
     review = ReviewModel.find_by_review_id(review_id)
     data = Review.parser.parse_args()
     if not review:
         new_review = ReviewModel(None, **data)
         new_review.save_to_db()
         return new_review.json(review_id)
     else:
         new_review = ReviewModel(review_id, **data)
         new_review.update_in_db()
         return new_review.json(review_id)
Пример #3
0
 def post(self, review_id):
     review = ReviewModel.find_by_review_id(review_id)
     if review:
         return {
             'message':
             'review with id of {} is already existing'.format(review_id)
         }
     data = Review.parser.parse_args()
     new_review = ReviewModel(None, **data)
     new_review.save_to_db()
     return new_review.json(review_id)
Пример #4
0
 def get(self, review_id):
     review = ReviewModel.find_by_review_id(review_id)
     return review.json(review_id) if review else None