Redirect to summary after purchase #55
This commit is contained in:
		| @@ -27,7 +27,10 @@ class SaleView(viewsets.ModelViewSet): | ||||
|                 unit_price=unit_price | ||||
|             ) | ||||
|  | ||||
|         return Response({'message': 'Venta creada con exito'}, status=201) | ||||
|         return Response( | ||||
|             {'id': sale.id, 'message': 'Venta creada con exito'}, | ||||
|             status=201 | ||||
|         ) | ||||
|  | ||||
|  | ||||
| class ProductView(viewsets.ModelViewSet): | ||||
|   | ||||
| @@ -270,7 +270,10 @@ | ||||
|                if (response.ok) { | ||||
|                    const data = await response.json(); | ||||
|                    console.log('Compra enviada:', data); | ||||
|                    this.$router.push("SummaryPurchase"); | ||||
|                    this.$router.push({ | ||||
|                        path: "/summary_purchase", | ||||
|                        query : {id: parseInt(data.id)} | ||||
|                    }); | ||||
|                } else { | ||||
|                    console.error('Error al enviar la compra:', response.statusText); | ||||
|                } | ||||
|   | ||||
| @@ -18,12 +18,18 @@ class TestAPI(APITestCase): | ||||
|  | ||||
|     def test_create_sale(self): | ||||
|         response = self._create_sale() | ||||
|         content = json.loads(response.content.decode('utf-8')) | ||||
|         self.assertEqual(response.status_code, status.HTTP_201_CREATED) | ||||
|         self.assertEqual(Sale.objects.count(), 1) | ||||
|         sale = Sale.objects.all()[0] | ||||
|         self.assertEqual( | ||||
|             Sale.objects.all()[0].customer.name, | ||||
|             sale.customer.name, | ||||
|             self.customer.name | ||||
|         ) | ||||
|         self.assertEqual( | ||||
|             sale.id, | ||||
|             content['id'] | ||||
|         ) | ||||
|  | ||||
|     def test_get_products(self): | ||||
|         url = '/don_confiao/api/products/' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user