Skip to content

feat(auth): configurable team lead roles for project and squad management - #43

Merged
espdesign merged 5 commits into
developfrom
feature/configurable-team-lead-roles
Sep 17, 2026
Merged

espdesign merged 5 commits into
developfrom
feature/configurable-team-lead-roles

Conversation

@espdesign

Copy link
Copy Markdown
Collaborator

Summary of Changes

This PR enables Server Managers to delegate project and squad creation and management capabilities to designated Discord Team Lead roles without requiring full Discord Manage Server or Administrator permissions.

1. Database Schema & Persistence

  • Added GuildLeadRoleTable (guild_lead_roles with composite primary key (guild_id, discord_role_id)).
  • Added Alembic migration 0002_add_guild_lead_roles.py.
  • Implemented IGuildLeadRoleRepository port and PostgresGuildLeadRoleRepository adapter.
  • Wired repository into SqlAlchemyUnitOfWork.

2. Domain & Authorization Services

  • Updated AuthService.can_manage_projects(user, guild_id, guild) and require_project_management to check:
    1. Discord Server Manager (manage_guild / administrator).
    2. Configured Team Lead roles in guild_lead_roles.
    3. Active Squad Leads in the guild.
  • Added automatic member and role resolution when interactions supply discord.User or uncached members.
  • Added methods add_guild_lead_role, remove_guild_lead_role, and list_guild_lead_roles.

3. Slash Commands & Administration

  • Added /pm admin lead-role action:<add|remove|list> role:<@Role> for server managers to configure lead roles.
  • Updated permissions across /pm project create, role, squad, lead, archive, unarchive, setup_forum, rebuild, and /pm squad create to allow authorized Team Lead roles.

4. Interactive Discord UI & Control Hubs

  • Interactive Lead Roles Admin Portal: Added a Lead Roles button to /pm menu (PmDashboardView) for server managers, opening LeadRolesAdminView with a native Discord RoleSelect menu to view, assign, and remove lead roles with 1 click.
  • Direct Creation on Forum Control Hub: Added a Create Project button (Row 1) on PmHubView so authorized Team Leads and Server Managers can initialize projects directly from pinned forum control centers.
  • Project Management Hub (ProjectMenuView): Standardized button label to Create Project and displayed creation/management actions for users with authorized Team Lead roles.
  • Repository Auto-Wiring: Added auto-wiring in PmHubView and ensure_pinned_hub_post to ensure guild_lead_role_repo is always active even if views are reconstructed without explicit service passing.

5. Documentation & Wiki

  • Updated docs/wiki/Teams-and-Authorization.md with the new hierarchy, authorization matrix, and configuration instructions.
  • Updated docs/wiki/Slash-Commands-Reference.md with /pm admin lead-role and updated subcommand permissions.
  • Updated docs/wiki/Forum-Channels-and-Hubs.md with the new button layout and ASCII diagrams.
  • Updated docs/wiki/Workflow-Guide.md and docs/wiki/Home.md.

Testing & Verification

  • Unit & integration tests in tests/test_authorization.py, tests/test_menus.py, and tests/test_cogs.py.
  • Full test suite: 385/385 passing (make check).
  • Formatting & linting clean via ruff check and ruff format.
  • Rebuilt and verified in Docker container via make docker-build.

…efully

- Add translation for discord.app_commands errors (MissingPermissions, BotMissingPermissions, CommandOnCooldown, CheckFailure)
- Add cog_app_command_error handler in PmCog to return ephemeral error responses to users
- Register fallback on_tree_error handler on DggPmBot.tree
- Add tests covering app command error translation, PmCog error handling, and bot tree fallback
@espdesign
espdesign merged commit 6296fa3 into develop Sep 17, 2026
8 checks passed
@espdesign
espdesign deleted the feature/configurable-team-lead-roles branch September 17, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant