Exemple #1
0
    def setUp(self):
        self.user = generate_user(username="******")
        self.token = self.generate_access_token(self.user)
        self.headers = {**self.generate_headers(), **self.bare_headers}

        self.url = reverse("webshop_orders-list")
        self.id_url = lambda _id: self.url + str(_id) + "/"

        self.product1: Product = G(
            Product,
            name="Onlinegenser",
            deadline=timezone.now() + timezone.timedelta(days=7),
        )

        self.product_size_s: ProductSize = G(ProductSize, size="S")
        self.product_size_m: ProductSize = G(ProductSize, size="M")
        self.product_size_l: ProductSize = G(ProductSize, size="L")

        self.get_order_line = lambda: OrderLine.get_current_order_line_for_user(
            self.user)
        self.order: Order = G(Order, order_line=self.get_order_line().id)
Exemple #2
0
 def current_order_line(self):
     user: User = self.request.user
     return OrderLine.get_current_order_line_for_user(user)
 def get_or_create_order_line(self) -> OrderLine:
     return OrderLine.get_current_order_line_for_user(self.user)
Exemple #4
0
 def __call__(self, serializer_field):
     user = super().__call__(serializer_field)
     return OrderLine.get_current_order_line_for_user(user)