Skip to content

Commit

Permalink
Roles without remapping in VenueRoom (resolves #1893) (#1896)
Browse files Browse the repository at this point in the history
  • Loading branch information
jace authored Oct 10, 2023
1 parent 2dcad8d commit a593bf9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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

0 comments on commit a593bf9

Please sign in to comment.