Example #1
0
    def post(self, user_id):
        request_body = PhoneAddApi.parser.parse_args()
        phone = Phone(number=request_body['number'], user_id=user_id)

        if not request_body['lastName']:
            return {"message": "Invalid lastName"}, 400

        try:
            phone.save()
        except:
            return {"message": "An error occurred while inserting the phone number."}, 400
        return phone.json(), 201
                #6. Kết nối
                data=data,  # Mạng di động
                sim=sim,  # Loại SIM
                wifi=wifi,  # Kết nối Wifi
                gps=gps,  # Công nghệ GPS
                bluetooth=bluetooth,  # bluetooth
                port=port,  # Cổng kết nối/sạc
                headphone_jack=headphone_jack,  # Jack tai nghe
                other_connection=other_connection,  # Kết nối khác
                #7. Thiết kế và Trọng lượng
                design=design,  # Thiết kế
                material=material,  # Chất liệu
                phone_dimension=phone_dimension,  # Kích thước
                weight=weight,  # Trọng lượng
                #8. Thông tin pin & Sạc
                battery_capacity=battery_capacity,  # Dung lượng pin
                battery_type=battery_type,  # Loại pin
                battery_technology=battery_technology,  # Công nghệ pin
                #9. Tiện ích
                protection=protection,  # Bảo mật nâng cao
                special_features=special_features,  # Tính năng đặc biệt
                recording=recording,  # Ghi âm
                radio=radio,  # Radio
                video_player=video_player,  # Định dạng phim
                music_player=music_player,  # Định dạng nhạc
                #10. Thông tin khác
                release_date=release_date,  # Thời điểm ra mắt
                phone_brand_name=phone_brand_name,
            )
            phone.save()