Skip to content

Commit

Permalink
Fix Drag and drop in Appraisal tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhwaniartefact committed Sep 26, 2023
1 parent ebd28c0 commit 1c64d31
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/dashboard/src/components/filesystem_ajax/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,6 @@ def _copy_files_to_arrange(
):
sourcepath = sourcepath.lstrip("/") # starts with 'originals/', not '/originals/'
# Insert each file into the DB

# Lots of error checking:
if not sourcepath or not destination:
raise ValueError(_("GET parameter 'filepath' or 'destination' was blank."))
Expand Down Expand Up @@ -915,8 +914,8 @@ def copy_to_arrange(request, sources=None, destinations=None, fetch_children=Fal
for entry in entries:
entries_to_copy.append(
models.SIPArrange(
original_path=entry["original_path"],
arrange_path=entry["arrange_path"],
original_path=entry["original_path"].encode(),
arrange_path=entry["arrange_path"].encode(),
file_uuid=entry["file_uuid"],
transfer_uuid=entry["transfer_uuid"],
)
Expand Down
5 changes: 4 additions & 1 deletion src/dashboard/src/main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,10 @@ class Meta:
def __str__(self):
return str(
_("%(original)s -> %(arrange)s")
% {"original": self.original_path, "arrange": self.arrange_path}
% {
"original": self.original_path.decode(),
"arrange": self.arrange_path.decode(),
}
)

@classmethod
Expand Down
49 changes: 49 additions & 0 deletions src/dashboard/tests/test_filesystem_ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,55 @@ def test_move_within_arrange(self):
assert b64encode_string("newsip") in response_dict["entries"]
assert len(response_dict["entries"]) == 2

@mock.patch(
"storageService.get_first_location",
return_value={"uuid": "355d110f-b641-4b6b-b1c0-8426e63951e5"},
)
@mock.patch(
"storageService.get_file_metadata",
side_effect=[
[
{
"fileuuid": "0b603cee-1f8a-4842-996a-e02a0307ccf7",
"sipuuid": "99c87143-6f74-4398-84e0-14a8ca4bd05a",
}
],
[
{
"fileuuid": "03a33ef5-8714-46cc-aefe-7283186341ca",
"sipuuid": "4ae7b624-9ba7-452a-adbc-1588223b7098",
}
],
],
)
@mock.patch(
"storageService.browse_location",
return_value={
"directories": [],
"entries": ["error.txt", "tree_a.txt"],
"properties": {
"error.txt": {"size": 8},
"tree_a.txt": {"size": 6},
},
},
)
def test_copy_within_arrange(
self, browse_location, get_file_metadata, get_first_location
):
# Copy directory
response = self.client.post(
reverse("filesystem_ajax:copy_to_arrange"),
data={
"filepath": b64encode_string("/originals/objects/"),
"destination": b64encode_string("/arrange/"),
},
follow=True,
)
assert response.status_code == 201
assert json.loads(response.content.decode("utf8")) == {
"message": "Files added to the SIP."
}

def test_copy_from_arrange_to_completed(self):
sip_uuid = "a29e7e86-eca9-43b6-b059-6f23a9802dc8"
models.SIP.objects.create(uuid=sip_uuid)
Expand Down

0 comments on commit 1c64d31

Please sign in to comment.