Skip to content

Commit

Permalink
Web UI: Remove workaround for listing English locale (#1291)
Browse files Browse the repository at this point in the history
* Remove workaround for listing English locale

* Use pathlib object to construct upload path
  • Loading branch information
rdmark authored Nov 3, 2023
1 parent b69c039 commit cb6174f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions python/web/src/templates/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2>{{ _("Upload File from Local Computer") }}</h2>
{% for dir in images_subdirs %}
<option value="{{dir}}">{{dir}}</option>
{% endfor %}
<option value="/" selected>/</option>
<option value="" selected>/</option>
</select>
{% if file_server_dir_exists %}
<input type="radio" name="destination" id="shared_files" value="shared_files">
Expand All @@ -31,7 +31,7 @@ <h2>{{ _("Upload File from Local Computer") }}</h2>
{% for dir in shared_subdirs %}
<option value="{{dir}}">{{dir}}</option>
{% endfor %}
<option value="/" selected>/</option>
<option value="" selected>/</option>
</select>
{% endif %}
<input type="radio" name="destination" id="piscsi_config" value="piscsi_config">
Expand Down
12 changes: 6 additions & 6 deletions python/web/src/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def get_supported_locales():
"""
locales = [
{"language": x.language, "display_name": x.display_name}
for x in [*BABEL.list_translations(), Locale("en")]
for x in [*BABEL.list_translations()]
]

return sorted(locales, key=lambda x: x["language"])
Expand Down Expand Up @@ -1038,14 +1038,14 @@ def upload_file():
if not safe_path["status"]:
return make_response(safe_path["msg"], 403)
server_info = piscsi_cmd.get_server_info()
destination_dir = server_info["image_dir"] + images_subdir
destination_dir = Path(server_info["image_dir"]) / images_subdir
elif destination == "shared_files":
safe_path = is_safe_path(Path("." + shared_subdir))
if not safe_path["status"]:
return make_response(safe_path["msg"], 403)
destination_dir = FILE_SERVER_DIR + shared_subdir
destination_dir = Path(FILE_SERVER_DIR) / shared_subdir
elif destination == "piscsi_config":
destination_dir = CFG_DIR
destination_dir = Path(CFG_DIR)
else:
return make_response(_("Unknown destination"), 403)

Expand All @@ -1054,8 +1054,8 @@ def upload_file():
file_name = secure_filename(file_object.filename)
tmp_file_name = "__tmp_" + file_name

save_path = path.join(destination_dir, file_name)
tmp_save_path = path.join(destination_dir, tmp_file_name)
save_path = destination_dir / file_name
tmp_save_path = destination_dir / tmp_file_name
current_chunk = int(request.form["dzchunkindex"])

# Makes sure not to overwrite an existing file,
Expand Down
2 changes: 1 addition & 1 deletion python/web/tests/api/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def test_upload_file(http_client, delete_file):

form_data = {
"destination": "disk_images",
"images_subdir": "/",
"images_subdir": "",
"dzuuid": str(uuid.uuid4()),
"dzchunkindex": chunk_number,
"dzchunksize": chunk_size,
Expand Down

0 comments on commit cb6174f

Please sign in to comment.