Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/nuxeo/nuxeo-drive into wip-
Browse files Browse the repository at this point in the history
…NXDRIVE-2967-upgrade-the-deprecated-datetime-adapter
  • Loading branch information
gitofanindya committed Sep 19, 2024
2 parents 613e4cd + 35e59ba commit ab66853
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 21 deletions.
9 changes: 7 additions & 2 deletions docs/changes/5.5.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ Release date: `2024-xx-xx`

### Direct Transfer

- [NXDRIVE-2](https://jira.nuxeo.com/browse/NXDRIVE-2):
- [NXDRIVE-2909](https://jira.nuxeo.com/browse/NXDRIVE-2909): Set container title when defining the Folder type from Document Type Selection using Direct Transfer
- [NXDRIVE-2915](https://jira.nuxeo.com/browse/NXDRIVE-2915): Translate "Document type" and "container type" labels on Direct Transfer popup

### Task Management
- [NXDRIVE-2](https://jira.nuxeo.com/browse/NXDRIVE-2):

## GUI

- [NXDRIVE-2](https://jira.nuxeo.com/browse/NXDRIVE-2):
- [NXDRIVE-2962] (https://jira.nuxeo.com/browse/NXDRIVE-2962): Update Translation Files

## Packaging / Build

- [NXDRIVE-2](https://jira.nuxeo.com/browse/NXDRIVE-2):
- [NXDRIVE-2970](https://jira.nuxeo.com/browse/NXDRIVE-2970): Fix security issue: urllib3's Proxy-Authorization request header isn't stripped during cross-origin redirects

## Tests

Expand All @@ -37,6 +39,8 @@ Release date: `2024-xx-xx`

- Upgraded `authlib` from 1.3.0 to 1.3.1
- Upgraded `black` from 23.12.1 to 24.8.0
- Upgraded `boto3` from 1.34.17 to 1.35.21
- Upgraded `botocore` from 1.34.17 to 1.35.21
- Upgraded `certifi` from 2023.7.22 to 2024.7.4
- Upgraded `flake8` from 6.1.0 to 7.1.1
- Upgraded `typing-extensions` from 4.9.0 to 4.12.2
Expand All @@ -46,6 +50,7 @@ Release date: `2024-xx-xx`
- Upgraded `pyflakes` from 3.1.0 to 3.2.0
- Upgraded `pytest-benchmark` from 3.4.1 to 4.0.0
- Upgraded `setuptools` from 69.5.1 to 72.1.0
- Upgraded `urllib3` from 1.26.12 to 1.26.19
- Upgraded `zipp` from 3.18.0 to 3.20.0

## Technical Changes
Expand Down
4 changes: 3 additions & 1 deletion nxdrive/client/uploader/direct_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def upload(
"entity-type": "document",
"name": doc_pair.local_name,
"type": doc_pair.doc_type,
"properties{'dc:title'}": doc_pair.local_name,
"properties": {
"dc:title": doc_pair.local_name,
},
}
item = self.remote.upload_folder_type(
doc_pair.remote_parent_path,
Expand Down
6 changes: 3 additions & 3 deletions nxdrive/data/i18n/i18n-fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"CHANNEL": "Canal",
"CHANNEL_CHANGE_SETTINGS": "Canal de mise à jour",
"CHANNEL_CONFIRM_DANGEROUS": "Confirmer le canal de développement ?",
"CHOOSE_PARTICIPANTS": "Choisir les participants",
"CHOOSE_PARTICIPANTS": "Choisir les participants %1",
"CLOSE": "Fermer",
"COMPLETED": "Terminés",
"COMPLETED_ON": "Terminée le %1",
Expand All @@ -49,7 +49,7 @@
"CONNECTION_REFUSED": "Connexion refusée",
"CONNECTION_SUCCESS": "Connexion réussie",
"CONNECTION_UNKNOWN": "Une erreur inconnue s'est produite lors de la connexion",
"CONSOLIDATE_REVIEW": "Consolider la consultation",
"CONSOLIDATE_REVIEW": "Consolider la consultation %1",
"CONTAINER_TYPE": "Type de dossier",
"CONTEXT_MENU_1": "Voir en ligne",
"CONTEXT_MENU_2": "Copier le lien de partage",
Expand Down Expand Up @@ -403,7 +403,7 @@
"USE_LIGHT_ICONS": "Utiliser des icônes claires",
"USE_SENTRY": "Activer les rapports d'erreur",
"USERNAME": "Utilisateur",
"VALIDATE_DOCUMENT": "Valider le document",
"VALIDATE_DOCUMENT": "Valider le document %1",
"WEB_AUTHENTICATION_WINDOW_TITLE": "Authentification web",
"WELCOME_MESSAGE": "Connectez-vous et synchronisez vos fichiers avec Nuxeo.",
"WINDOWS_ERROR_TITLE": "Erreur de document",
Expand Down
4 changes: 2 additions & 2 deletions nxdrive/data/i18n/i18n-ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"CHANNEL": "チャンネル",
"CHANNEL_CHANGE_SETTINGS": "チャンネルの更新",
"CHANNEL_CONFIRM_DANGEROUS": "開発チャンネルを確認しますか?",
"CHOOSE_PARTICIPANTS": "参加者を選択",
"CHOOSE_PARTICIPANTS": "参加者を選択 %1",
"CLOSE": "閉じる",
"COMPLETED": "完了",
"COMPLETED_ON": "%1上で完了",
Expand Down Expand Up @@ -191,7 +191,7 @@
"FOLDER_USED": "別のNuxeo Driveアカウントによって使用されているフォルダ",
"FREE_DISK_SPACE": "(空きディスク容量: %1)",
"GENERATING": "生成中…",
"GIVE_OPINION": "ご意見をお聞かせください",
"GIVE_OPINION": "ご意見をお聞かせください %1",
"HANDLE_TASKS": "タスクの処理",
"HELP": "ヘルプ",
"HISTORY": "履歴",
Expand Down
11 changes: 10 additions & 1 deletion nxdrive/data/i18n/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
"ADVANCED_SETTINGS": "Advanced settings",
"AGO": "ago",
"APPLY": "Apply",
"AUDIO": "Audio",
"AUTOLOCK": "Autolock",
"AUTH_EXPIRED": "Authentication expired",
"AUTH_UPDATE_ACTION": "Click here to log back in",
"AUTOMATIC": "Use Automatic Configuration Script",
"AUTOSTART": "Start on boot",
"AUTOMATICS": "Automatic",
"AUTOUPDATE": "Auto install new updates",
"AUTOUPDATE_DOWNGRADE": "Version not compatible with the server, a downgrade to %1 is needed. Synchronization won't start until then.",
"AUTOUPDATE_UPGRADE": "A new version %1 is available.",
Expand Down Expand Up @@ -57,7 +59,7 @@
"CONTEXT_MENU_4": "Upload content",
"CONTINUE": "Continue",
"CONTINUE_USING": "Continue using Drive %1",
"CREATE": "Create",
"CREATE": "create",
"CREATE_REPORT": "Generate bug report",
"DATETIME_FORMAT": "%x %X",
"DAYS": "Day(s)",
Expand Down Expand Up @@ -176,12 +178,14 @@
"FEATURE_SYNCHRONIZATION": "Enable or disable the bidirectional synchronization between the local environment and the Nuxeo Platform.\nA restart is needed to apply changes.",
"FEATURE_TASKS_MANAGEMENT": "Handle your tasks from Nuxeo Drive and receive notifications and reminders when a new task is assigned to you.",
"FEEDBACK_LINK": "Something is missing? Share your feedback here.",
"FILE": "File",
"FILE_ALREADY_EXISTS": "There is already a file named \"%1\" in this folder. Do you want to replace it with the one you're moving?",
"FILE_ALREADY_EXISTS_HEADER": "A duplicate file has been found.",
"FILE_PATH": "Path: %1",
"FILTERS_WINDOW_TITLE": "%1 - Filters",
"FILTERS_DISABLED": "You must wait for current synchronization actions to be done before filtering some folders.",
"FINALIZING": "Finalizing ...",
"FOLDER": "Folder",
"FOLDER_DOES_NOT_EXISTS": "This folder does not exist",
"FOLDER_DUPLICATES_DETECTED": "Duplicate folder detected",
"FOLDER_DUPLICATES_MSG": "The following folder(s) already exist under <a href=\"%1\">%2</a>:<ul>%3</ul>Please rename them or process to several transfers within those folders.",
Expand All @@ -197,6 +201,7 @@
"HISTORY": "History",
"HOST": "Host",
"HOURS_AGO": "%1 hours ago",
"IGNORE": "Ignore",
"IGNORES_SYSTRAY": "Ignored Files (%1)",
"IGNORE_PAIR": "Ignore this error",
"IGNORE_REASON_CORRUPT": "This file is ignored because its integrity cannot be verified.",
Expand Down Expand Up @@ -295,11 +300,14 @@
"OPEN_ROOT_FOLDER": "Open %1 folder",
"OPEN_SETTINGS": "Open settings",
"OPEN_WINDOW": "Open window",
"ORDERED_FOLDER": "Ordered Folder",
"OTHER": "Other",
"OVERRIDE": "Override",
"PASSWORD": "Password",
"PENDING_TASKS": "Review required",
"PERSONAL_SPACE": "Personal space",
"PENDING_TASK_REVIEWS": "New task to review",
"PICTURE": "Picture",
"PROXY": "Proxy",
"PROXY_APPLIED": "Proxy settings have been updated",
"PROXY_CHANGE_SETTINGS": "Proxy",
Expand Down Expand Up @@ -404,6 +412,7 @@
"USE_SENTRY": "Enable error reporting",
"USERNAME": "Username",
"VALIDATE_DOCUMENT": "Validate the Document %1",
"VIDEO": "Video",
"WEB_AUTHENTICATION_WINDOW_TITLE": "Web Authentication",
"WELCOME_MESSAGE": "Set your account and synchronize your files with the Nuxeo Platform.",
"WINDOWS_ERROR_TITLE": "Document error",
Expand Down
24 changes: 24 additions & 0 deletions nxdrive/gui/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from ..translator import Translator


def get_known_types_translations() -> dict:
KNOWN_FOLDER_TYPES = {
"OrderedFolder": Translator.get("ORDERED_FOLDER"),
"Folder": Translator.get("FOLDER"),
}
KNOWN_FILE_TYPES = {
"Audio": Translator.get("AUDIO"),
"File": Translator.get("FILE"),
"Picture": Translator.get("PICTURE"),
"Video": Translator.get("VIDEO"),
}
DEFAULT_TYPES = {
"Automatic": Translator.get("AUTOMATICS"),
"Create": Translator.get("CREATE"),
}

return {
"FOLDER_TYPES": KNOWN_FOLDER_TYPES,
"FILE_TYPES": KNOWN_FILE_TYPES,
"DEFAULT": DEFAULT_TYPES,
}
45 changes: 39 additions & 6 deletions nxdrive/gui/folders_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
)
from ..translator import Translator
from ..utils import find_icon, get_tree_list, sizeof_fmt
from .constants import get_known_types_translations
from .folders_model import FilteredDocuments, FoldersOnly
from .folders_treeview import DocumentTreeView, FolderTreeView

Expand Down Expand Up @@ -269,6 +270,11 @@ def __init__(
"dt_last_duplicates_behavior", default="create"
)

_types = get_known_types_translations()
self.KNOWN_FOLDER_TYPES = _types.get("FOLDER_TYPES", {})
self.KNOWN_FILE_TYPES = _types.get("FILE_TYPES", {})
self.DEFAULT_TYPES = _types.get("DEFAULT", {})

Check warning on line 276 in nxdrive/gui/folders_dialog.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_dialog.py#L273-L276

Added lines #L273 - L276 were not covered by tests

self.vertical_layout.addWidget(self._add_group_local())
self.vertical_layout.addWidget(self._add_group_remote())
self.vertical_layout.addWidget(self._add_group_options())
Expand Down Expand Up @@ -407,21 +413,35 @@ def _open_duplicates_doc(self, _: bool) -> None:
"""Open the duplicates management documentation in a browser tab."""
webbrowser.open_new_tab(DOC_URL)

def _check_for_known_types(self, is_folder_type: bool, /) -> None:
if is_folder_type:
for key, val in self.KNOWN_FOLDER_TYPES.items():
if key in self.containerTypeList:
self.containerTypeList.remove(key)
self.containerTypeList.append(val)

Check warning on line 421 in nxdrive/gui/folders_dialog.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_dialog.py#L417-L421

Added lines #L417 - L421 were not covered by tests
else:
for key, val in self.KNOWN_FILE_TYPES.items():
if key in self.docTypeList:
self.docTypeList.remove(key)
self.docTypeList.append(val)

Check warning on line 426 in nxdrive/gui/folders_dialog.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_dialog.py#L423-L426

Added lines #L423 - L426 were not covered by tests

def update_file_group(self, /) -> None:
self.cbDocType.clear()
self.cbDocType.addItem("Automatic", "create")
self.cbContainerType.clear()
if values := list(self.DEFAULT_TYPES.values()):
self.cbContainerType.addItem(values[0], values[1])
self.cbDocType.addItem(values[0], values[1])

Check warning on line 433 in nxdrive/gui/folders_dialog.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_dialog.py#L430-L433

Added lines #L430 - L433 were not covered by tests
if self.remote_folder_ref:
self.docTypeList = self.engine.remote.get_doc_enricher(
self.remote_folder_ref, "subtypes", False
)

self._check_for_known_types(False)

Check warning on line 438 in nxdrive/gui/folders_dialog.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_dialog.py#L438

Added line #L438 was not covered by tests
self.cbDocType.addItems(self.docTypeList)
self.cbContainerType.clear()
self.cbContainerType.addItem("Automatic", "create")
if self.remote_folder_ref:
self.containerTypeList = self.engine.remote.get_doc_enricher(
self.remote_folder_ref, "subtypes", True
)
self._check_for_known_types(True)

Check warning on line 444 in nxdrive/gui/folders_dialog.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_dialog.py#L444

Added line #L444 was not covered by tests
self.cbContainerType.addItems(self.containerTypeList)

def _add_subgroup_doc_type(self, layout: QVBoxLayout, /) -> None:
Expand Down Expand Up @@ -509,6 +529,18 @@ def _find_folders_duplicates(self) -> List[str]:

return folders

def get_known_type_key(self, is_folder: bool, type: str, /) -> str:
if type in self.DEFAULT_TYPES.values():
original_list = self.DEFAULT_TYPES

Check warning on line 534 in nxdrive/gui/folders_dialog.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_dialog.py#L533-L534

Added lines #L533 - L534 were not covered by tests
else:
original_list = (

Check warning on line 536 in nxdrive/gui/folders_dialog.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_dialog.py#L536

Added line #L536 was not covered by tests
self.KNOWN_FOLDER_TYPES if is_folder else self.KNOWN_FILE_TYPES
)
try:
return list(original_list.keys())[list(original_list.values()).index(type)]
except Exception:
return type

Check warning on line 542 in nxdrive/gui/folders_dialog.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_dialog.py#L539-L542

Added lines #L539 - L542 were not covered by tests

def accept(self) -> None:
"""Action to do when the OK button is clicked."""
super().accept()
Expand All @@ -518,9 +550,8 @@ def accept(self) -> None:
if self.cbDocType.currentIndex() == 0
else self.cbDocType.currentText()
)
folder_duplicates = self._find_folders_duplicates()

if folder_duplicates:
if folder_duplicates := self._find_folders_duplicates():

Check warning on line 554 in nxdrive/gui/folders_dialog.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_dialog.py#L554

Added line #L554 was not covered by tests
self.application.folder_duplicate_warning(
folder_duplicates,
self.remote_folder_title,
Expand All @@ -535,6 +566,8 @@ def accept(self) -> None:
doc_type = (
self.cbDocType.currentText() if self.cbDocType.currentIndex() != 0 else ""
)
doc_type = self.get_known_type_key(False, doc_type)
cont_type = self.get_known_type_key(True, cont_type)

Check warning on line 570 in nxdrive/gui/folders_dialog.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_dialog.py#L569-L570

Added lines #L569 - L570 were not covered by tests
self.engine.direct_transfer_async(
self.paths,
self.remote_folder.text(),
Expand Down
22 changes: 22 additions & 0 deletions tests/functional/test_document_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from pathlib import Path

from nxdrive.gui.constants import get_known_types_translations
from nxdrive.translator import Translator


def get_folder(folder) -> Path:
return Path(__file__).parent.parent / "resources" / folder


def test_get_known_types_translations():
Translator(get_folder("i18n"))
assert Translator.locale() == "en"
res = get_known_types_translations()

known_folder_types = res.get("FOLDER_TYPES", {})
known_file_types = res.get("FILE_TYPES", {})
default_types = res.get("DEFAULT", {})

assert known_folder_types["Folder"] == Translator.get("FOLDER")
assert known_file_types["Audio"] == Translator.get("AUDIO")
assert default_types["Automatic"] == Translator.get("AUTOMATICS")
12 changes: 6 additions & 6 deletions tools/deps/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ authlib==1.3.1 \
--hash=sha256:7ae843f03c06c5c0debd63c9db91f9fda64fa62a42a77419fa15fbb7e7a58917 \
--hash=sha256:d35800b973099bbadc49b42b256ecb80041ad56b7fe1216a362c7943c088f377
# via nuxeo
boto3==1.34.17 \
--hash=sha256:1efc02be786884034d503d59c018cf7650d0cff9fcb37cd2eb49b802a6fe6111 \
--hash=sha256:8ca248cc84e7e859e4e276eb9c4309fa01a3e58473bf48d6c33448be870c2bb8
boto3==1.35.21 \
--hash=sha256:247f88eedce9ae4e014a8fc14a9473759bb8e391460d49396a3b600fb649f33b \
--hash=sha256:db5fbbd10248db060f2ccce3ae17764f1641c99c8b9f51d422c26ebe25703a1e
# via nuxeo
botocore==1.34.17 \
--hash=sha256:7272c39032c6f1d62781e4c8445d9a1d9140c2bf52ba7ee66bf6db559c4b2427 \
--hash=sha256:e48a662f3a6919219276b55085e8f73c3347966675f55e9d448be30cf79678ee
botocore==1.35.21 \
--hash=sha256:3db9ddfe521edc0753fc8c68caef71c7806e1d2d21ce8cbabc2065b7d79192f2 \
--hash=sha256:db917e7d7b3a2eed1310c6496784bc813c91f020a021c2ab5f9df7d28cdb4f1d
# via boto3, s3transfer
certifi==2024.8.30 \
--hash=sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8 \
Expand Down

0 comments on commit ab66853

Please sign in to comment.