Skip to content

Update filename#931

Open
SHU8HAM1 wants to merge 3 commits into
mjordan:mainfrom
SHU8HAM1:Update-Filename
Open

Update filename#931
SHU8HAM1 wants to merge 3 commits into
mjordan:mainfrom
SHU8HAM1:Update-Filename

Conversation

@SHU8HAM1
Copy link
Copy Markdown

Link to Github issue or other discussion

#829, #861, mjordan/islandora_workbench_integration#35

What does this PR do?

Adds the functionality of changing file names and their URIs which is used to change file names to hide any information stored in the file name.

What changes were made?

Adds a new function in the workbench file called "update_filenames", adds an integration test in islandora_tests.py and slightly modifies functions in workbench_utils.py to include "update_filenames" as a task.

How to test / verify this PR?

For the integration test, open islandora_workbench folder in terminal, then run "python3 tests/islandora_tests.py TestUpdateFileName". To test the usage of the task, you have to create a config file with task as "update_filenames" and host, username, password, input_csv. For the csv file, you only need the file_id (the file you are trying to update) and filename (the new, updated file name).

Interested Parties

@mjordan


Checklist

  • Before opening this PR, have you opened an issue explaining what you want to to do?
  • Have you included some configuration and/or CSV files useful for testing this PR?
  • Have you written unit or integration tests if applicable?
  • Does the code added in this PR require a version of Python that is higher than the current minimum version?
  • If the changes in this PR require an additional Python library, have you included it in setup.py?
  • If the changes in this PR add a new configuration option, have you provided a default for when the option is not present in the .yml file?

@SHU8HAM1
Copy link
Copy Markdown
Author

Hello, is there anything else that needs to be done in this PR?

@mjordan
Copy link
Copy Markdown
Owner

mjordan commented Apr 22, 2025

Hi @SHU8HAM1 I have tested this and I am not sure it's working. I am in your branch of the Islandora Workbench Integration module, and in your branch of islandora_workbench.

I have two thumbnail images, originally named IMG_5083-Thumbnail Image.jpg and IMG_1410-Thumbnail Image.jpg. Here is my input CSV for the new update_filenames task:

file_id,filename
16,alcatraz_tn.jpg
14,havana_tn.jpg

and here is my config file:

task: update_filenames
host: https://islandora.dev
username: admin
password: password
input_csv: update_tn_filenames.csv
standalone_media_url: true
secure_ssl_only: false

I can confirm that the filename attribute of the files has changed to match the input CSV, but the URL hasn't. Is that to be expected? Here is the JSON of one of the files that I changed:

{
  "fid": [
    {
      "value": 16
    }
  ],
  "uuid": [
    {
      "value": "c823217a-6f88-4a68-9da5-23009b0cc786"
    }
  ],
  "langcode": [
    {
      "value": "en"
    }
  ],
  "uid": [
    {
      "target_id": 1,
      "target_type": "user",
      "target_uuid": "36d6a639-1c68-489a-80e8-cf3f7379787e",
      "url": "/user/1"
    }
  ],
  "filename": [
    {
      "value": "alcatraz_tn.jpg"
    }
  ],
  "uri": [
    {
      "value": "public://2025-04/IMG_5083-Thumbnail Image.jpg",
      "url": "/sites/default/files/2025-04/IMG_5083-Thumbnail%20Image.jpg"
    }
  ],
  "filemime": [
    {
      "value": "image/jpeg"
    }
  ],
  "filesize": [
    {
      "value": 7717
    }
  ],
  "status": [
    {
      "value": true
    }
  ],
  "created": [
    {
      "value": "2025-04-22T19:15:23+00:00",
      "format": "Y-m-d\\TH:i:sP"
    }
  ],
  "changed": [
    {
      "value": "2025-04-22T19:47:27+00:00",
      "format": "Y-m-d\\TH:i:sP"
    }
  ]
}

I can confirm that the "Filename" value for this file at /admin/content/files has changed to the expected value, but the filename in my Drupal public filesystem (/web/sites/default/files/2025-04) hasn't.

Sorry if I misunderstood the functionality of this new task. Please let me know if what I describe above confirms that this is working as you intend.

@mjordan
Copy link
Copy Markdown
Owner

mjordan commented Apr 22, 2025

Here is a screenshot of the updated files' entries at /admin/content/files:

Screenshot Capture - 2025-04-22 - 13-13-37

But here are the file's entries when I ls in my Drupal public filesystem directory:

IMG_2958-Thumbnail Image.jpg
IMG_5083-Thumbnail Image.jpg

@SHU8HAM1
Copy link
Copy Markdown
Author

Hi Mark, so sorry about that. It seems like I forgot to push the last commit onto my branch, if you try it now, it should change the file URI and name as well

@mjordan
Copy link
Copy Markdown
Owner

mjordan commented Apr 23, 2025

To confirm, this is the PR I should be testing, not #861, correct? Does this PR superseded that one?

@mjordan mjordan mentioned this pull request Apr 23, 2025
6 tasks
@SHU8HAM1
Copy link
Copy Markdown
Author

Hi @mjordan, yes, this is the PR that should be tested

@mjordan
Copy link
Copy Markdown
Owner

mjordan commented Apr 23, 2025

OK, I'm going to close the other one.

@mjordan
Copy link
Copy Markdown
Owner

mjordan commented Apr 24, 2025

I'm running Workbench at commit 4301b4a (latest in your branch) and am now seeing the filename on the public filesystem being changed, and the filename in the "files" content list at https://islandora.dev/admin/content/files. The media name that the file belongs to is not updated. Is that intentional? I would guess that people would expect it to be, maybe we can add that later.

@SHU8HAM1
Copy link
Copy Markdown
Author

Hi @mjordan, yes, that is intentional as the media name can be changed and set by the user but filename just gets updated automatically.

@mjordan
Copy link
Copy Markdown
Owner

mjordan commented Apr 24, 2025

OK, thanks, I'll test a bit more but this looks good. We will need to merge mjordan/islandora_workbench_integration#35 at the same time as this PR and I have left some comments over there for you.

@mjordan
Copy link
Copy Markdown
Owner

mjordan commented Apr 26, 2025

I just noticed there is no integration test like there was in #861 (see here). Can you add one please?

@Kxka Kxka mentioned this pull request Sep 18, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants