Skip to content
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
2 changes: 1 addition & 1 deletion pum/pum_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def role_manager(self) -> RoleManager:
"""Return a RoleManager instance based on the roles defined in the configuration."""
if not self.config.roles:
logger.warning("No roles defined in the configuration. Returning an empty RoleManager.")
return RoleManager()
return RoleManager([])
return RoleManager([role.model_dump() for role in self.config.roles])

def pre_hook_handlers(self) -> list[HookHandler]:
Expand Down
7 changes: 7 additions & 0 deletions pum/upgrader.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,15 @@ def install_demo_data(
name: str,
*,
parameters: dict | None = None,
grant: bool = True,
) -> None:
"""Install demo data for the module.

Args:
connection: The database connection to use.
name: The name of the demo data to install.
parameters: The parameters to pass to the demo data SQL.
grant: If True, grant permissions to the roles after installing the demo data. Default is True.
"""
if name not in self.config.demo_data():
raise PumException(f"Demo data '{name}' not found in the configuration.")
Expand Down Expand Up @@ -167,4 +169,9 @@ def install_demo_data(

connection.commit()

if grant:
self.config.role_manager().grant_permissions(connection=connection, commit=False)

connection.commit()

logger.info("Demo data '%s' installed successfully.", name)