def place_sell_order(request_data): farmer_obj = user_handler.get_user_profile(request_data['userId']) order_obj = SellOrders.objects.create( farmer=farmer_obj, product=product_handler.get_product_by_id(request_data['productId']), quantity=request_data['quantity'], product_image=request_data['productPic'], total_price=request_data['totalPrice'], shipping_address=user_handler.get_address_object_by_id( request_data['addressId'])) return order_obj
def place_purchase_order(request_data): hotel_obj = user_handler.get_user_profile(request_data['userId']) cart_obj = cart_handler.get_cart_for_hotel(hotel_obj.user.username) purchase_order_obj = PurchaseOrders.objects.create( hotel=hotel_obj, cart=cart_obj, total_price=request_data['totalPrice'], shipping_address=user_handler.get_address_object_by_id( request_data['addressId'])) post_purchase_order_action(cart_obj) return purchase_order_obj
def place_purchase_order(request_data): hotel_obj = user_handler.get_user_profile(request_data['userId']) cart_obj = cart_handler.get_cart_for_hotel(hotel_obj.user.username) purchase_order_obj = PurchaseOrders.objects.create( hotel=hotel_obj, cart=cart_obj, purchase_order_token=str(uuid.uuid4()), total_price=cart_obj.total_item_price, shipping_address=user_handler.get_address_object_by_id( request_data['addressId'])) post_purchase_order_action(cart_obj) cart_obj.is_active = False cart_obj.save() return purchase_order_obj
def get(self): data = request.args username = data['userId'] view = AddressView() if username: addresses = user_handler.get_addresses_by_username(username) return {"address": [view.render(adr) for adr in addresses]} token = request.headers.get('token') if token: user_obj = login_handler.get_user_object_by_token(token) addresses = user_handler.get_addresses_by_username( user_obj.user.username) return {"address": [view.render(adr) for adr in addresses]} address_id = data.get('addressId') if address_id: address_obj = user_handler.get_address_object_by_id(address_id) return {'address': view.render(address_obj)}
def get(self, username=None): if username: addresses = user_handler.get_addresses_by_username(username) return { "shippingAddresses": [user_handler.get_address_json(adr) for adr in addresses] } token = request.headers.get('token') if token: user_obj = login_handler.get_user_object_by_token(token) addresses = user_handler.get_addresses_by_username( user_obj.user.username) return { "shippingAddresses": [user_handler.get_address_json(adr) for adr in addresses] } address_id = request.headers.get('addressId') if address_id: address_obj = user_handler.get_address_object_by_id(address_id) return address_obj
def update_shipping_address(order_obj, request_data): order_obj.shipping_address = user_handler.get_address_object_by_id( request_data['addressId'])