Spaces:
Runtime error
Runtime error
gamingflexer commited on
Commit ·
f296ede
1
Parent(s): 4ffd1ee
Recoridng removed
Browse files- src/app/api/urls.py +0 -2
- src/app/api/views.py +1 -26
src/app/api/urls.py
CHANGED
|
@@ -9,6 +9,4 @@ urlpatterns = [
|
|
| 9 |
path('product/<int:product_id>/edit/', views.edit_product, name='edit_product'),
|
| 10 |
path('upload/', views.upload_image_and_audio, name='add_product_by_image'),
|
| 11 |
path('api/products/', ProductAPIView.as_view(), name='product_api'),
|
| 12 |
-
path("record/", views.record, name="record"),
|
| 13 |
-
path("record/detail/<uuid:id>/", views.record_detail, name="record_detail"),
|
| 14 |
]
|
|
|
|
| 9 |
path('product/<int:product_id>/edit/', views.edit_product, name='edit_product'),
|
| 10 |
path('upload/', views.upload_image_and_audio, name='add_product_by_image'),
|
| 11 |
path('api/products/', ProductAPIView.as_view(), name='product_api'),
|
|
|
|
|
|
|
| 12 |
]
|
src/app/api/views.py
CHANGED
|
@@ -135,29 +135,4 @@ def edit_voice_product(request,product_id):
|
|
| 135 |
else:
|
| 136 |
return JsonResponse({'error': 'No voice file submitted.'}, status=400)
|
| 137 |
else:
|
| 138 |
-
return render(request, 'edit_voice_product.html')
|
| 139 |
-
|
| 140 |
-
def record(request):
|
| 141 |
-
if request.method == "POST":
|
| 142 |
-
audio_file = request.FILES.get("recorded_audio")
|
| 143 |
-
language = request.POST.get("language")
|
| 144 |
-
record = Record.objects.create(language=language, voice_record=audio_file)
|
| 145 |
-
record.save()
|
| 146 |
-
messages.success(request, "Audio recording successfully added!")
|
| 147 |
-
return JsonResponse(
|
| 148 |
-
{
|
| 149 |
-
"url": record.get_absolute_url(),
|
| 150 |
-
"success": True,
|
| 151 |
-
}
|
| 152 |
-
)
|
| 153 |
-
context = {"page_title": "Record audio"}
|
| 154 |
-
return render(request, "record.html", context)
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
def record_detail(request, id):
|
| 158 |
-
record = get_object_or_404(Record, id=id)
|
| 159 |
-
context = {
|
| 160 |
-
"page_title": "Recorded audio detail",
|
| 161 |
-
"record": record,
|
| 162 |
-
}
|
| 163 |
-
return render(request, "record_detail.html", context)
|
|
|
|
| 135 |
else:
|
| 136 |
return JsonResponse({'error': 'No voice file submitted.'}, status=400)
|
| 137 |
else:
|
| 138 |
+
return render(request, 'edit_voice_product.html')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|