示例#1
0
 def put(self):
     kwargs = self.parser.parse_args(strict=True)
     user_id = get_jwt_identity()
     if user.is_user_the_owner(user_id) and user.is_owner_the_centre_owner(
             user_id, kwargs['centre_id']):
         gear.delete_gear(kwargs['centre_id'], kwargs['gear_id'])
         return {'msg': 'Gear deleted successfully.'}, 200
     return {'msg': 'Permission denied. You are not the owner.'}, 403
示例#2
0
 def post(self):
     kwargs = self.parser.parse_args(strict=True)
     user_id = get_jwt_identity()
     uploaded_file = kwargs['file']  # This is FileStorage instance
     if user.is_user_the_owner(user_id) and user.is_owner_the_centre_owner(
             user_id, kwargs['centre_id']):
         filepath = pictures.send_file_to_imgur(uploaded_file)
         pictures.add_picture_to_centre(kwargs['centre_id'], filepath)
         return {'msg': 'Picture was saved and added.'}, 201
     return {'msg': 'Permission denied. You are not the owner.'}, 403
示例#3
0
    def put(self):
        kwargs = self.parser.parse_args(strict=True)
        user_id = get_jwt_identity()
        if user.is_user_the_owner(user_id) and user.is_owner_the_centre_owner(
                user_id, kwargs['centre_id']):
            wc.edit_water_centre(user_id, kwargs['centre_id'],
                                 kwargs['centre_name'], kwargs['latitude'],
                                 kwargs['longitude'], kwargs['phone_number'])

            return {'msg': 'Water centre edited successfully.'}, 200
        return {'msg': 'User does not have the proper rights.'}, 403
示例#4
0
 def post(self):
     kwargs = self.parser.parse_args(strict=True)
     user_id = get_jwt_identity()
     print(user_id)
     centre_id = rental.get_centre_id(kwargs['rent_id'])
     if rental.is_user_rent_owner(
             user_id, kwargs['rent_id']) or user.is_owner_the_centre_owner(
                 user_id, centre_id):
         rent_id = kwargs.pop('rent_id')
         rental.edit_rental(rent_id, kwargs)
         return {'msg': 'Edit was successful.'}, 200
     return {
         'msg': 'Permission denied. You are not the user nor the owner.'
     }, 403
示例#5
0
 def get(self, centre_id):
     user_id = get_jwt_identity()
     if user.is_user_the_owner(user_id) and user.is_owner_the_centre_owner(
             user_id, centre_id):
         rentals = rental.get_rentals_for_centre_owner(centre_id)
         return jsonify(rentals)