Skip to content
Merged
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5cfcfb0
Allow committee-elect to update actions (and appear in auto-complete)
Thatsmusic99 May 24, 2025
aa327c4
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] May 24, 2025
87e097c
Address some Ruff errors
Thatsmusic99 May 24, 2025
17b1db2
Remove committee-elect check
Thatsmusic99 May 24, 2025
b172946
Remove committee-elect check
Thatsmusic99 May 24, 2025
ce5c6a5
Suppress CommitteeElectRoleDoesNotExistError
Thatsmusic99 May 24, 2025
de3c508
Fix final Ruff errors
Thatsmusic99 May 24, 2025
8e78b0a
Shorten expression for collecting committee/elect members
Thatsmusic99 May 24, 2025
cbc99e5
Make list command also non-committee
MattyTheHacker May 24, 2025
d05940b
Add a logging message
MattyTheHacker May 24, 2025
4650451
Merge branch 'allow-committee-elect-action-update' of github.com:CSSU…
MattyTheHacker May 24, 2025
0410964
Merge branch 'main' into allow-committee-elect-action-update
MattyTheHacker May 25, 2025
790636b
Merge branch 'main' into allow-committee-elect-action-update
MattyTheHacker May 27, 2025
6252439
Merge branch 'main' into allow-committee-elect-action-update
MattyTheHacker May 27, 2025
9730625
Update cogs/committee_actions_tracking.py
MattyTheHacker May 27, 2025
e9d6dbf
Apply suggestions from code review
MattyTheHacker May 27, 2025
cfac936
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] May 27, 2025
bddc4b5
Refactor fetching
MattyTheHacker May 27, 2025
78a3dd9
Merge main into allow-committee-elect-action-update
cssbhamdev Jun 12, 2025
c7311de
Merge main into allow-committee-elect-action-update
cssbhamdev Jun 13, 2025
3db1786
Add note about committee check
MattyTheHacker Jun 13, 2025
a2a1f32
Merge main into allow-committee-elect-action-update
cssbhamdev Jun 13, 2025
8d88100
Fix suggestions
MattyTheHacker Jun 13, 2025
d535819
Update cogs/committee_actions_tracking.py
MattyTheHacker Jun 14, 2025
09d6414
Update cogs/committee_actions_tracking.py
MattyTheHacker Jun 14, 2025
b02350e
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jun 14, 2025
80f2607
Merge main into allow-committee-elect-action-update
cssbhamdev Jun 14, 2025
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
50 changes: 37 additions & 13 deletions cogs/committee_actions_tracking.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Contains cog classes for tracking committee-actions."""

import contextlib
import logging
import random
from enum import Enum
Expand All @@ -11,6 +12,7 @@

from db.core.models import AssignedCommitteeAction, DiscordMember
from exceptions import (
CommitteeElectRoleDoesNotExistError,
CommitteeRoleDoesNotExistError,
InvalidActionDescriptionError,
InvalidActionTargetError,
Expand Down Expand Up @@ -129,11 +131,19 @@ async def autocomplete_get_committee_members(
except CommitteeRoleDoesNotExistError:
return set()

committee_elect_role: discord.Role | None = None
with contextlib.suppress(CommitteeElectRoleDoesNotExistError):
committee_elect_role = await ctx.bot.committee_elect_role

return {
discord.OptionChoice(
name=f"{member.display_name} ({member.global_name})", value=str(member.id)
)
for member in committee_role.members
for member in (
set(committee_role.members) | set(committee_elect_role.members)
if committee_elect_role is not None
else set()
)
if not member.bot
}

Expand Down Expand Up @@ -281,16 +291,15 @@ async def create(
required=True,
parameter_name="status",
)
@CommandChecks.check_interaction_user_has_committee_role
@CommandChecks.check_interaction_user_in_main_guild
async def update_status(
async def update_status( # NOTE: Committee role check is not present because non-committee can have actions, and need to be able to list their own actions.
self, ctx: "TeXBotApplicationContext", action_id: str, status: str
) -> None:
"""
Definition and callback of the "update-status" command.

Takes in an action object and a Status string,
sets the status of the provided action to be the provided status.
and must be able to update their own action status.
"""
try:
action_id_int: int = int(action_id)
Expand Down Expand Up @@ -561,9 +570,7 @@ async def action_all_committee(
default=None,
parameter_name="status",
)
@CommandChecks.check_interaction_user_has_committee_role
@CommandChecks.check_interaction_user_in_main_guild
async def list_user_actions(
async def list_user_actions( # NOTE: Committee role check is not present because non-committee can have actions, and need to be able to list their own actions.
self,
ctx: "TeXBotApplicationContext",
*,
Expand All @@ -575,15 +582,32 @@ async def list_user_actions(
Definition and callback of the "/list" command.

Takes in a user and lists out their current actions.
If no user is specified, the user issuing the command will be used.
If a user has the committee role, they can list actions for other users.
If a user does not have the committee role, they can only list their own actions.
"""
action_member: discord.Member | discord.User
action_member_id = action_member_id.strip()

action_member: discord.Member | discord.User = (
await self.bot.get_member_from_str_id(action_member_id)
if action_member_id
else ctx.user
)

if action_member_id:
action_member = await self.bot.get_member_from_str_id(
action_member_id,
if action_member != ctx.user and not await self.bot.check_user_has_committee_role(
ctx.user
):
await ctx.respond(
content="Committee role is required to list actions for other users.",
ephemeral=True,
)
else:
action_member = ctx.user
logger.debug(
"User: %s, tried to list actions for user: %s, "
"but did not have the committee role.",
ctx.user,
action_member,
)
return

user_actions: list[AssignedCommitteeAction]

Expand Down