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

Roles without remapping in VenueRoom (resolves #1893) #1896

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion funnel/models/project_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .membership_mixin import ImmutableUserMembershipMixin
from .project import Project

__all__ = ['ProjectMembership', 'project_child_role_map']
__all__ = ['ProjectMembership', 'project_child_role_map', 'project_child_role_set']

#: Roles in a project and their remapped names in objects attached to a project
project_child_role_map: dict[str, str] = {
Expand All @@ -24,6 +24,9 @@
'reader': 'reader',
}

#: A model that is indirectly under a project needs the role names without remapping
project_child_role_set: set[str] = set(project_child_role_map.values())

#: ProjectMembership maps project's `account_admin` role to membership's `editor`
#: role in addition to the recurring role grant map
project_membership_role_map: dict[str, str | set[str]] = {
Expand Down
6 changes: 2 additions & 4 deletions funnel/models/venue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from __future__ import annotations

import itertools

from sqlalchemy.ext.orderinglist import ordering_list

from coaster.sqlalchemy import add_primary_relationship, with_roles
Expand All @@ -19,7 +17,7 @@
)
from .helpers import MarkdownCompositeBasic, reopen
from .project import Project
from .project_membership import project_child_role_map
from .project_membership import project_child_role_map, project_child_role_set

__all__ = ['Venue', 'VenueRoom']

Expand Down Expand Up @@ -113,7 +111,7 @@ class VenueRoom(UuidMixin, BaseScopedNameMixin, Model):
venue: Mapped[Venue] = with_roles(
relationship(Venue, back_populates='rooms'),
# Since Venue already remaps Project roles, we just want the remapped role names
grants_via={None: set(itertools.chain(*project_child_role_map.values()))},
grants_via={None: project_child_role_set},
)
parent: Mapped[Venue] = sa.orm.synonym('venue')
description, description_text, description_html = MarkdownCompositeBasic.create(
Expand Down