gamingflexer commited on
Commit
fea5e09
·
1 Parent(s): 0f568e7

remove model & fucn added

Browse files
Files changed (2) hide show
  1. src/app/api/models.py +0 -15
  2. src/app/api/views.py +1 -14
src/app/api/models.py CHANGED
@@ -2,21 +2,6 @@ from django.db import models
2
  import uuid
3
  from django.urls.base import reverse
4
 
5
- class Record(models.Model):
6
- id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
7
- voice_record = models.FileField(upload_to="records")
8
- language = models.CharField(max_length=50, null=True, blank=True)
9
-
10
- class Meta:
11
- verbose_name = "Record"
12
- verbose_name_plural = "Records"
13
-
14
- def __str__(self):
15
- return str(self.id)
16
-
17
- def get_absolute_url(self):
18
- return reverse("record_detail", kwargs={"id": str(self.id)})
19
-
20
 
21
  class Product(models.Model):
22
  barcode = models.CharField(max_length=20)
 
2
  import uuid
3
  from django.urls.base import reverse
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  class Product(models.Model):
7
  barcode = models.CharField(max_length=20)
src/app/api/views.py CHANGED
@@ -88,26 +88,13 @@ def upload_image_and_audio(request):
88
  with open(image_path, 'wb') as f:
89
  for chunk in image.chunks():
90
  f.write(chunk)
91
- # Process the uploaded image and get product details
92
- # product_detail = get_data_openai(image_path)
93
- # product_details.append(product_detail)
94
 
95
- # Handle audio recording
96
- if 'audio_data' in request.POST:
97
- # Save the audio data locally
98
- audio_data = request.POST['audio_data']
99
- audio_path = os.path.join(settings.STATIC_ROOT, 'audio', 'recorded_audio.wav')
100
- with open(audio_path, 'wb') as f:
101
- f.write(audio_data)
102
- # Process the uploaded image and get product details
103
- # product_detail = get_data_openai(image_path)
104
- # product_details.append(product_detail)
105
- # Dummy data for testing - You can replace this with actual data retrieved from the AI model
106
  product_details = []
107
  dummy_data = [
108
  {'barcode': '123456', 'brand': 'Brand A', 'manufactured_by': 'Manufacturer A', 'product_name': 'Product A', 'weight': 1.5, 'variant': 'Variant A', 'net_content': '100ml', 'price': 10.0, 'parent_category': 'Category A', 'child_category': 'Subcategory A', 'description': 'Description for Product A', 'quantity': 100, 'mrp': '20.0'},
109
  {'barcode': '654321', 'brand': 'Brand B', 'manufactured_by': 'Manufacturer B', 'product_name': 'Product B', 'weight': 2.0, 'variant': 'Variant B', 'net_content': '200ml', 'price': 15.0, 'parent_category': 'Category B', 'child_category': 'Subcategory B', 'description': 'Description for Product B', 'quantity': 200, 'mrp': '25.0'}
110
  ]
 
111
  product_details.extend(dummy_data)
112
  return JsonResponse(dummy_data[0], safe=False) # Return product details as JSON response
113
  return render(request, 'upload_image.html')
 
88
  with open(image_path, 'wb') as f:
89
  for chunk in image.chunks():
90
  f.write(chunk)
 
 
 
91
 
 
 
 
 
 
 
 
 
 
 
 
92
  product_details = []
93
  dummy_data = [
94
  {'barcode': '123456', 'brand': 'Brand A', 'manufactured_by': 'Manufacturer A', 'product_name': 'Product A', 'weight': 1.5, 'variant': 'Variant A', 'net_content': '100ml', 'price': 10.0, 'parent_category': 'Category A', 'child_category': 'Subcategory A', 'description': 'Description for Product A', 'quantity': 100, 'mrp': '20.0'},
95
  {'barcode': '654321', 'brand': 'Brand B', 'manufactured_by': 'Manufacturer B', 'product_name': 'Product B', 'weight': 2.0, 'variant': 'Variant B', 'net_content': '200ml', 'price': 15.0, 'parent_category': 'Category B', 'child_category': 'Subcategory B', 'description': 'Description for Product B', 'quantity': 200, 'mrp': '25.0'}
96
  ]
97
+ # product = Product.objects.create(data)
98
  product_details.extend(dummy_data)
99
  return JsonResponse(dummy_data[0], safe=False) # Return product details as JSON response
100
  return render(request, 'upload_image.html')