Skip to content

Commit

Permalink
NXDRIVE-2942: Improve folder selection on Direct Transfer screen --Fi…
Browse files Browse the repository at this point in the history
…xes as per Customer Requirement
  • Loading branch information
gitofanindya committed Aug 27, 2024
1 parent 05f09bd commit 7bb3017
Showing 1 changed file with 40 additions and 15 deletions.
55 changes: 40 additions & 15 deletions nxdrive/gui/folders_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,29 +97,48 @@ def folderish(self) -> bool:

def enable(self) -> bool:
"""Allow to select the folder only if the user can effectively create documents inside."""
return (
"HiddenInCreation" not in self.doc.facets
and self.doc.type not in Options.disallowed_types_for_dt
and "AddChildren" in self.doc.contextParameters["permissions"]
)
try:
return (

Check warning on line 101 in nxdrive/gui/folders_model.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_model.py#L100-L101

Added lines #L100 - L101 were not covered by tests
"HiddenInCreation" not in self.doc.facets
and self.doc.type not in Options.disallowed_types_for_dt
and "AddChildren" in self.doc.contextParameters["permissions"]
)
except Exception:
return (

Check warning on line 107 in nxdrive/gui/folders_model.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_model.py#L106-L107

Added lines #L106 - L107 were not covered by tests
"HiddenInCreation" not in self.doc["facets"]
and self.doc["type"] not in Options.disallowed_types_for_dt
and "AddChildren" in self.doc["contextParameters"]["permissions"]
)

def get_id(self) -> str:
"""The document's UID."""
return self.doc.uid
try:
return self.doc.uid
except Exception:
return self.doc["uid"]

Check warning on line 118 in nxdrive/gui/folders_model.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_model.py#L115-L118

Added lines #L115 - L118 were not covered by tests

def get_label(self) -> str:
"""The document's name as it is showed in the tree."""
return self.doc.title
try:
return self.doc.title
except Exception:
return self.doc["title"]

Check warning on line 125 in nxdrive/gui/folders_model.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_model.py#L122-L125

Added lines #L122 - L125 were not covered by tests

def get_path(self) -> str:
"""Guess the document's path on the server."""
return self.doc.path
try:
return self.doc.path
except Exception:
return self.doc["path"]

Check warning on line 132 in nxdrive/gui/folders_model.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_model.py#L129-L132

Added lines #L129 - L132 were not covered by tests

def selectable(self) -> bool:
"""Allow to fetch its children only if the user has at least the "Read" permission
and if it contains at least one subfolder.
"""
return "Read" in self.doc.contextParameters["permissions"]
try:
return "Read" in self.doc.contextParameters["permissions"]
except Exception:
return "Read" in self.doc["contextParameters"]["permissions"]

Check warning on line 141 in nxdrive/gui/folders_model.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_model.py#L138-L141

Added lines #L138 - L141 were not covered by tests


class FilteredDoc(FileInfo):
Expand Down Expand Up @@ -263,18 +282,24 @@ def _get_root_folders(self) -> List["Documents"]:
else it will also show a loading error for the personal space.
"""
root_details = []

Check warning on line 284 in nxdrive/gui/folders_model.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_model.py#L284

Added line #L284 was not covered by tests
returned_folders = []
try:
roots = self.get_roots()
for root in roots:
if (

Check warning on line 288 in nxdrive/gui/folders_model.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_model.py#L286-L288

Added lines #L286 - L288 were not covered by tests
root["type"] == "Workspace"
root["type"] == "Folder"
and root["uid"] != self.personal_space_uid
and root["parentRef"] != self.personal_space_uid
):
for doc in self._get_children(root["parentRef"]):
if doc.title not in returned_folders:
returned_folders.append(doc.title)
yield Doc(doc)
doc = self.remote.fetch(

Check warning on line 293 in nxdrive/gui/folders_model.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_model.py#L293

Added line #L293 was not covered by tests
root["uid"],
enrichers=["permissions"],
)
if (

Check warning on line 297 in nxdrive/gui/folders_model.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_model.py#L297

Added line #L297 was not covered by tests
"Write" in doc["contextParameters"]["permissions"]
or "ReadWrite" in doc["contextParameters"]["permissions"]
or "Everything" in doc["contextParameters"]["permissions"]
):
yield Doc(doc)

Check warning on line 302 in nxdrive/gui/folders_model.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/folders_model.py#L302

Added line #L302 was not covered by tests
except Exception:
log.warning("Error while retrieving documents on '/'", exc_info=True)
context = {"permissions": [], "hasFolderishChild": False}
Expand Down

0 comments on commit 7bb3017

Please sign in to comment.