Allow changing active scan batch location
This commit is contained in:
+18
-2
@@ -11,7 +11,7 @@ from django.views.decorators.http import require_GET, require_http_methods, requ
|
||||
from .models import (InventoryLocation, InventoryScanBatch, InventoryScanItem,
|
||||
InventoryReviewPreference, InventoryScanRun)
|
||||
from .services.inventory_scanner import (ScanWorkflowError, adjust_confirmed_count,
|
||||
approve_scan_item, approve_scan_items, confirm_scan_item, create_active_scan,
|
||||
approve_scan_item, approve_scan_items, change_draft_batch_location, confirm_scan_item, create_active_scan,
|
||||
defer_scan_item, discard_active_scan, get_or_create_active_run,
|
||||
resume_active_run, save_review_item, submit_batch, update_review_preference)
|
||||
|
||||
@@ -118,7 +118,23 @@ def submit_scan_batch(request, batch_id):
|
||||
next_batch = run.batches.get(status=InventoryScanBatch.Status.DRAFT)
|
||||
return JsonResponse({'ok': True, 'batch_id': next_batch.pk,
|
||||
'location_id': next_batch.location_id, 'location': next_batch.location.name,
|
||||
'submit_url': reverse('food:inventory-scan-submit', args=[next_batch.pk])})
|
||||
'submit_url': reverse('food:inventory-scan-submit', args=[next_batch.pk]),
|
||||
'location_url': reverse('food:inventory-scan-location', args=[next_batch.pk])})
|
||||
|
||||
|
||||
@login_required
|
||||
@require_POST
|
||||
def change_scan_location(request, batch_id):
|
||||
payload, error = _payload(request)
|
||||
if error:
|
||||
return JsonResponse({'error': error}, status=400)
|
||||
try:
|
||||
batch = change_draft_batch_location(request.user, batch_id=batch_id,
|
||||
location_id=payload.get('location_id'))
|
||||
except (ScanWorkflowError, TypeError, ValueError) as error:
|
||||
return JsonResponse({'error': str(error)}, status=400)
|
||||
return JsonResponse({'ok': True, 'location_id': batch.location_id,
|
||||
'location': batch.location.name})
|
||||
|
||||
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user