Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow single file upload #1339

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/api/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ def commit(self, request, pk=None, project_pk=None):
task.partial = False
task.images_count = len(task.scan_images())

if task.images_count < 2:
raise exceptions.ValidationError(detail=_("You need to upload at least 2 images before commit"))
if task.images_count < 1:
raise exceptions.ValidationError(detail=_("You need to upload at least 1 file before commit"))

task.save()
worker_tasks.process_task.delay(task.id)
Expand Down
11 changes: 0 additions & 11 deletions app/tests/test_api_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ def test_task(self):
}, format="multipart")
self.assertTrue(res.status_code == status.HTTP_400_BAD_REQUEST)

# Cannot create a task with just 1 image
res = client.post("/api/projects/{}/tasks/".format(project.id), {
'images': image1
}, format="multipart")
self.assertTrue(res.status_code == status.HTTP_400_BAD_REQUEST)
image1.seek(0)

# Normal case with images[], name and processing node parameter
res = client.post("/api/projects/{}/tasks/".format(project.id), {
'images': [image1, image2],
Expand Down Expand Up @@ -1118,10 +1111,6 @@ def test_task_chunked_uploads(self):
self.assertEqual(res.data['success'], True)
image1.seek(0)

# Cannot commit with a single image
res = client.post("/api/projects/{}/tasks/{}/commit/".format(project.id, task.id))
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)

# And second image
res = client.post("/api/projects/{}/tasks/{}/upload/".format(project.id, task.id), {
'images': [image2],
Expand Down
2 changes: 1 addition & 1 deletion nodeodm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def process_new_task(self, images, name=None, options=[], progress_callback=None

:returns UUID of the newly created task
"""
if len(images) < 2: raise exceptions.NodeServerError("Need at least 2 images")
if len(images) < 1: raise exceptions.NodeServerError("Need at least 1 file")

api_client = self.api_client()

Expand Down