From 82a7930bb82f35bf8084e8aa77f55ddd5ecd4e7b Mon Sep 17 00:00:00 2001 From: Stoyan Ivanov Date: Sun, 31 Mar 2024 09:05:42 +0300 Subject: [PATCH] Add support for Azure Storage --- client/src/components/ProductItem.vue | 5 +++-- client/src/services/product-service.ts | 2 +- client/src/views/AddItemView.vue | 6 +++-- server/products/models.py | 4 +++- server/requirements.txt | Bin 2780 -> 3160 bytes server/server/settings.py | 30 ++++++++++++++++++++++++- 6 files changed, 40 insertions(+), 7 deletions(-) diff --git a/client/src/components/ProductItem.vue b/client/src/components/ProductItem.vue index fde069c..4d0978a 100644 --- a/client/src/components/ProductItem.vue +++ b/client/src/components/ProductItem.vue @@ -1,8 +1,9 @@ diff --git a/client/src/services/product-service.ts b/client/src/services/product-service.ts index e0d8455..7eee144 100644 --- a/client/src/services/product-service.ts +++ b/client/src/services/product-service.ts @@ -23,7 +23,7 @@ export class ProductService extends WebApiService { } public async createProduct(name: string, image?: Blob): AxiosPromise { - return await axios.postForm(BASE_PATH + '/api/product/', {name, image_url: image}, this.generateHeader()); + return await axios.postForm(BASE_PATH + '/api/products/', {name, image_url: image}, this.generateHeader()); } public async getProductById(id: number): AxiosPromise { diff --git a/client/src/views/AddItemView.vue b/client/src/views/AddItemView.vue index a587456..f5b9cb3 100644 --- a/client/src/views/AddItemView.vue +++ b/client/src/views/AddItemView.vue @@ -43,6 +43,7 @@ import BackArrowIcon from "../components/icons/BackArrowIcon.vue"; import { useRouter } from 'vue-router'; import {ref} from 'vue'; import Navbar from "../components/Navbar.vue"; +import productService from "../services/product-service.ts"; const router = useRouter(); @@ -55,8 +56,9 @@ const form = ref({ }) -function submitForm() { - +async function submitForm() { + await productService.createProduct(form.value.itemName); + navigateToItems(); } diff --git a/server/products/models.py b/server/products/models.py index 0726402..cf31a01 100644 --- a/server/products/models.py +++ b/server/products/models.py @@ -1,3 +1,5 @@ +from uuid import uuid4 + from django.db import models @@ -5,7 +7,7 @@ def upload_to(instance, filename): - return 'images/{filename}'.format(filename=filename) + return '{filename}'.format(filename=str(uuid4()) + filename) class Product(models.Model): diff --git a/server/requirements.txt b/server/requirements.txt index 019f0c4b9eb532fae9830e148ec36f43d1f4d0e3..6c652cc4dac63f1220ca4a06366651a901e72923 100644 GIT binary patch delta 360 zcmca3dP8CXV{9Tr6+Kog)cqsf8H+MAu2H!zA81D%orG_3^a zG>};!Q_MC$XIalEnaq$4lt>3UCl5%1B#nSpft=IJRt}Uc0Lm5tZAt}_5Luwf3`U!O svuQF3XEIcP1wjD=^~Gjc&PGP*M4)*k;BYGj>ILaD2AK&qcRH6V0H^#zUjP6A delta 50 zcmV-20L}l{7~B=00h3|@aFgx