Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix read-only + dummy feature by only looking at group names #146

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/fontra_rcjk/projectmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ async def closeFontHandler():
logger.info(f"new FontHandler for '{path}'")
fontHandler = FontHandler(
backend,
readOnly=self.readOnly,
readOnly=self.readOnly or userReadOnly,
dummyEditor=dummyEditor,
allConnectionsClosedCallback=closeFontHandler,
)
await fontHandler.startTasks()
Expand All @@ -218,22 +219,21 @@ async def _userPermissions(self) -> tuple[bool, bool]:
userMeResponse = await self.rcjkClient.user_me()
userInfo = userMeResponse["data"]

# Only check write permissions is the user belongs to at least one group
userReadOnly = (
not _hasKeyValue(
userInfo["permissions"], "codename", "change_characterglyph"
)
if "permissions" in userInfo and userInfo.get("groups")
else False
)
groupsList = userInfo.get("groups")

dummyEditor = (
_hasKeyValue(userInfo["groups"], "name", "DummyDesigners")
if "groups" in userInfo
else False
)
if groupsList is None:
# b/w compat
return False, False

groups = {group["name"] for group in groupsList}

if "DummyDesigners" in groups:
return True, True

if "Reviewers" in groups:
return True, False

return userReadOnly, dummyEditor
return False, False


def _hasKeyValue(items, key, value):
Expand Down
Loading